babylon.d.txt 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075
  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 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. /**
  3282. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3284. */
  3285. class Analyser {
  3286. /**
  3287. * Gets or sets the smoothing
  3288. * @ignorenaming
  3289. */
  3290. SMOOTHING: number;
  3291. /**
  3292. * Gets or sets the FFT table size
  3293. * @ignorenaming
  3294. */
  3295. FFT_SIZE: number;
  3296. /**
  3297. * Gets or sets the bar graph amplitude
  3298. * @ignorenaming
  3299. */
  3300. BARGRAPHAMPLITUDE: number;
  3301. /**
  3302. * Gets or sets the position of the debug canvas
  3303. * @ignorenaming
  3304. */
  3305. DEBUGCANVASPOS: {
  3306. x: number;
  3307. y: number;
  3308. };
  3309. /**
  3310. * Gets or sets the debug canvas size
  3311. * @ignorenaming
  3312. */
  3313. DEBUGCANVASSIZE: {
  3314. width: number;
  3315. height: number;
  3316. };
  3317. private _byteFreqs;
  3318. private _byteTime;
  3319. private _floatFreqs;
  3320. private _webAudioAnalyser;
  3321. private _debugCanvas;
  3322. private _debugCanvasContext;
  3323. private _scene;
  3324. private _registerFunc;
  3325. private _audioEngine;
  3326. /**
  3327. * Creates a new analyser
  3328. * @param scene defines hosting scene
  3329. */
  3330. constructor(scene: Scene);
  3331. /**
  3332. * Get the number of data values you will have to play with for the visualization
  3333. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3334. * @returns a number
  3335. */
  3336. getFrequencyBinCount(): number;
  3337. /**
  3338. * Gets the current frequency data as a byte array
  3339. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3340. * @returns a Uint8Array
  3341. */
  3342. getByteFrequencyData(): Uint8Array;
  3343. /**
  3344. * Gets the current waveform as a byte array
  3345. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3346. * @returns a Uint8Array
  3347. */
  3348. getByteTimeDomainData(): Uint8Array;
  3349. /**
  3350. * Gets the current frequency data as a float array
  3351. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3352. * @returns a Float32Array
  3353. */
  3354. getFloatFrequencyData(): Float32Array;
  3355. /**
  3356. * Renders the debug canvas
  3357. */
  3358. drawDebugCanvas(): void;
  3359. /**
  3360. * Stops rendering the debug canvas and removes it
  3361. */
  3362. stopDebugCanvas(): void;
  3363. /**
  3364. * Connects two audio nodes
  3365. * @param inputAudioNode defines first node to connect
  3366. * @param outputAudioNode defines second node to connect
  3367. */
  3368. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3369. /**
  3370. * Releases all associated resources
  3371. */
  3372. dispose(): void;
  3373. }
  3374. }
  3375. declare module BABYLON {
  3376. class AudioEngine {
  3377. private _audioContext;
  3378. private _audioContextInitialized;
  3379. canUseWebAudio: boolean;
  3380. masterGain: GainNode;
  3381. private _connectedAnalyser;
  3382. WarnedWebAudioUnsupported: boolean;
  3383. unlocked: boolean;
  3384. onAudioUnlocked: () => any;
  3385. isMP3supported: boolean;
  3386. isOGGsupported: boolean;
  3387. readonly audioContext: Nullable<AudioContext>;
  3388. constructor();
  3389. private _unlockiOSaudio();
  3390. private _initializeAudioContext();
  3391. dispose(): void;
  3392. getGlobalVolume(): number;
  3393. setGlobalVolume(newVolume: number): void;
  3394. connectToAnalyser(analyser: Analyser): void;
  3395. }
  3396. }
  3397. declare module BABYLON {
  3398. class Sound {
  3399. name: string;
  3400. autoplay: boolean;
  3401. loop: boolean;
  3402. useCustomAttenuation: boolean;
  3403. soundTrackId: number;
  3404. spatialSound: boolean;
  3405. refDistance: number;
  3406. rolloffFactor: number;
  3407. maxDistance: number;
  3408. distanceModel: string;
  3409. private _panningModel;
  3410. onended: () => any;
  3411. private _playbackRate;
  3412. private _streaming;
  3413. private _startTime;
  3414. private _startOffset;
  3415. private _position;
  3416. private _localDirection;
  3417. private _volume;
  3418. private _isReadyToPlay;
  3419. isPlaying: boolean;
  3420. isPaused: boolean;
  3421. private _isDirectional;
  3422. private _readyToPlayCallback;
  3423. private _audioBuffer;
  3424. private _soundSource;
  3425. private _streamingSource;
  3426. private _soundPanner;
  3427. private _soundGain;
  3428. private _inputAudioNode;
  3429. private _ouputAudioNode;
  3430. private _coneInnerAngle;
  3431. private _coneOuterAngle;
  3432. private _coneOuterGain;
  3433. private _scene;
  3434. private _connectedMesh;
  3435. private _customAttenuationFunction;
  3436. private _registerFunc;
  3437. private _isOutputConnected;
  3438. private _htmlAudioElement;
  3439. private _urlType;
  3440. /**
  3441. * Create a sound and attach it to a scene
  3442. * @param name Name of your sound
  3443. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3444. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3445. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3446. */
  3447. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3448. dispose(): void;
  3449. isReady(): boolean;
  3450. private _soundLoaded(audioData);
  3451. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3452. updateOptions(options: any): void;
  3453. private _createSpatialParameters();
  3454. private _updateSpatialParameters();
  3455. switchPanningModelToHRTF(): void;
  3456. switchPanningModelToEqualPower(): void;
  3457. private _switchPanningModel();
  3458. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3459. /**
  3460. * Transform this sound into a directional source
  3461. * @param coneInnerAngle Size of the inner cone in degree
  3462. * @param coneOuterAngle Size of the outer cone in degree
  3463. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3464. */
  3465. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3466. setPosition(newPosition: Vector3): void;
  3467. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3468. private _updateDirection();
  3469. updateDistanceFromListener(): void;
  3470. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3471. /**
  3472. * Play the sound
  3473. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3474. * @param offset (optional) Start the sound setting it at a specific time
  3475. */
  3476. play(time?: number, offset?: number): void;
  3477. private _onended();
  3478. /**
  3479. * Stop the sound
  3480. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3481. */
  3482. stop(time?: number): void;
  3483. pause(): void;
  3484. setVolume(newVolume: number, time?: number): void;
  3485. setPlaybackRate(newPlaybackRate: number): void;
  3486. getVolume(): number;
  3487. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3488. detachFromMesh(): void;
  3489. private _onRegisterAfterWorldMatrixUpdate(node);
  3490. clone(): Nullable<Sound>;
  3491. getAudioBuffer(): AudioBuffer | null;
  3492. serialize(): any;
  3493. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3494. }
  3495. }
  3496. declare module BABYLON {
  3497. class SoundTrack {
  3498. private _outputAudioNode;
  3499. private _scene;
  3500. id: number;
  3501. soundCollection: Array<Sound>;
  3502. private _isMainTrack;
  3503. private _connectedAnalyser;
  3504. private _options;
  3505. private _isInitialized;
  3506. constructor(scene: Scene, options?: any);
  3507. private _initializeSoundTrackAudioGraph();
  3508. dispose(): void;
  3509. AddSound(sound: Sound): void;
  3510. RemoveSound(sound: Sound): void;
  3511. setVolume(newVolume: number): void;
  3512. switchPanningModelToHRTF(): void;
  3513. switchPanningModelToEqualPower(): void;
  3514. connectToAnalyser(analyser: Analyser): void;
  3515. }
  3516. }
  3517. declare module BABYLON {
  3518. class Animatable {
  3519. target: any;
  3520. fromFrame: number;
  3521. toFrame: number;
  3522. loopAnimation: boolean;
  3523. onAnimationEnd: (() => void) | null | undefined;
  3524. private _localDelayOffset;
  3525. private _pausedDelay;
  3526. private _runtimeAnimations;
  3527. private _paused;
  3528. private _scene;
  3529. private _speedRatio;
  3530. private _weight;
  3531. private _syncRoot;
  3532. animationStarted: boolean;
  3533. /**
  3534. * Observer raised when the animation ends
  3535. */
  3536. onAnimationEndObservable: Observable<Animatable>;
  3537. /**
  3538. * Gets the root Animatable used to synchronize and normalize animations
  3539. */
  3540. readonly syncRoot: Animatable;
  3541. /**
  3542. * Gets the current frame of the first RuntimeAnimation
  3543. * Used to synchronize Animatables
  3544. */
  3545. readonly masterFrame: number;
  3546. /**
  3547. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3548. */
  3549. weight: number;
  3550. /**
  3551. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3552. */
  3553. speedRatio: number;
  3554. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3555. /**
  3556. * Synchronize and normalize current Animatable with a source Animatable
  3557. * This is useful when using animation weights and when animations are not of the same length
  3558. * @param root defines the root Animatable to synchronize with
  3559. * @returns the current Animatable
  3560. */
  3561. syncWith(root: Animatable): Animatable;
  3562. getAnimations(): RuntimeAnimation[];
  3563. appendAnimations(target: any, animations: Animation[]): void;
  3564. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3565. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3566. reset(): void;
  3567. enableBlending(blendingSpeed: number): void;
  3568. disableBlending(): void;
  3569. goToFrame(frame: number): void;
  3570. pause(): void;
  3571. restart(): void;
  3572. private _raiseOnAnimationEnd();
  3573. stop(animationName?: string): void;
  3574. /**
  3575. * Wait asynchronously for the animation to end
  3576. * @returns a promise which will be fullfilled when the animation ends
  3577. */
  3578. waitAsync(): Promise<Animatable>;
  3579. /** @hidden */
  3580. }
  3581. }
  3582. declare module BABYLON {
  3583. /**
  3584. * Represents the range of an animation
  3585. */
  3586. class AnimationRange {
  3587. /**The name of the animation range**/
  3588. name: string;
  3589. /**The starting frame of the animation */
  3590. from: number;
  3591. /**The ending frame of the animation*/
  3592. to: number;
  3593. /**
  3594. * Initializes the range of an animation
  3595. * @param name The name of the animation range
  3596. * @param from The starting frame of the animation
  3597. * @param to The ending frame of the animation
  3598. */
  3599. constructor(
  3600. /**The name of the animation range**/
  3601. name: string,
  3602. /**The starting frame of the animation */
  3603. from: number,
  3604. /**The ending frame of the animation*/
  3605. to: number);
  3606. /**
  3607. * Makes a copy of the animation range
  3608. * @returns A copy of the animation range
  3609. */
  3610. clone(): AnimationRange;
  3611. }
  3612. /**
  3613. * Composed of a frame, and an action function
  3614. */
  3615. class AnimationEvent {
  3616. /** The frame for which the event is triggered **/
  3617. frame: number;
  3618. /** The event to perform when triggered **/
  3619. action: () => void;
  3620. /** Specifies if the event should be triggered only once**/
  3621. onlyOnce: boolean | undefined;
  3622. /**
  3623. * Specifies if the animation event is done
  3624. */
  3625. isDone: boolean;
  3626. /**
  3627. * Initializes the animation event
  3628. * @param frame The frame for which the event is triggered
  3629. * @param action The event to perform when triggered
  3630. * @param onlyOnce Specifies if the event should be triggered only once
  3631. */
  3632. constructor(
  3633. /** The frame for which the event is triggered **/
  3634. frame: number,
  3635. /** The event to perform when triggered **/
  3636. action: () => void,
  3637. /** Specifies if the event should be triggered only once**/
  3638. onlyOnce?: boolean | undefined);
  3639. /** @hidden */
  3640. }
  3641. /**
  3642. * A cursor which tracks a point on a path
  3643. */
  3644. class PathCursor {
  3645. private path;
  3646. /**
  3647. * Stores path cursor callbacks for when an onchange event is triggered
  3648. */
  3649. private _onchange;
  3650. /**
  3651. * The value of the path cursor
  3652. */
  3653. value: number;
  3654. /**
  3655. * The animation array of the path cursor
  3656. */
  3657. animations: Animation[];
  3658. /**
  3659. * Initializes the path cursor
  3660. * @param path The path to track
  3661. */
  3662. constructor(path: Path2);
  3663. /**
  3664. * Gets the cursor point on the path
  3665. * @returns A point on the path cursor at the cursor location
  3666. */
  3667. getPoint(): Vector3;
  3668. /**
  3669. * Moves the cursor ahead by the step amount
  3670. * @param step The amount to move the cursor forward
  3671. * @returns This path cursor
  3672. */
  3673. moveAhead(step?: number): PathCursor;
  3674. /**
  3675. * Moves the cursor behind by the step amount
  3676. * @param step The amount to move the cursor back
  3677. * @returns This path cursor
  3678. */
  3679. moveBack(step?: number): PathCursor;
  3680. /**
  3681. * Moves the cursor by the step amount
  3682. * If the step amount is greater than one, an exception is thrown
  3683. * @param step The amount to move the cursor
  3684. * @returns This path cursor
  3685. */
  3686. move(step: number): PathCursor;
  3687. /**
  3688. * Ensures that the value is limited between zero and one
  3689. * @returns This path cursor
  3690. */
  3691. private ensureLimits();
  3692. /**
  3693. * Runs onchange callbacks on change (used by the animation engine)
  3694. * @returns This path cursor
  3695. */
  3696. private raiseOnChange();
  3697. /**
  3698. * Executes a function on change
  3699. * @param f A path cursor onchange callback
  3700. * @returns This path cursor
  3701. */
  3702. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3703. }
  3704. /**
  3705. * Defines an interface which represents an animation key frame
  3706. */
  3707. interface IAnimationKey {
  3708. /**
  3709. * Frame of the key frame
  3710. */
  3711. frame: number;
  3712. /**
  3713. * Value at the specifies key frame
  3714. */
  3715. value: any;
  3716. /**
  3717. * The input tangent for the cubic hermite spline
  3718. */
  3719. inTangent?: any;
  3720. /**
  3721. * The output tangent for the cubic hermite spline
  3722. */
  3723. outTangent?: any;
  3724. /**
  3725. * The animation interpolation type
  3726. */
  3727. interpolation?: AnimationKeyInterpolation;
  3728. }
  3729. /**
  3730. * Enum for the animation key frame interpolation type
  3731. */
  3732. enum AnimationKeyInterpolation {
  3733. /**
  3734. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3735. */
  3736. STEP = 1,
  3737. }
  3738. /**
  3739. * Class used to store any kind of animation
  3740. */
  3741. class Animation {
  3742. /**Name of the animation */
  3743. name: string;
  3744. /**Property to animate */
  3745. targetProperty: string;
  3746. /**The frames per second of the animation */
  3747. framePerSecond: number;
  3748. /**The data type of the animation */
  3749. dataType: number;
  3750. /**The loop mode of the animation */
  3751. loopMode: number | undefined;
  3752. /**Specifies if blending should be enabled */
  3753. enableBlending: boolean | undefined;
  3754. /**
  3755. * Use matrix interpolation instead of using direct key value when animating matrices
  3756. */
  3757. static AllowMatricesInterpolation: boolean;
  3758. /**
  3759. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3760. */
  3761. static AllowMatrixDecomposeForInterpolation: boolean;
  3762. /**
  3763. * Stores the key frames of the animation
  3764. */
  3765. private _keys;
  3766. /**
  3767. * Stores the easing function of the animation
  3768. */
  3769. private _easingFunction;
  3770. /**
  3771. * @hidden Internal use only
  3772. */
  3773. /**
  3774. * The set of event that will be linked to this animation
  3775. */
  3776. private _events;
  3777. /**
  3778. * Stores an array of target property paths
  3779. */
  3780. targetPropertyPath: string[];
  3781. /**
  3782. * Stores the blending speed of the animation
  3783. */
  3784. blendingSpeed: number;
  3785. /**
  3786. * Stores the animation ranges for the animation
  3787. */
  3788. private _ranges;
  3789. /**
  3790. * @hidden Internal use
  3791. */
  3792. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3793. /**
  3794. * Sets up an animation
  3795. * @param property The property to animate
  3796. * @param animationType The animation type to apply
  3797. * @param framePerSecond The frames per second of the animation
  3798. * @param easingFunction The easing function used in the animation
  3799. * @returns The created animation
  3800. */
  3801. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3802. /**
  3803. * Create and start an animation on a node
  3804. * @param name defines the name of the global animation that will be run on all nodes
  3805. * @param node defines the root node where the animation will take place
  3806. * @param targetProperty defines property to animate
  3807. * @param framePerSecond defines the number of frame per second yo use
  3808. * @param totalFrame defines the number of frames in total
  3809. * @param from defines the initial value
  3810. * @param to defines the final value
  3811. * @param loopMode defines which loop mode you want to use (off by default)
  3812. * @param easingFunction defines the easing function to use (linear by default)
  3813. * @param onAnimationEnd defines the callback to call when animation end
  3814. * @returns the animatable created for this animation
  3815. */
  3816. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3817. /**
  3818. * Create and start an animation on a node and its descendants
  3819. * @param name defines the name of the global animation that will be run on all nodes
  3820. * @param node defines the root node where the animation will take place
  3821. * @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
  3822. * @param targetProperty defines property to animate
  3823. * @param framePerSecond defines the number of frame per second to use
  3824. * @param totalFrame defines the number of frames in total
  3825. * @param from defines the initial value
  3826. * @param to defines the final value
  3827. * @param loopMode defines which loop mode you want to use (off by default)
  3828. * @param easingFunction defines the easing function to use (linear by default)
  3829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3830. * @returns the list of animatables created for all nodes
  3831. * @example https://www.babylonjs-playground.com/#MH0VLI
  3832. */
  3833. 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[]>;
  3834. /**
  3835. * Creates a new animation, merges it with the existing animations and starts it
  3836. * @param name Name of the animation
  3837. * @param node Node which contains the scene that begins the animations
  3838. * @param targetProperty Specifies which property to animate
  3839. * @param framePerSecond The frames per second of the animation
  3840. * @param totalFrame The total number of frames
  3841. * @param from The frame at the beginning of the animation
  3842. * @param to The frame at the end of the animation
  3843. * @param loopMode Specifies the loop mode of the animation
  3844. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3845. * @param onAnimationEnd Callback to run once the animation is complete
  3846. * @returns Nullable animation
  3847. */
  3848. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3849. /**
  3850. * Transition property of an host to the target Value
  3851. * @param property The property to transition
  3852. * @param targetValue The target Value of the property
  3853. * @param host The object where the property to animate belongs
  3854. * @param scene Scene used to run the animation
  3855. * @param frameRate Framerate (in frame/s) to use
  3856. * @param transition The transition type we want to use
  3857. * @param duration The duration of the animation, in milliseconds
  3858. * @param onAnimationEnd Callback trigger at the end of the animation
  3859. * @returns Nullable animation
  3860. */
  3861. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3862. /**
  3863. * Return the array of runtime animations currently using this animation
  3864. */
  3865. readonly runtimeAnimations: RuntimeAnimation[];
  3866. /**
  3867. * Specifies if any of the runtime animations are currently running
  3868. */
  3869. readonly hasRunningRuntimeAnimations: boolean;
  3870. /**
  3871. * Initializes the animation
  3872. * @param name Name of the animation
  3873. * @param targetProperty Property to animate
  3874. * @param framePerSecond The frames per second of the animation
  3875. * @param dataType The data type of the animation
  3876. * @param loopMode The loop mode of the animation
  3877. * @param enableBlendings Specifies if blending should be enabled
  3878. */
  3879. constructor(
  3880. /**Name of the animation */
  3881. name: string,
  3882. /**Property to animate */
  3883. targetProperty: string,
  3884. /**The frames per second of the animation */
  3885. framePerSecond: number,
  3886. /**The data type of the animation */
  3887. dataType: number,
  3888. /**The loop mode of the animation */
  3889. loopMode?: number | undefined,
  3890. /**Specifies if blending should be enabled */
  3891. enableBlending?: boolean | undefined);
  3892. /**
  3893. * Converts the animation to a string
  3894. * @param fullDetails support for multiple levels of logging within scene loading
  3895. * @returns String form of the animation
  3896. */
  3897. toString(fullDetails?: boolean): string;
  3898. /**
  3899. * Add an event to this animation
  3900. * @param event Event to add
  3901. */
  3902. addEvent(event: AnimationEvent): void;
  3903. /**
  3904. * Remove all events found at the given frame
  3905. * @param frame The frame to remove events from
  3906. */
  3907. removeEvents(frame: number): void;
  3908. /**
  3909. * Retrieves all the events from the animation
  3910. * @returns Events from the animation
  3911. */
  3912. getEvents(): AnimationEvent[];
  3913. /**
  3914. * Creates an animation range
  3915. * @param name Name of the animation range
  3916. * @param from Starting frame of the animation range
  3917. * @param to Ending frame of the animation
  3918. */
  3919. createRange(name: string, from: number, to: number): void;
  3920. /**
  3921. * Deletes an animation range by name
  3922. * @param name Name of the animation range to delete
  3923. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3924. */
  3925. deleteRange(name: string, deleteFrames?: boolean): void;
  3926. /**
  3927. * Gets the animation range by name, or null if not defined
  3928. * @param name Name of the animation range
  3929. * @returns Nullable animation range
  3930. */
  3931. getRange(name: string): Nullable<AnimationRange>;
  3932. /**
  3933. * Gets the key frames from the animation
  3934. * @returns The key frames of the animation
  3935. */
  3936. getKeys(): Array<IAnimationKey>;
  3937. /**
  3938. * Gets the highest frame rate of the animation
  3939. * @returns Highest frame rate of the animation
  3940. */
  3941. getHighestFrame(): number;
  3942. /**
  3943. * Gets the easing function of the animation
  3944. * @returns Easing function of the animation
  3945. */
  3946. getEasingFunction(): IEasingFunction;
  3947. /**
  3948. * Sets the easing function of the animation
  3949. * @param easingFunction A custom mathematical formula for animation
  3950. */
  3951. setEasingFunction(easingFunction: EasingFunction): void;
  3952. /**
  3953. * Interpolates a scalar linearly
  3954. * @param startValue Start value of the animation curve
  3955. * @param endValue End value of the animation curve
  3956. * @param gradient Scalar amount to interpolate
  3957. * @returns Interpolated scalar value
  3958. */
  3959. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3960. /**
  3961. * Interpolates a scalar cubically
  3962. * @param startValue Start value of the animation curve
  3963. * @param outTangent End tangent of the animation
  3964. * @param endValue End value of the animation curve
  3965. * @param inTangent Start tangent of the animation curve
  3966. * @param gradient Scalar amount to interpolate
  3967. * @returns Interpolated scalar value
  3968. */
  3969. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3970. /**
  3971. * Interpolates a quaternion using a spherical linear interpolation
  3972. * @param startValue Start value of the animation curve
  3973. * @param endValue End value of the animation curve
  3974. * @param gradient Scalar amount to interpolate
  3975. * @returns Interpolated quaternion value
  3976. */
  3977. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3978. /**
  3979. * Interpolates a quaternion cubically
  3980. * @param startValue Start value of the animation curve
  3981. * @param outTangent End tangent of the animation curve
  3982. * @param endValue End value of the animation curve
  3983. * @param inTangent Start tangent of the animation curve
  3984. * @param gradient Scalar amount to interpolate
  3985. * @returns Interpolated quaternion value
  3986. */
  3987. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3988. /**
  3989. * Interpolates a Vector3 linearl
  3990. * @param startValue Start value of the animation curve
  3991. * @param endValue End value of the animation curve
  3992. * @param gradient Scalar amount to interpolate
  3993. * @returns Interpolated scalar value
  3994. */
  3995. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3996. /**
  3997. * Interpolates a Vector3 cubically
  3998. * @param startValue Start value of the animation curve
  3999. * @param outTangent End tangent of the animation
  4000. * @param endValue End value of the animation curve
  4001. * @param inTangent Start tangent of the animation curve
  4002. * @param gradient Scalar amount to interpolate
  4003. * @returns InterpolatedVector3 value
  4004. */
  4005. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4006. /**
  4007. * Interpolates a Vector2 linearly
  4008. * @param startValue Start value of the animation curve
  4009. * @param endValue End value of the animation curve
  4010. * @param gradient Scalar amount to interpolate
  4011. * @returns Interpolated Vector2 value
  4012. */
  4013. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4014. /**
  4015. * Interpolates a Vector2 cubically
  4016. * @param startValue Start value of the animation curve
  4017. * @param outTangent End tangent of the animation
  4018. * @param endValue End value of the animation curve
  4019. * @param inTangent Start tangent of the animation curve
  4020. * @param gradient Scalar amount to interpolate
  4021. * @returns Interpolated Vector2 value
  4022. */
  4023. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4024. /**
  4025. * Interpolates a size linearly
  4026. * @param startValue Start value of the animation curve
  4027. * @param endValue End value of the animation curve
  4028. * @param gradient Scalar amount to interpolate
  4029. * @returns Interpolated Size value
  4030. */
  4031. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4032. /**
  4033. * Interpolates a Color3 linearly
  4034. * @param startValue Start value of the animation curve
  4035. * @param endValue End value of the animation curve
  4036. * @param gradient Scalar amount to interpolate
  4037. * @returns Interpolated Color3 value
  4038. */
  4039. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4040. /**
  4041. * @hidden Internal use only
  4042. */
  4043. /**
  4044. * @hidden Internal use only
  4045. */
  4046. /**
  4047. * Defines the function to use to interpolate matrices
  4048. * @param startValue defines the start matrix
  4049. * @param endValue defines the end matrix
  4050. * @param gradient defines the gradient between both matrices
  4051. * @param result defines an optional target matrix where to store the interpolation
  4052. * @returns the interpolated matrix
  4053. */
  4054. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4055. /**
  4056. * Makes a copy of the animation
  4057. * @returns Cloned animation
  4058. */
  4059. clone(): Animation;
  4060. /**
  4061. * Sets the key frames of the animation
  4062. * @param values The animation key frames to set
  4063. */
  4064. setKeys(values: Array<IAnimationKey>): void;
  4065. /**
  4066. * Serializes the animation to an object
  4067. * @returns Serialized object
  4068. */
  4069. serialize(): any;
  4070. /**
  4071. * Float animation type
  4072. */
  4073. private static _ANIMATIONTYPE_FLOAT;
  4074. /**
  4075. * Vector3 animation type
  4076. */
  4077. private static _ANIMATIONTYPE_VECTOR3;
  4078. /**
  4079. * Quaternion animation type
  4080. */
  4081. private static _ANIMATIONTYPE_QUATERNION;
  4082. /**
  4083. * Matrix animation type
  4084. */
  4085. private static _ANIMATIONTYPE_MATRIX;
  4086. /**
  4087. * Color3 animation type
  4088. */
  4089. private static _ANIMATIONTYPE_COLOR3;
  4090. /**
  4091. * Vector2 animation type
  4092. */
  4093. private static _ANIMATIONTYPE_VECTOR2;
  4094. /**
  4095. * Size animation type
  4096. */
  4097. private static _ANIMATIONTYPE_SIZE;
  4098. /**
  4099. * Relative Loop Mode
  4100. */
  4101. private static _ANIMATIONLOOPMODE_RELATIVE;
  4102. /**
  4103. * Cycle Loop Mode
  4104. */
  4105. private static _ANIMATIONLOOPMODE_CYCLE;
  4106. /**
  4107. * Constant Loop Mode
  4108. */
  4109. private static _ANIMATIONLOOPMODE_CONSTANT;
  4110. /**
  4111. * Get the float animation type
  4112. */
  4113. static readonly ANIMATIONTYPE_FLOAT: number;
  4114. /**
  4115. * Get the Vector3 animation type
  4116. */
  4117. static readonly ANIMATIONTYPE_VECTOR3: number;
  4118. /**
  4119. * Get the Vectpr2 animation type
  4120. */
  4121. static readonly ANIMATIONTYPE_VECTOR2: number;
  4122. /**
  4123. * Get the Size animation type
  4124. */
  4125. static readonly ANIMATIONTYPE_SIZE: number;
  4126. /**
  4127. * Get the Quaternion animation type
  4128. */
  4129. static readonly ANIMATIONTYPE_QUATERNION: number;
  4130. /**
  4131. * Get the Matrix animation type
  4132. */
  4133. static readonly ANIMATIONTYPE_MATRIX: number;
  4134. /**
  4135. * Get the Color3 animation type
  4136. */
  4137. static readonly ANIMATIONTYPE_COLOR3: number;
  4138. /**
  4139. * Get the Relative Loop Mode
  4140. */
  4141. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4142. /**
  4143. * Get the Cycle Loop Mode
  4144. */
  4145. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4146. /**
  4147. * Get the Constant Loop Mode
  4148. */
  4149. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4150. /** @hidden */
  4151. private static _UniversalLerp(left: any, right: any, amount: number): any;
  4152. /**
  4153. * Parses an animation object and creates an animation
  4154. * @param parsedAnimation Parsed animation object
  4155. * @returns Animation object
  4156. */
  4157. static Parse(parsedAnimation: any): Animation;
  4158. /**
  4159. * Appends the serialized animations from the source animations
  4160. * @param source Source containing the animations
  4161. * @param destination Target to store the animations
  4162. */
  4163. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4164. }
  4165. }
  4166. declare module BABYLON {
  4167. /**
  4168. * This class defines the direct association between an animation and a target
  4169. */
  4170. class TargetedAnimation {
  4171. animation: Animation;
  4172. target: any;
  4173. }
  4174. /**
  4175. * Use this class to create coordinated animations on multiple targets
  4176. */
  4177. class AnimationGroup implements IDisposable {
  4178. name: string;
  4179. private _scene;
  4180. private _targetedAnimations;
  4181. private _animatables;
  4182. private _from;
  4183. private _to;
  4184. private _isStarted;
  4185. private _speedRatio;
  4186. onAnimationEndObservable: Observable<TargetedAnimation>;
  4187. /**
  4188. * This observable will notify when all animations have ended.
  4189. */
  4190. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4191. /**
  4192. * Gets the first frame
  4193. */
  4194. readonly from: number;
  4195. /**
  4196. * Gets the last frame
  4197. */
  4198. readonly to: number;
  4199. /**
  4200. * Define if the animations are started
  4201. */
  4202. readonly isStarted: boolean;
  4203. /**
  4204. * Gets or sets the speed ratio to use for all animations
  4205. */
  4206. /**
  4207. * Gets or sets the speed ratio to use for all animations
  4208. */
  4209. speedRatio: number;
  4210. /**
  4211. * Gets the targeted animations for this animation group
  4212. */
  4213. readonly targetedAnimations: Array<TargetedAnimation>;
  4214. /**
  4215. * returning the list of animatables controlled by this animation group.
  4216. */
  4217. readonly animatables: Array<Animatable>;
  4218. constructor(name: string, scene?: Nullable<Scene>);
  4219. /**
  4220. * Add an animation (with its target) in the group
  4221. * @param animation defines the animation we want to add
  4222. * @param target defines the target of the animation
  4223. * @returns the {BABYLON.TargetedAnimation} object
  4224. */
  4225. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4226. /**
  4227. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4228. * It can add constant keys at begin or end
  4229. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4230. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4231. */
  4232. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4233. /**
  4234. * Start all animations on given targets
  4235. * @param loop defines if animations must loop
  4236. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4237. * @param from defines the from key (optional)
  4238. * @param to defines the to key (optional)
  4239. * @returns the current animation group
  4240. */
  4241. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4242. /**
  4243. * Pause all animations
  4244. */
  4245. pause(): AnimationGroup;
  4246. /**
  4247. * Play all animations to initial state
  4248. * This function will start() the animations if they were not started or will restart() them if they were paused
  4249. * @param loop defines if animations must loop
  4250. */
  4251. play(loop?: boolean): AnimationGroup;
  4252. /**
  4253. * Reset all animations to initial state
  4254. */
  4255. reset(): AnimationGroup;
  4256. /**
  4257. * Restart animations from key 0
  4258. */
  4259. restart(): AnimationGroup;
  4260. /**
  4261. * Stop all animations
  4262. */
  4263. stop(): AnimationGroup;
  4264. /**
  4265. * Set animation weight for all animatables
  4266. * @param weight defines the weight to use
  4267. * @return the animationGroup
  4268. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4269. */
  4270. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4271. /**
  4272. * Synchronize and normalize all animatables with a source animatable
  4273. * @param root defines the root animatable to synchronize with
  4274. * @return the animationGroup
  4275. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4276. */
  4277. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4278. /**
  4279. * Goes to a specific frame in this animation group
  4280. * @param frame the frame number to go to
  4281. * @return the animationGroup
  4282. */
  4283. goToFrame(frame: number): AnimationGroup;
  4284. /**
  4285. * Dispose all associated resources
  4286. */
  4287. dispose(): void;
  4288. private _checkAnimationGroupEnded(animatable);
  4289. }
  4290. }
  4291. declare module BABYLON {
  4292. /**
  4293. * Class used to override all child animations of a given target
  4294. */
  4295. class AnimationPropertiesOverride {
  4296. /**
  4297. * Gets or sets a value indicating if animation blending must be used
  4298. */
  4299. enableBlending: boolean;
  4300. /**
  4301. * Gets or sets the blending speed to use when enableBlending is true
  4302. */
  4303. blendingSpeed: number;
  4304. /**
  4305. * Gets or sets the default loop mode to use
  4306. */
  4307. loopMode: number;
  4308. }
  4309. }
  4310. declare module BABYLON {
  4311. interface IEasingFunction {
  4312. ease(gradient: number): number;
  4313. }
  4314. class EasingFunction implements IEasingFunction {
  4315. private static _EASINGMODE_EASEIN;
  4316. private static _EASINGMODE_EASEOUT;
  4317. private static _EASINGMODE_EASEINOUT;
  4318. static readonly EASINGMODE_EASEIN: number;
  4319. static readonly EASINGMODE_EASEOUT: number;
  4320. static readonly EASINGMODE_EASEINOUT: number;
  4321. private _easingMode;
  4322. setEasingMode(easingMode: number): void;
  4323. getEasingMode(): number;
  4324. easeInCore(gradient: number): number;
  4325. ease(gradient: number): number;
  4326. }
  4327. class CircleEase extends EasingFunction implements IEasingFunction {
  4328. easeInCore(gradient: number): number;
  4329. }
  4330. class BackEase extends EasingFunction implements IEasingFunction {
  4331. amplitude: number;
  4332. constructor(amplitude?: number);
  4333. easeInCore(gradient: number): number;
  4334. }
  4335. class BounceEase extends EasingFunction implements IEasingFunction {
  4336. bounces: number;
  4337. bounciness: number;
  4338. constructor(bounces?: number, bounciness?: number);
  4339. easeInCore(gradient: number): number;
  4340. }
  4341. class CubicEase extends EasingFunction implements IEasingFunction {
  4342. easeInCore(gradient: number): number;
  4343. }
  4344. class ElasticEase extends EasingFunction implements IEasingFunction {
  4345. oscillations: number;
  4346. springiness: number;
  4347. constructor(oscillations?: number, springiness?: number);
  4348. easeInCore(gradient: number): number;
  4349. }
  4350. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4351. exponent: number;
  4352. constructor(exponent?: number);
  4353. easeInCore(gradient: number): number;
  4354. }
  4355. class PowerEase extends EasingFunction implements IEasingFunction {
  4356. power: number;
  4357. constructor(power?: number);
  4358. easeInCore(gradient: number): number;
  4359. }
  4360. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4361. easeInCore(gradient: number): number;
  4362. }
  4363. class QuarticEase extends EasingFunction implements IEasingFunction {
  4364. easeInCore(gradient: number): number;
  4365. }
  4366. class QuinticEase extends EasingFunction implements IEasingFunction {
  4367. easeInCore(gradient: number): number;
  4368. }
  4369. class SineEase extends EasingFunction implements IEasingFunction {
  4370. easeInCore(gradient: number): number;
  4371. }
  4372. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4373. x1: number;
  4374. y1: number;
  4375. x2: number;
  4376. y2: number;
  4377. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4378. easeInCore(gradient: number): number;
  4379. }
  4380. }
  4381. declare module BABYLON {
  4382. /**
  4383. * Defines a runtime animation
  4384. */
  4385. class RuntimeAnimation {
  4386. private _events;
  4387. /**
  4388. * The current frame of the runtime animation
  4389. */
  4390. private _currentFrame;
  4391. /**
  4392. * The animation used by the runtime animation
  4393. */
  4394. private _animation;
  4395. /**
  4396. * The target of the runtime animation
  4397. */
  4398. private _target;
  4399. /**
  4400. * The initiating animatable
  4401. */
  4402. private _host;
  4403. /**
  4404. * The original value of the runtime animation
  4405. */
  4406. private _originalValue;
  4407. /**
  4408. * The original blend value of the runtime animation
  4409. */
  4410. private _originalBlendValue;
  4411. /**
  4412. * The offsets cache of the runtime animation
  4413. */
  4414. private _offsetsCache;
  4415. /**
  4416. * The high limits cache of the runtime animation
  4417. */
  4418. private _highLimitsCache;
  4419. /**
  4420. * Specifies if the runtime animation has been stopped
  4421. */
  4422. private _stopped;
  4423. /**
  4424. * The blending factor of the runtime animation
  4425. */
  4426. private _blendingFactor;
  4427. /**
  4428. * The BabylonJS scene
  4429. */
  4430. private _scene;
  4431. /**
  4432. * The current value of the runtime animation
  4433. */
  4434. private _currentValue;
  4435. /** @hidden */
  4436. /**
  4437. * The active target of the runtime animation
  4438. */
  4439. private _activeTarget;
  4440. /**
  4441. * The target path of the runtime animation
  4442. */
  4443. private _targetPath;
  4444. /**
  4445. * The weight of the runtime animation
  4446. */
  4447. private _weight;
  4448. /**
  4449. * The ratio offset of the runtime animation
  4450. */
  4451. private _ratioOffset;
  4452. /**
  4453. * The previous delay of the runtime animation
  4454. */
  4455. private _previousDelay;
  4456. /**
  4457. * The previous ratio of the runtime animation
  4458. */
  4459. private _previousRatio;
  4460. /**
  4461. * Gets the current frame of the runtime animation
  4462. */
  4463. readonly currentFrame: number;
  4464. /**
  4465. * Gets the weight of the runtime animation
  4466. */
  4467. readonly weight: number;
  4468. /**
  4469. * Gets the current value of the runtime animation
  4470. */
  4471. readonly currentValue: any;
  4472. /**
  4473. * Gets the target path of the runtime animation
  4474. */
  4475. readonly targetPath: string;
  4476. /**
  4477. * Gets the actual target of the runtime animation
  4478. */
  4479. readonly target: any;
  4480. /**
  4481. * Create a new RuntimeAnimation object
  4482. * @param target defines the target of the animation
  4483. * @param animation defines the source animation object
  4484. * @param scene defines the hosting scene
  4485. * @param host defines the initiating Animatable
  4486. */
  4487. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4488. /**
  4489. * Gets the animation from the runtime animation
  4490. */
  4491. readonly animation: Animation;
  4492. /**
  4493. * Resets the runtime animation to the beginning
  4494. * @param restoreOriginal defines whether to restore the target property to the original value
  4495. */
  4496. reset(restoreOriginal?: boolean): void;
  4497. /**
  4498. * Specifies if the runtime animation is stopped
  4499. * @returns Boolean specifying if the runtime animation is stopped
  4500. */
  4501. isStopped(): boolean;
  4502. /**
  4503. * Disposes of the runtime animation
  4504. */
  4505. dispose(): void;
  4506. /**
  4507. * Interpolates the animation from the current frame
  4508. * @param currentFrame The frame to interpolate the animation to
  4509. * @param repeatCount The number of times that the animation should loop
  4510. * @param loopMode The type of looping mode to use
  4511. * @param offsetValue Animation offset value
  4512. * @param highLimitValue The high limit value
  4513. * @returns The interpolated value
  4514. */
  4515. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4516. /**
  4517. * Apply the interpolated value to the target
  4518. * @param currentValue defines the value computed by the animation
  4519. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4520. */
  4521. setValue(currentValue: any, weight?: number): void;
  4522. private _setValue(target, currentValue, weight, targetIndex?);
  4523. /**
  4524. * Gets the loop pmode of the runtime animation
  4525. * @returns Loop Mode
  4526. */
  4527. private _getCorrectLoopMode();
  4528. /**
  4529. * Move the current animation to a given frame
  4530. * @param frame defines the frame to move to
  4531. */
  4532. goToFrame(frame: number): void;
  4533. /**
  4534. * @hidden Internal use only
  4535. */
  4536. /**
  4537. * Execute the current animation
  4538. * @param delay defines the delay to add to the current frame
  4539. * @param from defines the lower bound of the animation range
  4540. * @param to defines the upper bound of the animation range
  4541. * @param loop defines if the current animation must loop
  4542. * @param speedRatio defines the current speed ratio
  4543. * @param weight defines the weight of the animation (default is -1 so no weight)
  4544. * @returns a boolean indicating if the animation has ended
  4545. */
  4546. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4547. }
  4548. }
  4549. declare module BABYLON {
  4550. /**
  4551. * Interface used to define a behavior
  4552. */
  4553. interface Behavior<T> {
  4554. /** gets or sets behavior's name */
  4555. name: string;
  4556. /**
  4557. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4558. */
  4559. init(): void;
  4560. /**
  4561. * Called when the behavior is attached to a target
  4562. * @param target defines the target where the behavior is attached to
  4563. */
  4564. attach(target: T): void;
  4565. /**
  4566. * Called when the behavior is detached from its target
  4567. */
  4568. detach(): void;
  4569. }
  4570. /**
  4571. * Interface implemented by classes supporting behaviors
  4572. */
  4573. interface IBehaviorAware<T> {
  4574. /**
  4575. * Attach a behavior
  4576. * @param behavior defines the behavior to attach
  4577. * @returns the current host
  4578. */
  4579. addBehavior(behavior: Behavior<T>): T;
  4580. /**
  4581. * Remove a behavior from the current object
  4582. * @param behavior defines the behavior to detach
  4583. * @returns the current host
  4584. */
  4585. removeBehavior(behavior: Behavior<T>): T;
  4586. /**
  4587. * Gets a behavior using its name to search
  4588. * @param name defines the name to search
  4589. * @returns the behavior or null if not found
  4590. */
  4591. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4592. }
  4593. }
  4594. declare module BABYLON {
  4595. /**
  4596. * Class used to store bone information
  4597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4598. */
  4599. class Bone extends Node {
  4600. /**
  4601. * defines the bone name
  4602. */
  4603. name: string;
  4604. private static _tmpVecs;
  4605. private static _tmpQuat;
  4606. private static _tmpMats;
  4607. /**
  4608. * Gets the list of child bones
  4609. */
  4610. children: Bone[];
  4611. /** Gets the animations associated with this bone */
  4612. animations: Animation[];
  4613. /**
  4614. * Gets or sets bone length
  4615. */
  4616. length: number;
  4617. /**
  4618. * @hidden Internal only
  4619. * Set this value to map this bone to a different index in the transform matrices
  4620. * Set this value to -1 to exclude the bone from the transform matrices
  4621. */
  4622. private _skeleton;
  4623. private _localMatrix;
  4624. private _restPose;
  4625. private _baseMatrix;
  4626. private _absoluteTransform;
  4627. private _invertedAbsoluteTransform;
  4628. private _parent;
  4629. private _scalingDeterminant;
  4630. private _worldTransform;
  4631. private _localScaling;
  4632. private _localRotation;
  4633. private _localPosition;
  4634. private _needToDecompose;
  4635. private _needToCompose;
  4636. /** @hidden */
  4637. /** @hidden */
  4638. /**
  4639. * Create a new bone
  4640. * @param name defines the bone name
  4641. * @param skeleton defines the parent skeleton
  4642. * @param parentBone defines the parent (can be null if the bone is the root)
  4643. * @param localMatrix defines the local matrix
  4644. * @param restPose defines the rest pose matrix
  4645. * @param baseMatrix defines the base matrix
  4646. * @param index defines index of the bone in the hiearchy
  4647. */
  4648. constructor(
  4649. /**
  4650. * defines the bone name
  4651. */
  4652. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4653. /**
  4654. * Gets the parent skeleton
  4655. * @returns a skeleton
  4656. */
  4657. getSkeleton(): Skeleton;
  4658. /**
  4659. * Gets parent bone
  4660. * @returns a bone or null if the bone is the root of the bone hierarchy
  4661. */
  4662. getParent(): Nullable<Bone>;
  4663. /**
  4664. * Sets the parent bone
  4665. * @param parent defines the parent (can be null if the bone is the root)
  4666. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4667. */
  4668. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4669. /**
  4670. * Gets the local matrix
  4671. * @returns a matrix
  4672. */
  4673. getLocalMatrix(): Matrix;
  4674. /**
  4675. * Gets the base matrix (initial matrix which remains unchanged)
  4676. * @returns a matrix
  4677. */
  4678. getBaseMatrix(): Matrix;
  4679. /**
  4680. * Gets the rest pose matrix
  4681. * @returns a matrix
  4682. */
  4683. getRestPose(): Matrix;
  4684. /**
  4685. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4686. */
  4687. getWorldMatrix(): Matrix;
  4688. /**
  4689. * Sets the local matrix to rest pose matrix
  4690. */
  4691. returnToRest(): void;
  4692. /**
  4693. * Gets the inverse of the absolute transform matrix.
  4694. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4695. * @returns a matrix
  4696. */
  4697. getInvertedAbsoluteTransform(): Matrix;
  4698. /**
  4699. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4700. * @returns a matrix
  4701. */
  4702. getAbsoluteTransform(): Matrix;
  4703. /** Gets or sets current position (in local space) */
  4704. position: Vector3;
  4705. /** Gets or sets current rotation (in local space) */
  4706. rotation: Vector3;
  4707. /** Gets or sets current rotation quaternion (in local space) */
  4708. rotationQuaternion: Quaternion;
  4709. /** Gets or sets current scaling (in local space) */
  4710. scaling: Vector3;
  4711. /**
  4712. * Gets the animation properties override
  4713. */
  4714. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4715. private _decompose();
  4716. private _compose();
  4717. /**
  4718. * Update the base and local matrices
  4719. * @param matrix defines the new base or local matrix
  4720. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4721. * @param updateLocalMatrix defines if the local matrix should be updated
  4722. */
  4723. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4724. /** @hidden */
  4725. /**
  4726. * Flag the bone as dirty (Forcing it to update everything)
  4727. */
  4728. markAsDirty(): void;
  4729. private _markAsDirtyAndCompose();
  4730. private _markAsDirtyAndDecompose();
  4731. /**
  4732. * Copy an animation range from another bone
  4733. * @param source defines the source bone
  4734. * @param rangeName defines the range name to copy
  4735. * @param frameOffset defines the frame offset
  4736. * @param rescaleAsRequired defines if rescaling must be applied if required
  4737. * @param skelDimensionsRatio defines the scaling ratio
  4738. * @returns true if operation was successful
  4739. */
  4740. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4741. /**
  4742. * Translate the bone in local or world space
  4743. * @param vec The amount to translate the bone
  4744. * @param space The space that the translation is in
  4745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4746. */
  4747. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4748. /**
  4749. * Set the postion of the bone in local or world space
  4750. * @param position The position to set the bone
  4751. * @param space The space that the position is in
  4752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4753. */
  4754. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4755. /**
  4756. * Set the absolute position of the bone (world space)
  4757. * @param position The position to set the bone
  4758. * @param mesh The mesh that this bone is attached to
  4759. */
  4760. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4761. /**
  4762. * Scale the bone on the x, y and z axes (in local space)
  4763. * @param x The amount to scale the bone on the x axis
  4764. * @param y The amount to scale the bone on the y axis
  4765. * @param z The amount to scale the bone on the z axis
  4766. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4767. */
  4768. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4769. /**
  4770. * Set the bone scaling in local space
  4771. * @param scale defines the scaling vector
  4772. */
  4773. setScale(scale: Vector3): void;
  4774. /**
  4775. * Gets the current scaling in local space
  4776. * @returns the current scaling vector
  4777. */
  4778. getScale(): Vector3;
  4779. /**
  4780. * Gets the current scaling in local space and stores it in a target vector
  4781. * @param result defines the target vector
  4782. */
  4783. getScaleToRef(result: Vector3): void;
  4784. /**
  4785. * Set the yaw, pitch, and roll of the bone in local or world space
  4786. * @param yaw The rotation of the bone on the y axis
  4787. * @param pitch The rotation of the bone on the x axis
  4788. * @param roll The rotation of the bone on the z axis
  4789. * @param space The space that the axes of rotation are in
  4790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4791. */
  4792. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4793. /**
  4794. * Add a rotation to the bone on an axis in local or world space
  4795. * @param axis The axis to rotate the bone on
  4796. * @param amount The amount to rotate the bone
  4797. * @param space The space that the axis is in
  4798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4799. */
  4800. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4801. /**
  4802. * Set the rotation of the bone to a particular axis angle in local or world space
  4803. * @param axis The axis to rotate the bone on
  4804. * @param angle The angle that the bone should be rotated to
  4805. * @param space The space that the axis is in
  4806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4807. */
  4808. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4809. /**
  4810. * Set the euler rotation of the bone in local of world space
  4811. * @param rotation The euler rotation that the bone should be set to
  4812. * @param space The space that the rotation is in
  4813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4814. */
  4815. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4816. /**
  4817. * Set the quaternion rotation of the bone in local of world space
  4818. * @param quat The quaternion rotation that the bone should be set to
  4819. * @param space The space that the rotation is in
  4820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4821. */
  4822. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4823. /**
  4824. * Set the rotation matrix of the bone in local of world space
  4825. * @param rotMat The rotation matrix that the bone should be set to
  4826. * @param space The space that the rotation is in
  4827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4828. */
  4829. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4830. private _rotateWithMatrix(rmat, space?, mesh?);
  4831. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4832. /**
  4833. * Get the position of the bone in local or world space
  4834. * @param space The space that the returned position is in
  4835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4836. * @returns The position of the bone
  4837. */
  4838. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4839. /**
  4840. * Copy the position of the bone to a vector3 in local or world space
  4841. * @param space The space that the returned position is in
  4842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4843. * @param result The vector3 to copy the position to
  4844. */
  4845. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4846. /**
  4847. * Get the absolute position of the bone (world space)
  4848. * @param mesh The mesh that this bone is attached to
  4849. * @returns The absolute position of the bone
  4850. */
  4851. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4852. /**
  4853. * Copy the absolute position of the bone (world space) to the result param
  4854. * @param mesh The mesh that this bone is attached to
  4855. * @param result The vector3 to copy the absolute position to
  4856. */
  4857. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4858. /**
  4859. * Compute the absolute transforms of this bone and its children
  4860. */
  4861. computeAbsoluteTransforms(): void;
  4862. /**
  4863. * Get the world direction from an axis that is in the local space of the bone
  4864. * @param localAxis The local direction that is used to compute the world direction
  4865. * @param mesh The mesh that this bone is attached to
  4866. * @returns The world direction
  4867. */
  4868. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4869. /**
  4870. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4871. * @param localAxis The local direction that is used to compute the world direction
  4872. * @param mesh The mesh that this bone is attached to
  4873. * @param result The vector3 that the world direction will be copied to
  4874. */
  4875. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4876. /**
  4877. * Get the euler rotation of the bone in local or world space
  4878. * @param space The space that the rotation should be in
  4879. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4880. * @returns The euler rotation
  4881. */
  4882. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4883. /**
  4884. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4885. * @param space The space that the rotation should be in
  4886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4887. * @param result The vector3 that the rotation should be copied to
  4888. */
  4889. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4890. /**
  4891. * Get the quaternion rotation of the bone in either local or world space
  4892. * @param space The space that the rotation should be in
  4893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4894. * @returns The quaternion rotation
  4895. */
  4896. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4897. /**
  4898. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4899. * @param space The space that the rotation should be in
  4900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4901. * @param result The quaternion that the rotation should be copied to
  4902. */
  4903. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4904. /**
  4905. * Get the rotation matrix of the bone in local or world space
  4906. * @param space The space that the rotation should be in
  4907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4908. * @returns The rotation matrix
  4909. */
  4910. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4911. /**
  4912. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4913. * @param space The space that the rotation should be in
  4914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4915. * @param result The quaternion that the rotation should be copied to
  4916. */
  4917. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4918. /**
  4919. * Get the world position of a point that is in the local space of the bone
  4920. * @param position The local position
  4921. * @param mesh The mesh that this bone is attached to
  4922. * @returns The world position
  4923. */
  4924. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4925. /**
  4926. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4927. * @param position The local position
  4928. * @param mesh The mesh that this bone is attached to
  4929. * @param result The vector3 that the world position should be copied to
  4930. */
  4931. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4932. /**
  4933. * Get the local position of a point that is in world space
  4934. * @param position The world position
  4935. * @param mesh The mesh that this bone is attached to
  4936. * @returns The local position
  4937. */
  4938. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4939. /**
  4940. * Get the local position of a point that is in world space and copy it to the result param
  4941. * @param position The world position
  4942. * @param mesh The mesh that this bone is attached to
  4943. * @param result The vector3 that the local position should be copied to
  4944. */
  4945. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4946. }
  4947. }
  4948. declare module BABYLON {
  4949. /**
  4950. * Class used to apply inverse kinematics to bones
  4951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4952. */
  4953. class BoneIKController {
  4954. private static _tmpVecs;
  4955. private static _tmpQuat;
  4956. private static _tmpMats;
  4957. /**
  4958. * Gets or sets the target mesh
  4959. */
  4960. targetMesh: AbstractMesh;
  4961. /** Gets or sets the mesh used as pole */
  4962. poleTargetMesh: AbstractMesh;
  4963. /**
  4964. * Gets or sets the bone used as pole
  4965. */
  4966. poleTargetBone: Nullable<Bone>;
  4967. /**
  4968. * Gets or sets the target position
  4969. */
  4970. targetPosition: Vector3;
  4971. /**
  4972. * Gets or sets the pole target position
  4973. */
  4974. poleTargetPosition: Vector3;
  4975. /**
  4976. * Gets or sets the pole target local offset
  4977. */
  4978. poleTargetLocalOffset: Vector3;
  4979. /**
  4980. * Gets or sets the pole angle
  4981. */
  4982. poleAngle: number;
  4983. /**
  4984. * Gets or sets the mesh associated with the controller
  4985. */
  4986. mesh: AbstractMesh;
  4987. /**
  4988. * 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)
  4989. */
  4990. slerpAmount: number;
  4991. private _bone1Quat;
  4992. private _bone1Mat;
  4993. private _bone2Ang;
  4994. private _bone1;
  4995. private _bone2;
  4996. private _bone1Length;
  4997. private _bone2Length;
  4998. private _maxAngle;
  4999. private _maxReach;
  5000. private _rightHandedSystem;
  5001. private _bendAxis;
  5002. private _slerping;
  5003. private _adjustRoll;
  5004. /**
  5005. * Gets or sets maximum allowed angle
  5006. */
  5007. maxAngle: number;
  5008. /**
  5009. * Creates a new BoneIKController
  5010. * @param mesh defines the mesh to control
  5011. * @param bone defines the bone to control
  5012. * @param options defines options to set up the controller
  5013. */
  5014. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5015. targetMesh?: AbstractMesh;
  5016. poleTargetMesh?: AbstractMesh;
  5017. poleTargetBone?: Bone;
  5018. poleTargetLocalOffset?: Vector3;
  5019. poleAngle?: number;
  5020. bendAxis?: Vector3;
  5021. maxAngle?: number;
  5022. slerpAmount?: number;
  5023. });
  5024. private _setMaxAngle(ang);
  5025. /**
  5026. * Force the controller to update the bones
  5027. */
  5028. update(): void;
  5029. }
  5030. }
  5031. declare module BABYLON {
  5032. /**
  5033. * Class used to make a bone look toward a point in space
  5034. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5035. */
  5036. class BoneLookController {
  5037. private static _tmpVecs;
  5038. private static _tmpQuat;
  5039. private static _tmpMats;
  5040. /**
  5041. * The target Vector3 that the bone will look at
  5042. */
  5043. target: Vector3;
  5044. /**
  5045. * The mesh that the bone is attached to
  5046. */
  5047. mesh: AbstractMesh;
  5048. /**
  5049. * The bone that will be looking to the target
  5050. */
  5051. bone: Bone;
  5052. /**
  5053. * The up axis of the coordinate system that is used when the bone is rotated
  5054. */
  5055. upAxis: Vector3;
  5056. /**
  5057. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5058. */
  5059. upAxisSpace: Space;
  5060. /**
  5061. * Used to make an adjustment to the yaw of the bone
  5062. */
  5063. adjustYaw: number;
  5064. /**
  5065. * Used to make an adjustment to the pitch of the bone
  5066. */
  5067. adjustPitch: number;
  5068. /**
  5069. * Used to make an adjustment to the roll of the bone
  5070. */
  5071. adjustRoll: number;
  5072. /**
  5073. * 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)
  5074. */
  5075. slerpAmount: number;
  5076. private _minYaw;
  5077. private _maxYaw;
  5078. private _minPitch;
  5079. private _maxPitch;
  5080. private _minYawSin;
  5081. private _minYawCos;
  5082. private _maxYawSin;
  5083. private _maxYawCos;
  5084. private _midYawConstraint;
  5085. private _minPitchTan;
  5086. private _maxPitchTan;
  5087. private _boneQuat;
  5088. private _slerping;
  5089. private _transformYawPitch;
  5090. private _transformYawPitchInv;
  5091. private _firstFrameSkipped;
  5092. private _yawRange;
  5093. private _fowardAxis;
  5094. /**
  5095. * Gets or sets the minimum yaw angle that the bone can look to
  5096. */
  5097. minYaw: number;
  5098. /**
  5099. * Gets or sets the maximum yaw angle that the bone can look to
  5100. */
  5101. maxYaw: number;
  5102. /**
  5103. * Gets or sets the minimum pitch angle that the bone can look to
  5104. */
  5105. minPitch: number;
  5106. /**
  5107. * Gets or sets the maximum pitch angle that the bone can look to
  5108. */
  5109. maxPitch: number;
  5110. /**
  5111. * Create a BoneLookController
  5112. * @param mesh the mesh that the bone belongs to
  5113. * @param bone the bone that will be looking to the target
  5114. * @param target the target Vector3 to look at
  5115. * @param settings optional settings:
  5116. * * maxYaw: the maximum angle the bone will yaw to
  5117. * * minYaw: the minimum angle the bone will yaw to
  5118. * * maxPitch: the maximum angle the bone will pitch to
  5119. * * minPitch: the minimum angle the bone will yaw to
  5120. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5121. * * upAxis: the up axis of the coordinate system
  5122. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5123. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5124. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5125. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5126. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5127. * * adjustRoll: used to make an adjustment to the roll of the bone
  5128. **/
  5129. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5130. maxYaw?: number;
  5131. minYaw?: number;
  5132. maxPitch?: number;
  5133. minPitch?: number;
  5134. slerpAmount?: number;
  5135. upAxis?: Vector3;
  5136. upAxisSpace?: Space;
  5137. yawAxis?: Vector3;
  5138. pitchAxis?: Vector3;
  5139. adjustYaw?: number;
  5140. adjustPitch?: number;
  5141. adjustRoll?: number;
  5142. });
  5143. /**
  5144. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5145. */
  5146. update(): void;
  5147. private _getAngleDiff(ang1, ang2);
  5148. private _getAngleBetween(ang1, ang2);
  5149. private _isAngleBetween(ang, ang1, ang2);
  5150. }
  5151. }
  5152. declare module BABYLON {
  5153. /**
  5154. * Class used to handle skinning animations
  5155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5156. */
  5157. class Skeleton implements IAnimatable {
  5158. /** defines the skeleton name */
  5159. name: string;
  5160. /** defines the skeleton Id */
  5161. id: string;
  5162. /**
  5163. * Gets the list of child bones
  5164. */
  5165. bones: Bone[];
  5166. /**
  5167. * Gets an estimate of the dimension of the skeleton at rest
  5168. */
  5169. dimensionsAtRest: Vector3;
  5170. /**
  5171. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5172. */
  5173. needInitialSkinMatrix: boolean;
  5174. /**
  5175. * Gets the list of animations attached to this skeleton
  5176. */
  5177. animations: Array<Animation>;
  5178. private _scene;
  5179. private _isDirty;
  5180. private _transformMatrices;
  5181. private _meshesWithPoseMatrix;
  5182. private _animatables;
  5183. private _identity;
  5184. private _synchronizedWithMesh;
  5185. private _ranges;
  5186. private _lastAbsoluteTransformsUpdateId;
  5187. /**
  5188. * Specifies if the skeleton should be serialized
  5189. */
  5190. doNotSerialize: boolean;
  5191. private _animationPropertiesOverride;
  5192. /**
  5193. * Gets or sets the animation properties override
  5194. */
  5195. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5196. /**
  5197. * An observable triggered before computing the skeleton's matrices
  5198. */
  5199. onBeforeComputeObservable: Observable<Skeleton>;
  5200. /**
  5201. * Creates a new skeleton
  5202. * @param name defines the skeleton name
  5203. * @param id defines the skeleton Id
  5204. * @param scene defines the hosting scene
  5205. */
  5206. constructor(
  5207. /** defines the skeleton name */
  5208. name: string,
  5209. /** defines the skeleton Id */
  5210. id: string, scene: Scene);
  5211. /**
  5212. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5213. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5214. * @returns a Float32Array containing matrices data
  5215. */
  5216. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5217. /**
  5218. * Gets the current hosting scene
  5219. * @returns a scene object
  5220. */
  5221. getScene(): Scene;
  5222. /**
  5223. * Gets a string representing the current skeleton data
  5224. * @param fullDetails defines a boolean indicating if we want a verbose version
  5225. * @returns a string representing the current skeleton data
  5226. */
  5227. toString(fullDetails?: boolean): string;
  5228. /**
  5229. * Get bone's index searching by name
  5230. * @param name defines bone's name to search for
  5231. * @return the indice of the bone. Returns -1 if not found
  5232. */
  5233. getBoneIndexByName(name: string): number;
  5234. /**
  5235. * Creater a new animation range
  5236. * @param name defines the name of the range
  5237. * @param from defines the start key
  5238. * @param to defines the end key
  5239. */
  5240. createAnimationRange(name: string, from: number, to: number): void;
  5241. /**
  5242. * Delete a specific animation range
  5243. * @param name defines the name of the range
  5244. * @param deleteFrames defines if frames must be removed as well
  5245. */
  5246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5247. /**
  5248. * Gets a specific animation range
  5249. * @param name defines the name of the range to look for
  5250. * @returns the requested animation range or null if not found
  5251. */
  5252. getAnimationRange(name: string): Nullable<AnimationRange>;
  5253. /**
  5254. * Gets the list of all animation ranges defined on this skeleton
  5255. * @returns an array
  5256. */
  5257. getAnimationRanges(): Nullable<AnimationRange>[];
  5258. /**
  5259. * Copy animation range from a source skeleton.
  5260. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5261. * @param source defines the source skeleton
  5262. * @param name defines the name of the range to copy
  5263. * @param rescaleAsRequired defines if rescaling must be applied if required
  5264. * @returns true if operation was successful
  5265. */
  5266. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5267. /**
  5268. * Forces the skeleton to go to rest pose
  5269. */
  5270. returnToRest(): void;
  5271. private _getHighestAnimationFrame();
  5272. /**
  5273. * Begin a specific animation range
  5274. * @param name defines the name of the range to start
  5275. * @param loop defines if looping must be turned on (false by default)
  5276. * @param speedRatio defines the speed ratio to apply (1 by default)
  5277. * @param onAnimationEnd defines a callback which will be called when animation will end
  5278. * @returns a new animatable
  5279. */
  5280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5281. /** @hidden */
  5282. /** @hidden */
  5283. /** @hidden */
  5284. /** @hidden */
  5285. /**
  5286. * Build all resources required to render a skeleton
  5287. */
  5288. prepare(): void;
  5289. /**
  5290. * Gets the list of animatables currently running for this skeleton
  5291. * @returns an array of animatables
  5292. */
  5293. getAnimatables(): IAnimatable[];
  5294. /**
  5295. * Clone the current skeleton
  5296. * @param name defines the name of the new skeleton
  5297. * @param id defines the id of the enw skeleton
  5298. * @returns the new skeleton
  5299. */
  5300. clone(name: string, id: string): Skeleton;
  5301. /**
  5302. * Enable animation blending for this skeleton
  5303. * @param blendingSpeed defines the blending speed to apply
  5304. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5305. */
  5306. enableBlending(blendingSpeed?: number): void;
  5307. /**
  5308. * Releases all resources associated with the current skeleton
  5309. */
  5310. dispose(): void;
  5311. /**
  5312. * Serialize the skeleton in a JSON object
  5313. * @returns a JSON object
  5314. */
  5315. serialize(): any;
  5316. /**
  5317. * Creates a new skeleton from serialized data
  5318. * @param parsedSkeleton defines the serialized data
  5319. * @param scene defines the hosting scene
  5320. * @returns a new skeleton
  5321. */
  5322. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5323. /**
  5324. * Compute all node absolute transforms
  5325. * @param forceUpdate defines if computation must be done even if cache is up to date
  5326. */
  5327. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5328. /**
  5329. * Gets the root pose matrix
  5330. * @returns a matrix
  5331. */
  5332. getPoseMatrix(): Nullable<Matrix>;
  5333. /**
  5334. * Sorts bones per internal index
  5335. */
  5336. sortBones(): void;
  5337. private _sortBones(index, bones, visited);
  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 BoundingBox implements ICullable {
  5642. vectors: Vector3[];
  5643. center: Vector3;
  5644. centerWorld: Vector3;
  5645. extendSize: Vector3;
  5646. extendSizeWorld: Vector3;
  5647. directions: Vector3[];
  5648. vectorsWorld: Vector3[];
  5649. minimumWorld: Vector3;
  5650. maximumWorld: Vector3;
  5651. minimum: Vector3;
  5652. maximum: Vector3;
  5653. private _worldMatrix;
  5654. /**
  5655. * Creates a new bounding box
  5656. * @param min defines the minimum vector (in local space)
  5657. * @param max defines the maximum vector (in local space)
  5658. */
  5659. constructor(min: Vector3, max: Vector3);
  5660. /**
  5661. * Recreates the entire bounding box from scratch
  5662. * @param min defines the new minimum vector (in local space)
  5663. * @param max defines the new maximum vector (in local space)
  5664. */
  5665. reConstruct(min: Vector3, max: Vector3): void;
  5666. getWorldMatrix(): Matrix;
  5667. setWorldMatrix(matrix: Matrix): BoundingBox;
  5668. isInFrustum(frustumPlanes: Plane[]): boolean;
  5669. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5670. intersectsPoint(point: Vector3): boolean;
  5671. intersectsSphere(sphere: BoundingSphere): boolean;
  5672. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5673. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5674. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5675. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5676. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5677. }
  5678. }
  5679. declare module BABYLON {
  5680. interface ICullable {
  5681. isInFrustum(frustumPlanes: Plane[]): boolean;
  5682. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5683. }
  5684. class BoundingInfo implements ICullable {
  5685. minimum: Vector3;
  5686. maximum: Vector3;
  5687. boundingBox: BoundingBox;
  5688. boundingSphere: BoundingSphere;
  5689. private _isLocked;
  5690. constructor(minimum: Vector3, maximum: Vector3);
  5691. isLocked: boolean;
  5692. update(world: Matrix): void;
  5693. /**
  5694. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5695. * @param center New center of the bounding info
  5696. * @param extend New extend of the bounding info
  5697. */
  5698. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5699. isInFrustum(frustumPlanes: Plane[]): boolean;
  5700. /**
  5701. * Gets the world distance between the min and max points of the bounding box
  5702. */
  5703. readonly diagonalLength: number;
  5704. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5705. intersectsPoint(point: Vector3): boolean;
  5706. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5707. }
  5708. }
  5709. declare module BABYLON {
  5710. class BoundingSphere {
  5711. center: Vector3;
  5712. radius: number;
  5713. centerWorld: Vector3;
  5714. radiusWorld: number;
  5715. minimum: Vector3;
  5716. maximum: Vector3;
  5717. private _tempRadiusVector;
  5718. /**
  5719. * Creates a new bounding sphere
  5720. * @param min defines the minimum vector (in local space)
  5721. * @param max defines the maximum vector (in local space)
  5722. */
  5723. constructor(min: Vector3, max: Vector3);
  5724. /**
  5725. * Recreates the entire bounding sphere from scratch
  5726. * @param min defines the new minimum vector (in local space)
  5727. * @param max defines the new maximum vector (in local space)
  5728. */
  5729. reConstruct(min: Vector3, max: Vector3): void;
  5730. isInFrustum(frustumPlanes: Plane[]): boolean;
  5731. intersectsPoint(point: Vector3): boolean;
  5732. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5733. }
  5734. }
  5735. declare module BABYLON {
  5736. class Ray {
  5737. origin: Vector3;
  5738. direction: Vector3;
  5739. length: number;
  5740. private _edge1;
  5741. private _edge2;
  5742. private _pvec;
  5743. private _tvec;
  5744. private _qvec;
  5745. private _tmpRay;
  5746. constructor(origin: Vector3, direction: Vector3, length?: number);
  5747. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5748. intersectsBox(box: BoundingBox): boolean;
  5749. intersectsSphere(sphere: BoundingSphere): boolean;
  5750. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5751. intersectsPlane(plane: Plane): Nullable<number>;
  5752. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5753. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5754. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5755. private static smallnum;
  5756. private static rayl;
  5757. /**
  5758. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5759. * @param sega the first point of the segment to test the intersection against
  5760. * @param segb the second point of the segment to test the intersection against
  5761. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5762. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5763. */
  5764. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5765. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5766. static Zero(): Ray;
  5767. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5768. /**
  5769. * 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
  5770. * transformed to the given world matrix.
  5771. * @param origin The origin point
  5772. * @param end The end point
  5773. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5774. */
  5775. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5776. static Transform(ray: Ray, matrix: Matrix): Ray;
  5777. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5778. }
  5779. }
  5780. declare module BABYLON {
  5781. class ArcRotateCamera extends TargetCamera {
  5782. alpha: number;
  5783. beta: number;
  5784. radius: number;
  5785. protected _target: Vector3;
  5786. protected _targetHost: Nullable<AbstractMesh>;
  5787. target: Vector3;
  5788. inertialAlphaOffset: number;
  5789. inertialBetaOffset: number;
  5790. inertialRadiusOffset: number;
  5791. lowerAlphaLimit: Nullable<number>;
  5792. upperAlphaLimit: Nullable<number>;
  5793. lowerBetaLimit: number;
  5794. upperBetaLimit: number;
  5795. lowerRadiusLimit: Nullable<number>;
  5796. upperRadiusLimit: Nullable<number>;
  5797. inertialPanningX: number;
  5798. inertialPanningY: number;
  5799. pinchToPanMaxDistance: number;
  5800. panningDistanceLimit: Nullable<number>;
  5801. panningOriginTarget: Vector3;
  5802. panningInertia: number;
  5803. angularSensibilityX: number;
  5804. angularSensibilityY: number;
  5805. pinchPrecision: number;
  5806. pinchDeltaPercentage: number;
  5807. panningSensibility: number;
  5808. keysUp: number[];
  5809. keysDown: number[];
  5810. keysLeft: number[];
  5811. keysRight: number[];
  5812. wheelPrecision: number;
  5813. wheelDeltaPercentage: number;
  5814. zoomOnFactor: number;
  5815. targetScreenOffset: Vector2;
  5816. allowUpsideDown: boolean;
  5817. inputs: ArcRotateCameraInputsManager;
  5818. panningAxis: Vector3;
  5819. protected _localDirection: Vector3;
  5820. protected _transformedDirection: Vector3;
  5821. private _bouncingBehavior;
  5822. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5823. useBouncingBehavior: boolean;
  5824. private _framingBehavior;
  5825. readonly framingBehavior: Nullable<FramingBehavior>;
  5826. useFramingBehavior: boolean;
  5827. private _autoRotationBehavior;
  5828. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5829. useAutoRotationBehavior: boolean;
  5830. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5831. onCollide: (collidedMesh: AbstractMesh) => void;
  5832. checkCollisions: boolean;
  5833. collisionRadius: Vector3;
  5834. protected _collider: Collider;
  5835. protected _previousPosition: Vector3;
  5836. protected _collisionVelocity: Vector3;
  5837. protected _newPosition: Vector3;
  5838. protected _previousAlpha: number;
  5839. protected _previousBeta: number;
  5840. protected _previousRadius: number;
  5841. protected _collisionTriggered: boolean;
  5842. protected _targetBoundingCenter: Nullable<Vector3>;
  5843. private _computationVector;
  5844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5845. protected _getTargetPosition(): Vector3;
  5846. /**
  5847. * Store current camera state (fov, position, etc..)
  5848. */
  5849. private _storedAlpha;
  5850. private _storedBeta;
  5851. private _storedRadius;
  5852. private _storedTarget;
  5853. storeState(): Camera;
  5854. /**
  5855. * Restored camera state. You must call storeState() first
  5856. */
  5857. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5858. detachControl(element: HTMLElement): void;
  5859. protected _checkLimits(): void;
  5860. rebuildAnglesAndRadius(): void;
  5861. setPosition(position: Vector3): void;
  5862. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5863. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5864. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5865. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5866. min: Vector3;
  5867. max: Vector3;
  5868. distance: number;
  5869. }, doNotUpdateMaxZ?: boolean): void;
  5870. /**
  5871. * @override
  5872. * Override Camera.createRigCamera
  5873. */
  5874. createRigCamera(name: string, cameraIndex: number): Camera;
  5875. /**
  5876. * @override
  5877. * Override Camera._updateRigCameras
  5878. */
  5879. dispose(): void;
  5880. getClassName(): string;
  5881. }
  5882. }
  5883. declare module BABYLON {
  5884. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5885. constructor(camera: ArcRotateCamera);
  5886. addMouseWheel(): ArcRotateCameraInputsManager;
  5887. addPointers(): ArcRotateCameraInputsManager;
  5888. addKeyboard(): ArcRotateCameraInputsManager;
  5889. addGamepad(): ArcRotateCameraInputsManager;
  5890. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5891. }
  5892. }
  5893. declare module BABYLON {
  5894. class Camera extends Node {
  5895. inputs: CameraInputsManager<Camera>;
  5896. private static _PERSPECTIVE_CAMERA;
  5897. private static _ORTHOGRAPHIC_CAMERA;
  5898. private static _FOVMODE_VERTICAL_FIXED;
  5899. private static _FOVMODE_HORIZONTAL_FIXED;
  5900. private static _RIG_MODE_NONE;
  5901. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5902. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5903. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5904. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5905. private static _RIG_MODE_VR;
  5906. private static _RIG_MODE_WEBVR;
  5907. static readonly PERSPECTIVE_CAMERA: number;
  5908. static readonly ORTHOGRAPHIC_CAMERA: number;
  5909. /**
  5910. * This is the default FOV mode for perspective cameras.
  5911. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5912. *
  5913. */
  5914. static readonly FOVMODE_VERTICAL_FIXED: number;
  5915. /**
  5916. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5917. *
  5918. */
  5919. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5920. static readonly RIG_MODE_NONE: number;
  5921. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5922. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5923. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5924. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5925. static readonly RIG_MODE_VR: number;
  5926. static readonly RIG_MODE_WEBVR: number;
  5927. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5928. static UseAlternateWebVRRendering: boolean;
  5929. position: Vector3;
  5930. /**
  5931. * The vector the camera should consider as up.
  5932. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5933. */
  5934. upVector: Vector3;
  5935. orthoLeft: Nullable<number>;
  5936. orthoRight: Nullable<number>;
  5937. orthoBottom: Nullable<number>;
  5938. orthoTop: Nullable<number>;
  5939. /**
  5940. * FOV is set in Radians. (default is 0.8)
  5941. */
  5942. fov: number;
  5943. minZ: number;
  5944. maxZ: number;
  5945. inertia: number;
  5946. mode: number;
  5947. isIntermediate: boolean;
  5948. viewport: Viewport;
  5949. /**
  5950. * Restricts the camera to viewing objects with the same layerMask.
  5951. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5952. */
  5953. layerMask: number;
  5954. /**
  5955. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5956. */
  5957. fovMode: number;
  5958. cameraRigMode: number;
  5959. interaxialDistance: number;
  5960. isStereoscopicSideBySide: boolean;
  5961. protected _webvrViewMatrix: Matrix;
  5962. customRenderTargets: RenderTargetTexture[];
  5963. onViewMatrixChangedObservable: Observable<Camera>;
  5964. onProjectionMatrixChangedObservable: Observable<Camera>;
  5965. onAfterCheckInputsObservable: Observable<Camera>;
  5966. onRestoreStateObservable: Observable<Camera>;
  5967. private _computedViewMatrix;
  5968. private _doNotComputeProjectionMatrix;
  5969. private _worldMatrix;
  5970. private _transformMatrix;
  5971. protected _globalPosition: Vector3;
  5972. private _frustumPlanes;
  5973. private _refreshFrustumPlanes;
  5974. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5975. private _storedFov;
  5976. private _stateStored;
  5977. /**
  5978. * Store current camera state (fov, position, etc..)
  5979. */
  5980. storeState(): Camera;
  5981. /**
  5982. * Restores the camera state values if it has been stored. You must call storeState() first
  5983. */
  5984. protected _restoreStateValues(): boolean;
  5985. /**
  5986. * Restored camera state. You must call storeState() first
  5987. */
  5988. restoreState(): boolean;
  5989. getClassName(): string;
  5990. /**
  5991. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5992. */
  5993. toString(fullDetails?: boolean): string;
  5994. readonly globalPosition: Vector3;
  5995. getActiveMeshes(): SmartArray<AbstractMesh>;
  5996. isActiveMesh(mesh: Mesh): boolean;
  5997. /**
  5998. * Is this camera ready to be used/rendered
  5999. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6000. * @return true if the camera is ready
  6001. */
  6002. isReady(completeCheck?: boolean): boolean;
  6003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6004. detachControl(element: HTMLElement): void;
  6005. update(): void;
  6006. readonly rigCameras: Camera[];
  6007. readonly rigPostProcess: Nullable<PostProcess>;
  6008. /**
  6009. * Internal, gets the first post proces.
  6010. * @returns the first post process to be run on this camera.
  6011. */
  6012. private _cascadePostProcessesToRigCams();
  6013. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6014. detachPostProcess(postProcess: PostProcess): void;
  6015. getWorldMatrix(): Matrix;
  6016. getViewMatrix(force?: boolean): Matrix;
  6017. freezeProjectionMatrix(projection?: Matrix): void;
  6018. unfreezeProjectionMatrix(): void;
  6019. getProjectionMatrix(force?: boolean): Matrix;
  6020. getTranformationMatrix(): Matrix;
  6021. private updateFrustumPlanes();
  6022. isInFrustum(target: ICullable): boolean;
  6023. isCompletelyInFrustum(target: ICullable): boolean;
  6024. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6025. /**
  6026. * Releases resources associated with this node.
  6027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6029. */
  6030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6031. readonly leftCamera: Nullable<FreeCamera>;
  6032. readonly rightCamera: Nullable<FreeCamera>;
  6033. getLeftTarget(): Nullable<Vector3>;
  6034. getRightTarget(): Nullable<Vector3>;
  6035. setCameraRigMode(mode: number, rigParams: any): void;
  6036. private _getVRProjectionMatrix();
  6037. protected _updateCameraRotationMatrix(): void;
  6038. protected _updateWebVRCameraRotationMatrix(): void;
  6039. /**
  6040. * This function MUST be overwritten by the different WebVR cameras available.
  6041. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6042. */
  6043. protected _getWebVRProjectionMatrix(): Matrix;
  6044. /**
  6045. * This function MUST be overwritten by the different WebVR cameras available.
  6046. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6047. */
  6048. protected _getWebVRViewMatrix(): Matrix;
  6049. setCameraRigParameter(name: string, value: any): void;
  6050. /**
  6051. * needs to be overridden by children so sub has required properties to be copied
  6052. */
  6053. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6054. /**
  6055. * May need to be overridden by children
  6056. */
  6057. serialize(): any;
  6058. clone(name: string): Camera;
  6059. getDirection(localAxis: Vector3): Vector3;
  6060. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6061. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6062. computeWorldMatrix(): Matrix;
  6063. static Parse(parsedCamera: any, scene: Scene): Camera;
  6064. }
  6065. }
  6066. declare module BABYLON {
  6067. var CameraInputTypes: {};
  6068. interface ICameraInput<TCamera extends Camera> {
  6069. camera: Nullable<TCamera>;
  6070. getClassName(): string;
  6071. getSimpleName(): string;
  6072. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6073. detachControl: (element: Nullable<HTMLElement>) => void;
  6074. checkInputs?: () => void;
  6075. }
  6076. interface CameraInputsMap<TCamera extends Camera> {
  6077. [name: string]: ICameraInput<TCamera>;
  6078. [idx: number]: ICameraInput<TCamera>;
  6079. }
  6080. class CameraInputsManager<TCamera extends Camera> {
  6081. attached: CameraInputsMap<TCamera>;
  6082. attachedElement: Nullable<HTMLElement>;
  6083. noPreventDefault: boolean;
  6084. camera: TCamera;
  6085. checkInputs: () => void;
  6086. constructor(camera: TCamera);
  6087. /**
  6088. * Add an input method to a camera.
  6089. * builtin inputs example: camera.inputs.addGamepad();
  6090. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6091. * @param input camera input method
  6092. */
  6093. add(input: ICameraInput<TCamera>): void;
  6094. /**
  6095. * Remove a specific input method from a camera
  6096. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6097. * @param inputToRemove camera input method
  6098. */
  6099. remove(inputToRemove: ICameraInput<TCamera>): void;
  6100. removeByType(inputType: string): void;
  6101. private _addCheckInputs(fn);
  6102. attachInput(input: ICameraInput<TCamera>): void;
  6103. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6104. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6105. rebuildInputCheck(): void;
  6106. /**
  6107. * Remove all attached input methods from a camera
  6108. */
  6109. clear(): void;
  6110. serialize(serializedCamera: any): void;
  6111. parse(parsedCamera: any): void;
  6112. }
  6113. }
  6114. declare module BABYLON {
  6115. /**
  6116. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6117. * being tilted forward or back and left or right.
  6118. */
  6119. class DeviceOrientationCamera extends FreeCamera {
  6120. private _initialQuaternion;
  6121. private _quaternionCache;
  6122. /**
  6123. * Creates a new device orientation camera
  6124. * @param name The name of the camera
  6125. * @param position The start position camera
  6126. * @param scene The scene the camera belongs to
  6127. */
  6128. constructor(name: string, position: Vector3, scene: Scene);
  6129. /**
  6130. * Gets the current instance class name ("DeviceOrientationCamera").
  6131. * This helps avoiding instanceof at run time.
  6132. * @returns the class name
  6133. */
  6134. getClassName(): string;
  6135. /**
  6136. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6137. */
  6138. /**
  6139. * Reset the camera to its default orientation on the specified axis only.
  6140. * @param axis The axis to reset
  6141. */
  6142. resetToCurrentRotation(axis?: Axis): void;
  6143. }
  6144. }
  6145. declare module BABYLON {
  6146. class FollowCamera extends TargetCamera {
  6147. radius: number;
  6148. rotationOffset: number;
  6149. heightOffset: number;
  6150. cameraAcceleration: number;
  6151. maxCameraSpeed: number;
  6152. lockedTarget: Nullable<AbstractMesh>;
  6153. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6154. private getRadians(degrees);
  6155. private follow(cameraTarget);
  6156. getClassName(): string;
  6157. }
  6158. class ArcFollowCamera extends TargetCamera {
  6159. alpha: number;
  6160. beta: number;
  6161. radius: number;
  6162. target: Nullable<AbstractMesh>;
  6163. private _cartesianCoordinates;
  6164. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6165. private follow();
  6166. getClassName(): string;
  6167. }
  6168. }
  6169. declare module BABYLON {
  6170. class FreeCamera extends TargetCamera {
  6171. ellipsoid: Vector3;
  6172. ellipsoidOffset: Vector3;
  6173. checkCollisions: boolean;
  6174. applyGravity: boolean;
  6175. inputs: FreeCameraInputsManager;
  6176. /**
  6177. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6178. * Higher values reduce sensitivity.
  6179. */
  6180. /**
  6181. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6182. * Higher values reduce sensitivity.
  6183. */
  6184. angularSensibility: number;
  6185. keysUp: number[];
  6186. keysDown: number[];
  6187. keysLeft: number[];
  6188. keysRight: number[];
  6189. onCollide: (collidedMesh: AbstractMesh) => void;
  6190. private _collider;
  6191. private _needMoveForGravity;
  6192. private _oldPosition;
  6193. private _diffPosition;
  6194. private _newPosition;
  6195. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6197. detachControl(element: HTMLElement): void;
  6198. private _collisionMask;
  6199. collisionMask: number;
  6200. private _onCollisionPositionChange;
  6201. dispose(): void;
  6202. getClassName(): string;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6207. constructor(camera: FreeCamera);
  6208. addKeyboard(): FreeCameraInputsManager;
  6209. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6210. addGamepad(): FreeCameraInputsManager;
  6211. addDeviceOrientation(): FreeCameraInputsManager;
  6212. addTouch(): FreeCameraInputsManager;
  6213. addVirtualJoystick(): FreeCameraInputsManager;
  6214. }
  6215. }
  6216. declare module BABYLON {
  6217. class GamepadCamera extends UniversalCamera {
  6218. gamepadAngularSensibility: number;
  6219. gamepadMoveSensibility: number;
  6220. constructor(name: string, position: Vector3, scene: Scene);
  6221. getClassName(): string;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6227. */
  6228. class AnaglyphFreeCamera extends FreeCamera {
  6229. /**
  6230. * Creates a new AnaglyphFreeCamera
  6231. * @param name defines camera name
  6232. * @param position defines initial position
  6233. * @param interaxialDistance defines distance between each color axis
  6234. * @param scene defines the hosting scene
  6235. */
  6236. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6237. /**
  6238. * Gets camera class name
  6239. * @returns AnaglyphFreeCamera
  6240. */
  6241. getClassName(): string;
  6242. }
  6243. /**
  6244. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6245. */
  6246. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6247. /**
  6248. * Creates a new AnaglyphArcRotateCamera
  6249. * @param name defines camera name
  6250. * @param alpha defines alpha angle (in radians)
  6251. * @param beta defines beta angle (in radians)
  6252. * @param radius defines radius
  6253. * @param target defines camera target
  6254. * @param interaxialDistance defines distance between each color axis
  6255. * @param scene defines the hosting scene
  6256. */
  6257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6258. /**
  6259. * Gets camera class name
  6260. * @returns AnaglyphArcRotateCamera
  6261. */
  6262. getClassName(): string;
  6263. }
  6264. /**
  6265. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6266. */
  6267. class AnaglyphGamepadCamera extends GamepadCamera {
  6268. /**
  6269. * Creates a new AnaglyphGamepadCamera
  6270. * @param name defines camera name
  6271. * @param position defines initial position
  6272. * @param interaxialDistance defines distance between each color axis
  6273. * @param scene defines the hosting scene
  6274. */
  6275. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6276. /**
  6277. * Gets camera class name
  6278. * @returns AnaglyphGamepadCamera
  6279. */
  6280. getClassName(): string;
  6281. }
  6282. /**
  6283. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6284. */
  6285. class AnaglyphUniversalCamera extends UniversalCamera {
  6286. /**
  6287. * Creates a new AnaglyphUniversalCamera
  6288. * @param name defines camera name
  6289. * @param position defines initial position
  6290. * @param interaxialDistance defines distance between each color axis
  6291. * @param scene defines the hosting scene
  6292. */
  6293. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6294. /**
  6295. * Gets camera class name
  6296. * @returns AnaglyphUniversalCamera
  6297. */
  6298. getClassName(): string;
  6299. }
  6300. /**
  6301. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6302. */
  6303. class StereoscopicFreeCamera extends FreeCamera {
  6304. /**
  6305. * Creates a new StereoscopicFreeCamera
  6306. * @param name defines camera name
  6307. * @param position defines initial position
  6308. * @param interaxialDistance defines distance between each color axis
  6309. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6310. * @param scene defines the hosting scene
  6311. */
  6312. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6313. /**
  6314. * Gets camera class name
  6315. * @returns StereoscopicFreeCamera
  6316. */
  6317. getClassName(): string;
  6318. }
  6319. /**
  6320. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6321. */
  6322. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6323. /**
  6324. * Creates a new StereoscopicArcRotateCamera
  6325. * @param name defines camera name
  6326. * @param alpha defines alpha angle (in radians)
  6327. * @param beta defines beta angle (in radians)
  6328. * @param radius defines radius
  6329. * @param target defines camera target
  6330. * @param interaxialDistance defines distance between each color axis
  6331. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6332. * @param scene defines the hosting scene
  6333. */
  6334. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6335. /**
  6336. * Gets camera class name
  6337. * @returns StereoscopicArcRotateCamera
  6338. */
  6339. getClassName(): string;
  6340. }
  6341. /**
  6342. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6343. */
  6344. class StereoscopicGamepadCamera extends GamepadCamera {
  6345. /**
  6346. * Creates a new StereoscopicGamepadCamera
  6347. * @param name defines camera name
  6348. * @param position defines initial position
  6349. * @param interaxialDistance defines distance between each color axis
  6350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6351. * @param scene defines the hosting scene
  6352. */
  6353. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6354. /**
  6355. * Gets camera class name
  6356. * @returns StereoscopicGamepadCamera
  6357. */
  6358. getClassName(): string;
  6359. }
  6360. /**
  6361. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6362. */
  6363. class StereoscopicUniversalCamera extends UniversalCamera {
  6364. /**
  6365. * Creates a new StereoscopicUniversalCamera
  6366. * @param name defines camera name
  6367. * @param position defines initial position
  6368. * @param interaxialDistance defines distance between each color axis
  6369. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6370. * @param scene defines the hosting scene
  6371. */
  6372. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6373. /**
  6374. * Gets camera class name
  6375. * @returns StereoscopicUniversalCamera
  6376. */
  6377. getClassName(): string;
  6378. }
  6379. }
  6380. declare module BABYLON {
  6381. class TargetCamera extends Camera {
  6382. cameraDirection: Vector3;
  6383. cameraRotation: Vector2;
  6384. rotation: Vector3;
  6385. rotationQuaternion: Quaternion;
  6386. speed: number;
  6387. noRotationConstraint: boolean;
  6388. lockedTarget: any;
  6389. private _rigCamTransformMatrix;
  6390. private _currentUpVector;
  6391. protected _globalCurrentTarget: Vector3;
  6392. protected _globalCurrentUpVector: Vector3;
  6393. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6394. getFrontPosition(distance: number): Vector3;
  6395. /**
  6396. * Store current camera state (fov, position, etc..)
  6397. */
  6398. private _storedPosition;
  6399. private _storedRotation;
  6400. private _storedRotationQuaternion;
  6401. storeState(): Camera;
  6402. /**
  6403. * Restored camera state. You must call storeState() first
  6404. */
  6405. setTarget(target: Vector3): void;
  6406. /**
  6407. * Return the current target position of the camera. This value is expressed in local space.
  6408. */
  6409. getTarget(): Vector3;
  6410. protected _updateCameraRotationMatrix(): void;
  6411. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6412. /**
  6413. * @override
  6414. * Override Camera.createRigCamera
  6415. */
  6416. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6417. /**
  6418. * @override
  6419. * Override Camera._updateRigCameras
  6420. */
  6421. private _getRigCamPosition(halfSpace, result);
  6422. getClassName(): string;
  6423. }
  6424. }
  6425. declare module BABYLON {
  6426. class TouchCamera extends FreeCamera {
  6427. touchAngularSensibility: number;
  6428. touchMoveSensibility: number;
  6429. constructor(name: string, position: Vector3, scene: Scene);
  6430. getClassName(): string;
  6431. }
  6432. }
  6433. declare module BABYLON {
  6434. class UniversalCamera extends TouchCamera {
  6435. gamepadAngularSensibility: number;
  6436. gamepadMoveSensibility: number;
  6437. constructor(name: string, position: Vector3, scene: Scene);
  6438. getClassName(): string;
  6439. }
  6440. }
  6441. declare module BABYLON {
  6442. class VirtualJoysticksCamera extends FreeCamera {
  6443. constructor(name: string, position: Vector3, scene: Scene);
  6444. getClassName(): string;
  6445. }
  6446. }
  6447. interface VRDisplay extends EventTarget {
  6448. /**
  6449. * Dictionary of capabilities describing the VRDisplay.
  6450. */
  6451. readonly capabilities: VRDisplayCapabilities;
  6452. /**
  6453. * z-depth defining the far plane of the eye view frustum
  6454. * enables mapping of values in the render target depth
  6455. * attachment to scene coordinates. Initially set to 10000.0.
  6456. */
  6457. depthFar: number;
  6458. /**
  6459. * z-depth defining the near plane of the eye view frustum
  6460. * enables mapping of values in the render target depth
  6461. * attachment to scene coordinates. Initially set to 0.01.
  6462. */
  6463. depthNear: number;
  6464. /**
  6465. * An identifier for this distinct VRDisplay. Used as an
  6466. * association point in the Gamepad API.
  6467. */
  6468. readonly displayId: number;
  6469. /**
  6470. * A display name, a user-readable name identifying it.
  6471. */
  6472. readonly displayName: string;
  6473. readonly isConnected: boolean;
  6474. readonly isPresenting: boolean;
  6475. /**
  6476. * If this VRDisplay supports room-scale experiences, the optional
  6477. * stage attribute contains details on the room-scale parameters.
  6478. */
  6479. readonly stageParameters: VRStageParameters | null;
  6480. /**
  6481. * Passing the value returned by `requestAnimationFrame` to
  6482. * `cancelAnimationFrame` will unregister the callback.
  6483. */
  6484. cancelAnimationFrame(handle: number): void;
  6485. /**
  6486. * Stops presenting to the VRDisplay.
  6487. */
  6488. exitPresent(): Promise<void>;
  6489. getEyeParameters(whichEye: string): VREyeParameters;
  6490. /**
  6491. * Populates the passed VRFrameData with the information required to render
  6492. * the current frame.
  6493. */
  6494. getFrameData(frameData: VRFrameData): boolean;
  6495. /**
  6496. * Get the layers currently being presented.
  6497. */
  6498. getLayers(): VRLayer[];
  6499. /**
  6500. * Return a VRPose containing the future predicted pose of the VRDisplay
  6501. * when the current frame will be presented. The value returned will not
  6502. * change until JavaScript has returned control to the browser.
  6503. *
  6504. * The VRPose will contain the position, orientation, velocity,
  6505. * and acceleration of each of these properties.
  6506. */
  6507. getPose(): VRPose;
  6508. /**
  6509. * Return the current instantaneous pose of the VRDisplay, with no
  6510. * prediction applied.
  6511. */
  6512. getImmediatePose(): VRPose;
  6513. /**
  6514. * The callback passed to `requestAnimationFrame` will be called
  6515. * any time a new frame should be rendered. When the VRDisplay is
  6516. * presenting the callback will be called at the native refresh
  6517. * rate of the HMD. When not presenting this function acts
  6518. * identically to how window.requestAnimationFrame acts. Content should
  6519. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6520. * asynchronously from other displays and at differing refresh rates.
  6521. */
  6522. requestAnimationFrame(callback: FrameRequestCallback): number;
  6523. /**
  6524. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6525. * Repeat calls while already presenting will update the VRLayers being displayed.
  6526. */
  6527. requestPresent(layers: VRLayer[]): Promise<void>;
  6528. /**
  6529. * Reset the pose for this display, treating its current position and
  6530. * orientation as the "origin/zero" values. VRPose.position,
  6531. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6532. * updated when calling resetPose(). This should be called in only
  6533. * sitting-space experiences.
  6534. */
  6535. resetPose(): void;
  6536. /**
  6537. * The VRLayer provided to the VRDisplay will be captured and presented
  6538. * in the HMD. Calling this function has the same effect on the source
  6539. * canvas as any other operation that uses its source image, and canvases
  6540. * created without preserveDrawingBuffer set to true will be cleared.
  6541. */
  6542. submitFrame(pose?: VRPose): void;
  6543. }
  6544. declare var VRDisplay: {
  6545. prototype: VRDisplay;
  6546. new (): VRDisplay;
  6547. };
  6548. interface VRLayer {
  6549. leftBounds?: number[] | null;
  6550. rightBounds?: number[] | null;
  6551. source?: HTMLCanvasElement | null;
  6552. }
  6553. interface VRDisplayCapabilities {
  6554. readonly canPresent: boolean;
  6555. readonly hasExternalDisplay: boolean;
  6556. readonly hasOrientation: boolean;
  6557. readonly hasPosition: boolean;
  6558. readonly maxLayers: number;
  6559. }
  6560. interface VREyeParameters {
  6561. /** @deprecated */
  6562. readonly fieldOfView: VRFieldOfView;
  6563. readonly offset: Float32Array;
  6564. readonly renderHeight: number;
  6565. readonly renderWidth: number;
  6566. }
  6567. interface VRFieldOfView {
  6568. readonly downDegrees: number;
  6569. readonly leftDegrees: number;
  6570. readonly rightDegrees: number;
  6571. readonly upDegrees: number;
  6572. }
  6573. interface VRFrameData {
  6574. readonly leftProjectionMatrix: Float32Array;
  6575. readonly leftViewMatrix: Float32Array;
  6576. readonly pose: VRPose;
  6577. readonly rightProjectionMatrix: Float32Array;
  6578. readonly rightViewMatrix: Float32Array;
  6579. readonly timestamp: number;
  6580. }
  6581. interface VRPose {
  6582. readonly angularAcceleration: Float32Array | null;
  6583. readonly angularVelocity: Float32Array | null;
  6584. readonly linearAcceleration: Float32Array | null;
  6585. readonly linearVelocity: Float32Array | null;
  6586. readonly orientation: Float32Array | null;
  6587. readonly position: Float32Array | null;
  6588. readonly timestamp: number;
  6589. }
  6590. interface VRStageParameters {
  6591. sittingToStandingTransform?: Float32Array;
  6592. sizeX?: number;
  6593. sizeY?: number;
  6594. }
  6595. interface Navigator {
  6596. getVRDisplays(): Promise<VRDisplay[]>;
  6597. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6598. }
  6599. interface Window {
  6600. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6601. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6602. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6603. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6604. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6605. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6606. }
  6607. interface Gamepad {
  6608. readonly displayId: number;
  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. * Creates a new engine
  7255. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7256. * @param antialias defines enable antialiasing (default: false)
  7257. * @param options defines further options to be sent to the getContext() function
  7258. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7259. */
  7260. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7261. private _rebuildInternalTextures();
  7262. private _rebuildEffects();
  7263. private _rebuildBuffers();
  7264. private _initGLContext();
  7265. /**
  7266. * Gets version of the current webGL context
  7267. */
  7268. readonly webGLVersion: number;
  7269. /**
  7270. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7271. */
  7272. readonly isStencilEnable: boolean;
  7273. private _prepareWorkingCanvas();
  7274. /**
  7275. * Reset the texture cache to empty state
  7276. */
  7277. resetTextureCache(): void;
  7278. /**
  7279. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7280. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7281. * @returns true if engine is in deterministic lock step mode
  7282. */
  7283. isDeterministicLockStep(): boolean;
  7284. /**
  7285. * Gets the max steps when engine is running in deterministic lock step
  7286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7287. * @returns the max steps
  7288. */
  7289. getLockstepMaxSteps(): number;
  7290. /**
  7291. * Gets an object containing information about the current webGL context
  7292. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7293. */
  7294. getGlInfo(): {
  7295. vendor: string;
  7296. renderer: string;
  7297. version: string;
  7298. };
  7299. /**
  7300. * Gets current aspect ratio
  7301. * @param camera defines the camera to use to get the aspect ratio
  7302. * @param useScreen defines if screen size must be used (or the current render target if any)
  7303. * @returns a number defining the aspect ratio
  7304. */
  7305. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7306. /**
  7307. * Gets current screen aspect ratio
  7308. * @returns a number defining the aspect ratio
  7309. */
  7310. getScreenAspectRatio(): number;
  7311. /**
  7312. * Gets the current render width
  7313. * @param useScreen defines if screen size must be used (or the current render target if any)
  7314. * @returns a number defining the current render width
  7315. */
  7316. getRenderWidth(useScreen?: boolean): number;
  7317. /**
  7318. * Gets the current render height
  7319. * @param useScreen defines if screen size must be used (or the current render target if any)
  7320. * @returns a number defining the current render height
  7321. */
  7322. getRenderHeight(useScreen?: boolean): number;
  7323. /**
  7324. * Gets the HTML canvas attached with the current webGL context
  7325. * @returns a HTML canvas
  7326. */
  7327. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7328. /**
  7329. * Gets the client rect of the HTML canvas attached with the current webGL context
  7330. * @returns a client rectanglee
  7331. */
  7332. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7333. /**
  7334. * Defines the hardware scaling level.
  7335. * By default the hardware scaling level is computed from the window device ratio.
  7336. * 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.
  7337. * @param level defines the level to use
  7338. */
  7339. setHardwareScalingLevel(level: number): void;
  7340. /**
  7341. * Gets the current hardware scaling level.
  7342. * By default the hardware scaling level is computed from the window device ratio.
  7343. * 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.
  7344. * @returns a number indicating the current hardware scaling level
  7345. */
  7346. getHardwareScalingLevel(): number;
  7347. /**
  7348. * Gets the list of loaded textures
  7349. * @returns an array containing all loaded textures
  7350. */
  7351. getLoadedTexturesCache(): InternalTexture[];
  7352. /**
  7353. * Gets the object containing all engine capabilities
  7354. * @returns the EngineCapabilities object
  7355. */
  7356. getCaps(): EngineCapabilities;
  7357. /** @hidden */
  7358. readonly drawCalls: number;
  7359. /** @hidden */
  7360. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7361. /**
  7362. * Gets the current depth function
  7363. * @returns a number defining the depth function
  7364. */
  7365. getDepthFunction(): Nullable<number>;
  7366. /**
  7367. * Sets the current depth function
  7368. * @param depthFunc defines the function to use
  7369. */
  7370. setDepthFunction(depthFunc: number): void;
  7371. /**
  7372. * Sets the current depth function to GREATER
  7373. */
  7374. setDepthFunctionToGreater(): void;
  7375. /**
  7376. * Sets the current depth function to GEQUAL
  7377. */
  7378. setDepthFunctionToGreaterOrEqual(): void;
  7379. /**
  7380. * Sets the current depth function to LESS
  7381. */
  7382. setDepthFunctionToLess(): void;
  7383. /**
  7384. * Sets the current depth function to LEQUAL
  7385. */
  7386. setDepthFunctionToLessOrEqual(): void;
  7387. /**
  7388. * Gets a boolean indicating if stencil buffer is enabled
  7389. * @returns the current stencil buffer state
  7390. */
  7391. getStencilBuffer(): boolean;
  7392. /**
  7393. * Enable or disable the stencil buffer
  7394. * @param enable defines if the stencil buffer must be enabled or disabled
  7395. */
  7396. setStencilBuffer(enable: boolean): void;
  7397. /**
  7398. * Gets the current stencil mask
  7399. * @returns a number defining the new stencil mask to use
  7400. */
  7401. getStencilMask(): number;
  7402. /**
  7403. * Sets the current stencil mask
  7404. * @param mask defines the new stencil mask to use
  7405. */
  7406. setStencilMask(mask: number): void;
  7407. /**
  7408. * Gets the current stencil function
  7409. * @returns a number defining the stencil function to use
  7410. */
  7411. getStencilFunction(): number;
  7412. /**
  7413. * Gets the current stencil reference value
  7414. * @returns a number defining the stencil reference value to use
  7415. */
  7416. getStencilFunctionReference(): number;
  7417. /**
  7418. * Gets the current stencil mask
  7419. * @returns a number defining the stencil mask to use
  7420. */
  7421. getStencilFunctionMask(): number;
  7422. /**
  7423. * Sets the current stencil function
  7424. * @param stencilFunc defines the new stencil function to use
  7425. */
  7426. setStencilFunction(stencilFunc: number): void;
  7427. /**
  7428. * Sets the current stencil reference
  7429. * @param reference defines the new stencil reference to use
  7430. */
  7431. setStencilFunctionReference(reference: number): void;
  7432. /**
  7433. * Sets the current stencil mask
  7434. * @param mask defines the new stencil mask to use
  7435. */
  7436. setStencilFunctionMask(mask: number): void;
  7437. /**
  7438. * Gets the current stencil operation when stencil fails
  7439. * @returns a number defining stencil operation to use when stencil fails
  7440. */
  7441. getStencilOperationFail(): number;
  7442. /**
  7443. * Gets the current stencil operation when depth fails
  7444. * @returns a number defining stencil operation to use when depth fails
  7445. */
  7446. getStencilOperationDepthFail(): number;
  7447. /**
  7448. * Gets the current stencil operation when stencil passes
  7449. * @returns a number defining stencil operation to use when stencil passes
  7450. */
  7451. getStencilOperationPass(): number;
  7452. /**
  7453. * Sets the stencil operation to use when stencil fails
  7454. * @param operation defines the stencil operation to use when stencil fails
  7455. */
  7456. setStencilOperationFail(operation: number): void;
  7457. /**
  7458. * Sets the stencil operation to use when depth fails
  7459. * @param operation defines the stencil operation to use when depth fails
  7460. */
  7461. setStencilOperationDepthFail(operation: number): void;
  7462. /**
  7463. * Sets the stencil operation to use when stencil passes
  7464. * @param operation defines the stencil operation to use when stencil passes
  7465. */
  7466. setStencilOperationPass(operation: number): void;
  7467. /**
  7468. * Sets a boolean indicating if the dithering state is enabled or disabled
  7469. * @param value defines the dithering state
  7470. */
  7471. setDitheringState(value: boolean): void;
  7472. /**
  7473. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7474. * @param value defines the rasterizer state
  7475. */
  7476. setRasterizerState(value: boolean): void;
  7477. /**
  7478. * stop executing a render loop function and remove it from the execution array
  7479. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7480. */
  7481. stopRenderLoop(renderFunction?: () => void): void;
  7482. /** @hidden */
  7483. /**
  7484. * Register and execute a render loop. The engine can have more than one render function
  7485. * @param renderFunction defines the function to continuously execute
  7486. */
  7487. runRenderLoop(renderFunction: () => void): void;
  7488. /**
  7489. * Toggle full screen mode
  7490. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7491. * @param options defines an option object to be sent to the requestFullscreen function
  7492. */
  7493. switchFullscreen(requestPointerLock: boolean): void;
  7494. /**
  7495. * Clear the current render buffer or the current render target (if any is set up)
  7496. * @param color defines the color to use
  7497. * @param backBuffer defines if the back buffer must be cleared
  7498. * @param depth defines if the depth buffer must be cleared
  7499. * @param stencil defines if the stencil buffer must be cleared
  7500. */
  7501. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7502. /**
  7503. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7505. * @param y defines the y-coordinate of the corner of the clear rectangle
  7506. * @param width defines the width of the clear rectangle
  7507. * @param height defines the height of the clear rectangle
  7508. * @param clearColor defines the clear color
  7509. */
  7510. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7511. /**
  7512. * Set the WebGL's viewport
  7513. * @param viewport defines the viewport element to be used
  7514. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7515. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7516. */
  7517. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7518. /**
  7519. * Directly set the WebGL Viewport
  7520. * @param x defines the x coordinate of the viewport (in screen space)
  7521. * @param y defines the y coordinate of the viewport (in screen space)
  7522. * @param width defines the width of the viewport (in screen space)
  7523. * @param height defines the height of the viewport (in screen space)
  7524. * @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
  7525. */
  7526. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7527. /**
  7528. * Begin a new frame
  7529. */
  7530. beginFrame(): void;
  7531. /**
  7532. * Enf the current frame
  7533. */
  7534. endFrame(): void;
  7535. /**
  7536. * Resize the view according to the canvas' size
  7537. */
  7538. resize(): void;
  7539. /**
  7540. * Force a specific size of the canvas
  7541. * @param width defines the new canvas' width
  7542. * @param height defines the new canvas' height
  7543. */
  7544. setSize(width: number, height: number): void;
  7545. /**
  7546. * Gets a boolean indicating if a webVR device was detected
  7547. * @returns true if a webVR device was detected
  7548. */
  7549. isVRDevicePresent(): boolean;
  7550. /**
  7551. * Gets the current webVR device
  7552. * @returns the current webVR device (or null)
  7553. */
  7554. getVRDevice(): any;
  7555. /**
  7556. * Initializes a webVR display and starts listening to display change events
  7557. * The onVRDisplayChangedObservable will be notified upon these changes
  7558. * @returns The onVRDisplayChangedObservable
  7559. */
  7560. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7561. /**
  7562. * Initializes a webVR display and starts listening to display change events
  7563. * The onVRDisplayChangedObservable will be notified upon these changes
  7564. * @returns A promise containing a VRDisplay and if vr is supported
  7565. */
  7566. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7567. /**
  7568. * Call this function to switch to webVR mode
  7569. * Will do nothing if webVR is not supported or if there is no webVR device
  7570. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7571. */
  7572. enableVR(): void;
  7573. /**
  7574. * Call this function to leave 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. disableVR(): void;
  7579. private _onVRFullScreenTriggered;
  7580. private _getVRDisplaysAsync();
  7581. /**
  7582. * Binds the frame buffer to the specified texture.
  7583. * @param texture The texture to render to or null for the default canvas
  7584. * @param faceIndex The face of the texture to render to in case of cube texture
  7585. * @param requiredWidth The width of the target to render to
  7586. * @param requiredHeight The height of the target to render to
  7587. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7588. * @param depthStencilTexture The depth stencil texture to use to render
  7589. */
  7590. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7591. private bindUnboundFramebuffer(framebuffer);
  7592. /**
  7593. * Unbind the current render target texture from the webGL context
  7594. * @param texture defines the render target texture to unbind
  7595. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7596. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7597. */
  7598. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7599. /**
  7600. * Unbind a list of render target textures from the webGL context
  7601. * This is used only when drawBuffer extension or webGL2 are active
  7602. * @param textures defines the render target textures to unbind
  7603. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7604. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7605. */
  7606. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7607. /**
  7608. * Force the mipmap generation for the given render target texture
  7609. * @param texture defines the render target texture to use
  7610. */
  7611. generateMipMapsForCubemap(texture: InternalTexture): void;
  7612. /**
  7613. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7614. */
  7615. flushFramebuffer(): void;
  7616. /**
  7617. * Unbind the current render target and bind the default framebuffer
  7618. */
  7619. restoreDefaultFramebuffer(): void;
  7620. /**
  7621. * Create an uniform buffer
  7622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7623. * @param elements defines the content of the uniform buffer
  7624. * @returns the webGL uniform buffer
  7625. */
  7626. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7627. /**
  7628. * Create a dynamic 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. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7634. /**
  7635. * Update an existing uniform buffer
  7636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7637. * @param uniformBuffer defines the target uniform buffer
  7638. * @param elements defines the content to update
  7639. * @param offset defines the offset in the uniform buffer where update should start
  7640. * @param count defines the size of the data to update
  7641. */
  7642. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7643. private _resetVertexBufferBinding();
  7644. /**
  7645. * Creates a vertex buffer
  7646. * @param data the data for the vertex buffer
  7647. * @returns the new WebGL static buffer
  7648. */
  7649. createVertexBuffer(data: DataArray): WebGLBuffer;
  7650. /**
  7651. * Creates a dynamic vertex buffer
  7652. * @param data the data for the dynamic vertex buffer
  7653. * @returns the new WebGL dynamic buffer
  7654. */
  7655. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7656. /**
  7657. * Update a dynamic index buffer
  7658. * @param indexBuffer defines the target index buffer
  7659. * @param indices defines the data to update
  7660. * @param offset defines the offset in the target index buffer where update should start
  7661. */
  7662. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7663. /**
  7664. * Updates a dynamic vertex buffer.
  7665. * @param vertexBuffer the vertex buffer to update
  7666. * @param data the data used to update the vertex buffer
  7667. * @param byteOffset the byte offset of the data
  7668. * @param byteLength the byte length of the data
  7669. */
  7670. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7671. private _resetIndexBufferBinding();
  7672. /**
  7673. * Creates a new index buffer
  7674. * @param indices defines the content of the index buffer
  7675. * @param updatable defines if the index buffer must be updatable
  7676. * @returns a new webGL buffer
  7677. */
  7678. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7679. /**
  7680. * Bind a webGL buffer to the webGL context
  7681. * @param buffer defines the buffer to bind
  7682. */
  7683. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7684. /**
  7685. * Bind an uniform buffer to the current webGL context
  7686. * @param buffer defines the buffer to bind
  7687. */
  7688. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7689. /**
  7690. * Bind a buffer to the current webGL context at a given location
  7691. * @param buffer defines the buffer to bind
  7692. * @param location defines the index where to bind the buffer
  7693. */
  7694. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7695. /**
  7696. * Bind a specific block at a given index in a specific shader program
  7697. * @param shaderProgram defines the shader program
  7698. * @param blockName defines the block name
  7699. * @param index defines the index where to bind the block
  7700. */
  7701. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7702. private bindIndexBuffer(buffer);
  7703. private bindBuffer(buffer, target);
  7704. /**
  7705. * update the bound buffer with the given data
  7706. * @param data defines the data to update
  7707. */
  7708. updateArrayBuffer(data: Float32Array): void;
  7709. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7710. private _bindIndexBufferWithCache(indexBuffer);
  7711. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7712. /**
  7713. * Records a vertex array object
  7714. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7715. * @param vertexBuffers defines the list of vertex buffers to store
  7716. * @param indexBuffer defines the index buffer to store
  7717. * @param effect defines the effect to store
  7718. * @returns the new vertex array object
  7719. */
  7720. recordVertexArrayObject(vertexBuffers: {
  7721. [key: string]: VertexBuffer;
  7722. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7723. /**
  7724. * Bind a specific vertex array object
  7725. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7726. * @param vertexArrayObject defines the vertex array object to bind
  7727. * @param indexBuffer defines the index buffer to bind
  7728. */
  7729. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7730. /**
  7731. * Bind webGl buffers directly to the webGL context
  7732. * @param vertexBuffer defines the vertex buffer to bind
  7733. * @param indexBuffer defines the index buffer to bind
  7734. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7735. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7736. * @param effect defines the effect associated with the vertex buffer
  7737. */
  7738. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7739. private _unbindVertexArrayObject();
  7740. /**
  7741. * Bind a list of vertex buffers to the webGL context
  7742. * @param vertexBuffers defines the list of vertex buffers to bind
  7743. * @param indexBuffer defines the index buffer to bind
  7744. * @param effect defines the effect associated with the vertex buffers
  7745. */
  7746. bindBuffers(vertexBuffers: {
  7747. [key: string]: Nullable<VertexBuffer>;
  7748. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7749. /**
  7750. * Unbind all instance attributes
  7751. */
  7752. unbindInstanceAttributes(): void;
  7753. /**
  7754. * Release and free the memory of a vertex array object
  7755. * @param vao defines the vertex array object to delete
  7756. */
  7757. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7758. /** @hidden */
  7759. /**
  7760. * Creates a webGL buffer to use with instanciation
  7761. * @param capacity defines the size of the buffer
  7762. * @returns the webGL buffer
  7763. */
  7764. createInstancesBuffer(capacity: number): WebGLBuffer;
  7765. /**
  7766. * Delete a webGL buffer used with instanciation
  7767. * @param buffer defines the webGL buffer to delete
  7768. */
  7769. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7770. /**
  7771. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7772. * @param instancesBuffer defines the webGL buffer to update and bind
  7773. * @param data defines the data to store in the buffer
  7774. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7775. */
  7776. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7777. /**
  7778. * Apply all cached states (depth, culling, stencil and alpha)
  7779. */
  7780. applyStates(): void;
  7781. /**
  7782. * Send a draw order
  7783. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7784. * @param indexStart defines the starting index
  7785. * @param indexCount defines the number of index to draw
  7786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7787. */
  7788. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7789. /**
  7790. * Draw a list of points
  7791. * @param verticesStart defines the index of first vertex to draw
  7792. * @param verticesCount defines the count of vertices to draw
  7793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7794. */
  7795. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7796. /**
  7797. * Draw a list of unindexed primitives
  7798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7799. * @param verticesStart defines the index of first vertex to draw
  7800. * @param verticesCount defines the count of vertices to draw
  7801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7802. */
  7803. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7804. /**
  7805. * Draw a list of indexed primitives
  7806. * @param fillMode defines the primitive to use
  7807. * @param indexStart defines the starting index
  7808. * @param indexCount defines the number of index to draw
  7809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7810. */
  7811. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7812. /**
  7813. * Draw a list of unindexed primitives
  7814. * @param fillMode defines the primitive to use
  7815. * @param verticesStart defines the index of first vertex to draw
  7816. * @param verticesCount defines the count of vertices to draw
  7817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7818. */
  7819. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7820. private _drawMode(fillMode);
  7821. /** @hidden */
  7822. /** @hidden */
  7823. /**
  7824. * Create a new effect (used to store vertex/fragment shaders)
  7825. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7826. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7827. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7828. * @param samplers defines an array of string used to represent textures
  7829. * @param defines defines the string containing the defines to use to compile the shaders
  7830. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7831. * @param onCompiled defines a function to call when the effect creation is successful
  7832. * @param onError defines a function to call when the effect creation has failed
  7833. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7834. * @returns the new Effect
  7835. */
  7836. 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;
  7837. /**
  7838. * Create an effect to use with particle systems
  7839. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7840. * @param uniformsNames defines a list of attribute names
  7841. * @param samplers defines an array of string used to represent textures
  7842. * @param defines defines the string containing the defines to use to compile the shaders
  7843. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7844. * @param onCompiled defines a function to call when the effect creation is successful
  7845. * @param onError defines a function to call when the effect creation has failed
  7846. * @returns the new Effect
  7847. */
  7848. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7849. /**
  7850. * Directly creates a webGL program
  7851. * @param vertexCode defines the vertex shader code to use
  7852. * @param fragmentCode defines the fragment shader code to use
  7853. * @param context defines the webGL context to use (if not set, the current one will be used)
  7854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7855. * @returns the new webGL program
  7856. */
  7857. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7858. /**
  7859. * Creates a webGL program
  7860. * @param vertexCode defines the vertex shader code to use
  7861. * @param fragmentCode defines the fragment shader code to use
  7862. * @param defines defines the string containing the defines to use to compile the shaders
  7863. * @param context defines the webGL context to use (if not set, the current one will be used)
  7864. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7865. * @returns the new webGL program
  7866. */
  7867. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7868. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7869. /**
  7870. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7871. * @param shaderProgram defines the webGL program to use
  7872. * @param uniformsNames defines the list of uniform names
  7873. * @returns an array of webGL uniform locations
  7874. */
  7875. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7876. /**
  7877. * Gets the lsit of active attributes for a given webGL program
  7878. * @param shaderProgram defines the webGL program to use
  7879. * @param attributesNames defines the list of attribute names to get
  7880. * @returns an array of indices indicating the offset of each attribute
  7881. */
  7882. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7883. /**
  7884. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7885. * @param effect defines the effect to activate
  7886. */
  7887. enableEffect(effect: Nullable<Effect>): void;
  7888. /**
  7889. * Set the value of an uniform to an array of int32
  7890. * @param uniform defines the webGL uniform location where to store the value
  7891. * @param array defines the array of int32 to store
  7892. */
  7893. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7894. /**
  7895. * Set the value of an uniform to an array of int32 (stored as vec2)
  7896. * @param uniform defines the webGL uniform location where to store the value
  7897. * @param array defines the array of int32 to store
  7898. */
  7899. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7900. /**
  7901. * Set the value of an uniform to an array of int32 (stored as vec3)
  7902. * @param uniform defines the webGL uniform location where to store the value
  7903. * @param array defines the array of int32 to store
  7904. */
  7905. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7906. /**
  7907. * Set the value of an uniform to an array of int32 (stored as vec4)
  7908. * @param uniform defines the webGL uniform location where to store the value
  7909. * @param array defines the array of int32 to store
  7910. */
  7911. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7912. /**
  7913. * Set the value of an uniform to an array of float32
  7914. * @param uniform defines the webGL uniform location where to store the value
  7915. * @param array defines the array of float32 to store
  7916. */
  7917. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7918. /**
  7919. * Set the value of an uniform to an array of float32 (stored as vec2)
  7920. * @param uniform defines the webGL uniform location where to store the value
  7921. * @param array defines the array of float32 to store
  7922. */
  7923. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7924. /**
  7925. * Set the value of an uniform to an array of float32 (stored as vec3)
  7926. * @param uniform defines the webGL uniform location where to store the value
  7927. * @param array defines the array of float32 to store
  7928. */
  7929. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7930. /**
  7931. * Set the value of an uniform to an array of float32 (stored as vec4)
  7932. * @param uniform defines the webGL uniform location where to store the value
  7933. * @param array defines the array of float32 to store
  7934. */
  7935. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7936. /**
  7937. * Set the value of an uniform to an array of number
  7938. * @param uniform defines the webGL uniform location where to store the value
  7939. * @param array defines the array of number to store
  7940. */
  7941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7942. /**
  7943. * Set the value of an uniform to an array of number (stored as vec2)
  7944. * @param uniform defines the webGL uniform location where to store the value
  7945. * @param array defines the array of number to store
  7946. */
  7947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7948. /**
  7949. * Set the value of an uniform to an array of number (stored as vec3)
  7950. * @param uniform defines the webGL uniform location where to store the value
  7951. * @param array defines the array of number to store
  7952. */
  7953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7954. /**
  7955. * Set the value of an uniform to an array of number (stored as vec4)
  7956. * @param uniform defines the webGL uniform location where to store the value
  7957. * @param array defines the array of number to store
  7958. */
  7959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7960. /**
  7961. * Set the value of an uniform to an array of float32 (stored as matrices)
  7962. * @param uniform defines the webGL uniform location where to store the value
  7963. * @param matrices defines the array of float32 to store
  7964. */
  7965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7966. /**
  7967. * Set the value of an uniform to a matrix
  7968. * @param uniform defines the webGL uniform location where to store the value
  7969. * @param matrix defines the matrix to store
  7970. */
  7971. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7972. /**
  7973. * Set the value of an uniform to a matrix (3x3)
  7974. * @param uniform defines the webGL uniform location where to store the value
  7975. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7976. */
  7977. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7978. /**
  7979. * Set the value of an uniform to a matrix (2x2)
  7980. * @param uniform defines the webGL uniform location where to store the value
  7981. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7982. */
  7983. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7984. /**
  7985. * Set the value of an uniform to a number (int)
  7986. * @param uniform defines the webGL uniform location where to store the value
  7987. * @param value defines the int number to store
  7988. */
  7989. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7990. /**
  7991. * Set the value of an uniform to a number (float)
  7992. * @param uniform defines the webGL uniform location where to store the value
  7993. * @param value defines the float number to store
  7994. */
  7995. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7996. /**
  7997. * Set the value of an uniform to a vec2
  7998. * @param uniform defines the webGL uniform location where to store the value
  7999. * @param x defines the 1st component of the value
  8000. * @param y defines the 2nd component of the value
  8001. */
  8002. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8003. /**
  8004. * Set the value of an uniform to a vec3
  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. * @param z defines the 3rd component of the value
  8009. */
  8010. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8011. /**
  8012. * Set the value of an uniform to a boolean
  8013. * @param uniform defines the webGL uniform location where to store the value
  8014. * @param bool defines the boolean to store
  8015. */
  8016. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8017. /**
  8018. * Set the value of an uniform to a vec4
  8019. * @param uniform defines the webGL uniform location where to store the value
  8020. * @param x defines the 1st component of the value
  8021. * @param y defines the 2nd component of the value
  8022. * @param z defines the 3rd component of the value
  8023. * @param w defines the 4th component of the value
  8024. */
  8025. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8026. /**
  8027. * Set the value of an uniform to a Color3
  8028. * @param uniform defines the webGL uniform location where to store the value
  8029. * @param color3 defines the color to store
  8030. */
  8031. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8032. /**
  8033. * Set the value of an uniform to a Color3 and an alpha value
  8034. * @param uniform defines the webGL uniform location where to store the value
  8035. * @param color3 defines the color to store
  8036. * @param alpha defines the alpha component to store
  8037. */
  8038. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8039. /**
  8040. * Sets a Color4 on a uniform variable
  8041. * @param uniform defines the uniform location
  8042. * @param color4 defines the value to be set
  8043. */
  8044. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8045. /**
  8046. * Set various states to the webGL context
  8047. * @param culling defines backface culling state
  8048. * @param zOffset defines the value to apply to zOffset (0 by default)
  8049. * @param force defines if states must be applied even if cache is up to date
  8050. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8051. */
  8052. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8053. /**
  8054. * Set the z offset to apply to current rendering
  8055. * @param value defines the offset to apply
  8056. */
  8057. setZOffset(value: number): void;
  8058. /**
  8059. * Gets the current value of the zOffset
  8060. * @returns the current zOffset state
  8061. */
  8062. getZOffset(): number;
  8063. /**
  8064. * Enable or disable depth buffering
  8065. * @param enable defines the state to set
  8066. */
  8067. setDepthBuffer(enable: boolean): void;
  8068. /**
  8069. * Gets a boolean indicating if depth writing is enabled
  8070. * @returns the current depth writing state
  8071. */
  8072. getDepthWrite(): boolean;
  8073. /**
  8074. * Enable or disable depth writing
  8075. * @param enable defines the state to set
  8076. */
  8077. setDepthWrite(enable: boolean): void;
  8078. /**
  8079. * Enable or disable color writing
  8080. * @param enable defines the state to set
  8081. */
  8082. setColorWrite(enable: boolean): void;
  8083. /**
  8084. * Gets a boolean indicating if color writing is enabled
  8085. * @returns the current color writing state
  8086. */
  8087. getColorWrite(): boolean;
  8088. /**
  8089. * Sets alpha constants used by some alpha blending modes
  8090. * @param r defines the red component
  8091. * @param g defines the green component
  8092. * @param b defines the blue component
  8093. * @param a defines the alpha component
  8094. */
  8095. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8096. /**
  8097. * Sets the current alpha mode
  8098. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8099. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8100. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8101. */
  8102. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8103. /**
  8104. * Gets the current alpha mode
  8105. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8106. * @returns the current alpha mode
  8107. */
  8108. getAlphaMode(): number;
  8109. /**
  8110. * Force the entire cache to be cleared
  8111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8113. */
  8114. wipeCaches(bruteForce?: boolean): void;
  8115. /**
  8116. * Set the compressed texture format to use, based on the formats you have, and the formats
  8117. * supported by the hardware / browser.
  8118. *
  8119. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8120. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8121. * to API arguments needed to compressed textures. This puts the burden on the container
  8122. * generator to house the arcane code for determining these for current & future formats.
  8123. *
  8124. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8125. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8126. *
  8127. * Note: The result of this call is not taken into account when a texture is base64.
  8128. *
  8129. * @param formatsAvailable defines the list of those format families you have created
  8130. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8131. *
  8132. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8133. * @returns The extension selected.
  8134. */
  8135. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8136. /** @hidden */
  8137. /**
  8138. * Usually called from BABYLON.Texture.ts.
  8139. * Passed information to create a WebGLTexture
  8140. * @param urlArg defines a value which contains one of the following:
  8141. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8142. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8143. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8144. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8145. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8146. * @param scene needed for loading to the correct scene
  8147. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8148. * @param onLoad optional callback to be called upon successful completion
  8149. * @param onError optional callback to be called upon failure
  8150. * @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
  8151. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8152. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8153. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8154. */
  8155. 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;
  8156. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8157. /**
  8158. * Update a raw texture
  8159. * @param texture defines the texture to update
  8160. * @param data defines the data to store in the texture
  8161. * @param format defines the format of the data
  8162. * @param invertY defines if data must be stored with Y axis inverted
  8163. * @param compression defines the compression used (null by default)
  8164. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8165. */
  8166. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8167. /**
  8168. * Creates a raw texture
  8169. * @param data defines the data to store in the texture
  8170. * @param width defines the width of the texture
  8171. * @param height defines the height of the texture
  8172. * @param format defines the format of the data
  8173. * @param generateMipMaps defines if the engine should generate the mip levels
  8174. * @param invertY defines if data must be stored with Y axis inverted
  8175. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8176. * @param compression defines the compression used (null by default)
  8177. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8178. * @returns the raw texture inside an InternalTexture
  8179. */
  8180. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8181. /**
  8182. * Creates a dynamic texture
  8183. * @param width defines the width of the texture
  8184. * @param height defines the height of the texture
  8185. * @param generateMipMaps defines if the engine should generate the mip levels
  8186. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8187. * @returns the dynamic texture inside an InternalTexture
  8188. */
  8189. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8190. /**
  8191. * Update the sampling mode of a given texture
  8192. * @param samplingMode defines the required sampling mode
  8193. * @param texture defines the texture to update
  8194. */
  8195. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8196. /**
  8197. * Update the content of a dynamic texture
  8198. * @param texture defines the texture to update
  8199. * @param canvas defines the canvas containing the source
  8200. * @param invertY defines if data must be stored with Y axis inverted
  8201. * @param premulAlpha defines if alpha is stored as premultiplied
  8202. * @param format defines the format of the data
  8203. */
  8204. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8205. /**
  8206. * Update a video texture
  8207. * @param texture defines the texture to update
  8208. * @param video defines the video element to use
  8209. * @param invertY defines if data must be stored with Y axis inverted
  8210. */
  8211. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8212. /**
  8213. * Updates a depth texture Comparison Mode and Function.
  8214. * If the comparison Function is equal to 0, the mode will be set to none.
  8215. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8216. * @param texture The texture to set the comparison function for
  8217. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8218. */
  8219. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8220. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8221. /**
  8222. * Creates a depth stencil texture.
  8223. * This is only available in WebGL 2 or with the depth texture extension available.
  8224. * @param size The size of face edge in the texture.
  8225. * @param options The options defining the texture.
  8226. * @returns The texture
  8227. */
  8228. createDepthStencilTexture(size: number | {
  8229. width: number;
  8230. height: number;
  8231. }, options: DepthTextureCreationOptions): InternalTexture;
  8232. /**
  8233. * Creates a depth stencil texture.
  8234. * This is only available in WebGL 2 or with the depth texture extension available.
  8235. * @param size The size of face edge in the texture.
  8236. * @param options The options defining the texture.
  8237. * @returns The texture
  8238. */
  8239. private _createDepthStencilTexture(size, options);
  8240. /**
  8241. * Creates a depth stencil cube texture.
  8242. * This is only available in WebGL 2.
  8243. * @param size The size of face edge in the cube texture.
  8244. * @param options The options defining the cube texture.
  8245. * @returns The cube texture
  8246. */
  8247. private _createDepthStencilCubeTexture(size, options);
  8248. /**
  8249. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8250. * @param renderTarget The render target to set the frame buffer for
  8251. */
  8252. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8253. /**
  8254. * Creates a new render target texture
  8255. * @param size defines the size of the texture
  8256. * @param options defines the options used to create the texture
  8257. * @returns a new render target texture stored in an InternalTexture
  8258. */
  8259. createRenderTargetTexture(size: number | {
  8260. width: number;
  8261. height: number;
  8262. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8263. /**
  8264. * Create a multi render target texture
  8265. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8266. * @param size defines the size of the texture
  8267. * @param options defines the creation options
  8268. * @returns the cube texture as an InternalTexture
  8269. */
  8270. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8271. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8272. /**
  8273. * Updates the sample count of a render target texture
  8274. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8275. * @param texture defines the texture to update
  8276. * @param samples defines the sample count to set
  8277. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8278. */
  8279. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8280. /**
  8281. * Update the sample count for a given multiple render target texture
  8282. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8283. * @param textures defines the textures to update
  8284. * @param samples defines the sample count to set
  8285. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8286. */
  8287. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8288. /** @hidden */
  8289. /** @hidden */
  8290. /**
  8291. * Creates a new render target cube texture
  8292. * @param size defines the size of the texture
  8293. * @param options defines the options used to create the texture
  8294. * @returns a new render target cube texture stored in an InternalTexture
  8295. */
  8296. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8297. /**
  8298. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8299. * @param rootUrl defines the url where the file to load is located
  8300. * @param scene defines the current scene
  8301. * @param scale defines scale to apply to the mip map selection
  8302. * @param offset defines offset to apply to the mip map selection
  8303. * @param onLoad defines an optional callback raised when the texture is loaded
  8304. * @param onError defines an optional callback raised if there is an issue to load the texture
  8305. * @param format defines the format of the data
  8306. * @param forcedExtension defines the extension to use to pick the right loader
  8307. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8308. * @returns the cube texture as an InternalTexture
  8309. */
  8310. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8311. /**
  8312. * Creates a cube texture
  8313. * @param rootUrl defines the url where the files to load is located
  8314. * @param scene defines the current scene
  8315. * @param files defines the list of files to load (1 per face)
  8316. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8317. * @param onLoad defines an optional callback raised when the texture is loaded
  8318. * @param onError defines an optional callback raised if there is an issue to load the texture
  8319. * @param format defines the format of the data
  8320. * @param forcedExtension defines the extension to use to pick the right loader
  8321. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8322. * @returns the cube texture as an InternalTexture
  8323. */
  8324. 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): InternalTexture;
  8325. private setCubeMapTextureParams(gl, loadMipmap);
  8326. /**
  8327. * Update a raw cube texture
  8328. * @param texture defines the texture to udpdate
  8329. * @param data defines the data to store
  8330. * @param format defines the data format
  8331. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8332. * @param invertY defines if data must be stored with Y axis inverted
  8333. * @param compression defines the compression used (null by default)
  8334. * @param level defines which level of the texture to update
  8335. */
  8336. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8337. /**
  8338. * Creates a new raw cube texture
  8339. * @param data defines the array of data to use to create each face
  8340. * @param size defines the size of the textures
  8341. * @param format defines the format of the data
  8342. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8343. * @param generateMipMaps defines if the engine should generate the mip levels
  8344. * @param invertY defines if data must be stored with Y axis inverted
  8345. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8346. * @param compression defines the compression used (null by default)
  8347. * @returns the cube texture as an InternalTexture
  8348. */
  8349. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8350. /**
  8351. * Creates a new raw cube texture from a specified url
  8352. * @param url defines the url where the data is located
  8353. * @param scene defines the current scene
  8354. * @param size defines the size of the textures
  8355. * @param format defines the format of the data
  8356. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8357. * @param noMipmap defines if the engine should avoid generating the mip levels
  8358. * @param callback defines a callback used to extract texture data from loaded data
  8359. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8360. * @param onLoad defines a callback called when texture is loaded
  8361. * @param onError defines a callback called if there is an error
  8362. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8363. * @param invertY defines if data must be stored with Y axis inverted
  8364. * @returns the cube texture as an InternalTexture
  8365. */
  8366. 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;
  8367. /**
  8368. * Update a raw 3D texture
  8369. * @param texture defines the texture to update
  8370. * @param data defines the data to store
  8371. * @param format defines the data format
  8372. * @param invertY defines if data must be stored with Y axis inverted
  8373. * @param compression defines the used compression (can be null)
  8374. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8375. */
  8376. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8377. /**
  8378. * Creates a new raw 3D texture
  8379. * @param data defines the data used to create the texture
  8380. * @param width defines the width of the texture
  8381. * @param height defines the height of the texture
  8382. * @param depth defines the depth of the texture
  8383. * @param format defines the format of the texture
  8384. * @param generateMipMaps defines if the engine must generate mip levels
  8385. * @param invertY defines if data must be stored with Y axis inverted
  8386. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8387. * @param compression defines the compressed used (can be null)
  8388. * @param textureType defines the compressed used (can be null)
  8389. * @returns a new raw 3D texture (stored in an InternalTexture)
  8390. */
  8391. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8392. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8393. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8394. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8395. /** @hidden */
  8396. /** @hidden */
  8397. private setProgram(program);
  8398. private _boundUniforms;
  8399. /**
  8400. * Binds an effect to the webGL context
  8401. * @param effect defines the effect to bind
  8402. */
  8403. bindSamplers(effect: Effect): void;
  8404. private _moveBoundTextureOnTop(internalTexture);
  8405. private _getCorrectTextureChannel(channel, internalTexture);
  8406. private _linkTrackers(previous, next);
  8407. private _removeDesignatedSlot(internalTexture);
  8408. private _activateCurrentTexture();
  8409. /** @hidden */
  8410. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8411. /** @hidden */
  8412. /**
  8413. * Sets a texture to the webGL context from a postprocess
  8414. * @param channel defines the channel to use
  8415. * @param postProcess defines the source postprocess
  8416. */
  8417. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8418. /**
  8419. * Binds the output of the passed in post process to the texture channel specified
  8420. * @param channel The channel the texture should be bound to
  8421. * @param postProcess The post process which's output should be bound
  8422. */
  8423. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8424. /**
  8425. * Unbind all textures from the webGL context
  8426. */
  8427. unbindAllTextures(): void;
  8428. /**
  8429. * Sets a texture to the according uniform.
  8430. * @param channel The texture channel
  8431. * @param uniform The uniform to set
  8432. * @param texture The texture to apply
  8433. */
  8434. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8435. /**
  8436. * Sets a depth stencil texture from a render target to the according uniform.
  8437. * @param channel The texture channel
  8438. * @param uniform The uniform to set
  8439. * @param texture The render target texture containing the depth stencil texture to apply
  8440. */
  8441. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8442. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8443. private _getTextureWrapMode(mode);
  8444. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8445. /**
  8446. * Sets an array of texture to the webGL context
  8447. * @param channel defines the channel where the texture array must be set
  8448. * @param uniform defines the associated uniform location
  8449. * @param textures defines the array of textures to bind
  8450. */
  8451. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8452. /** @hidden */
  8453. private _setTextureParameterFloat(target, parameter, value, texture);
  8454. private _setTextureParameterInteger(target, parameter, value, texture?);
  8455. /**
  8456. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8457. * @param x defines the x coordinate of the rectangle where pixels must be read
  8458. * @param y defines the y coordinate of the rectangle where pixels must be read
  8459. * @param width defines the width of the rectangle where pixels must be read
  8460. * @param height defines the height of the rectangle where pixels must be read
  8461. * @returns a Uint8Array containing RGBA colors
  8462. */
  8463. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8464. /**
  8465. * Add an externaly attached data from its key.
  8466. * This method call will fail and return false, if such key already exists.
  8467. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8468. * @param key the unique key that identifies the data
  8469. * @param data the data object to associate to the key for this Engine instance
  8470. * @return true if no such key were already present and the data was added successfully, false otherwise
  8471. */
  8472. addExternalData<T>(key: string, data: T): boolean;
  8473. /**
  8474. * Get an externaly attached data from its key
  8475. * @param key the unique key that identifies the data
  8476. * @return the associated data, if present (can be null), or undefined if not present
  8477. */
  8478. getExternalData<T>(key: string): T;
  8479. /**
  8480. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8481. * @param key the unique key that identifies the data
  8482. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8483. * @return the associated data, can be null if the factory returned null.
  8484. */
  8485. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8486. /**
  8487. * Remove an externaly attached data from the Engine instance
  8488. * @param key the unique key that identifies the data
  8489. * @return true if the data was successfully removed, false if it doesn't exist
  8490. */
  8491. removeExternalData(key: string): boolean;
  8492. /**
  8493. * Unbind all vertex attributes from the webGL context
  8494. */
  8495. unbindAllAttributes(): void;
  8496. /**
  8497. * 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
  8498. */
  8499. releaseEffects(): void;
  8500. /**
  8501. * Dispose and release all associated resources
  8502. */
  8503. dispose(): void;
  8504. /**
  8505. * Display the loading screen
  8506. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8507. */
  8508. displayLoadingUI(): void;
  8509. /**
  8510. * Hide the loading screen
  8511. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8512. */
  8513. hideLoadingUI(): void;
  8514. /**
  8515. * Gets the current loading screen object
  8516. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8517. */
  8518. /**
  8519. * Sets the current loading screen object
  8520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8521. */
  8522. loadingScreen: ILoadingScreen;
  8523. /**
  8524. * Sets the current loading screen text
  8525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8526. */
  8527. loadingUIText: string;
  8528. /**
  8529. * Sets the current loading screen background color
  8530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8531. */
  8532. loadingUIBackgroundColor: string;
  8533. /**
  8534. * Attach a new callback raised when context lost event is fired
  8535. * @param callback defines the callback to call
  8536. */
  8537. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8538. /**
  8539. * Attach a new callback raised when context restored event is fired
  8540. * @param callback defines the callback to call
  8541. */
  8542. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8543. /**
  8544. * Gets the source code of the vertex shader associated with a specific webGL program
  8545. * @param program defines the program to use
  8546. * @returns a string containing the source code of the vertex shader associated with the program
  8547. */
  8548. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8549. /**
  8550. * Gets the source code of the fragment shader associated with a specific webGL program
  8551. * @param program defines the program to use
  8552. * @returns a string containing the source code of the fragment shader associated with the program
  8553. */
  8554. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8555. /**
  8556. * Get the current error code of the webGL context
  8557. * @returns the error code
  8558. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8559. */
  8560. getError(): number;
  8561. /**
  8562. * Gets the current framerate
  8563. * @returns a number representing the framerate
  8564. */
  8565. getFps(): number;
  8566. /**
  8567. * Gets the time spent between current and previous frame
  8568. * @returns a number representing the delta time in ms
  8569. */
  8570. getDeltaTime(): number;
  8571. private _measureFps();
  8572. /** @hidden */
  8573. private _canRenderToFloatFramebuffer();
  8574. private _canRenderToHalfFloatFramebuffer();
  8575. private _canRenderToFramebuffer(type);
  8576. /** @hidden */
  8577. private _getInternalFormat(format);
  8578. /** @hidden */
  8579. /** @hidden */
  8580. /**
  8581. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8582. * @return the new query
  8583. */
  8584. createQuery(): WebGLQuery;
  8585. /**
  8586. * Delete and release a webGL query
  8587. * @param query defines the query to delete
  8588. * @return the current engine
  8589. */
  8590. deleteQuery(query: WebGLQuery): Engine;
  8591. /**
  8592. * Check if a given query has resolved and got its value
  8593. * @param query defines the query to check
  8594. * @returns true if the query got its value
  8595. */
  8596. isQueryResultAvailable(query: WebGLQuery): boolean;
  8597. /**
  8598. * Gets the value of a given query
  8599. * @param query defines the query to check
  8600. * @returns the value of the query
  8601. */
  8602. getQueryResult(query: WebGLQuery): number;
  8603. /**
  8604. * Initiates an occlusion query
  8605. * @param algorithmType defines the algorithm to use
  8606. * @param query defines the query to use
  8607. * @returns the current engine
  8608. * @see http://doc.babylonjs.com/features/occlusionquery
  8609. */
  8610. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8611. /**
  8612. * Ends an occlusion query
  8613. * @see http://doc.babylonjs.com/features/occlusionquery
  8614. * @param algorithmType defines the algorithm to use
  8615. * @returns the current engine
  8616. */
  8617. endOcclusionQuery(algorithmType: number): Engine;
  8618. private _createTimeQuery();
  8619. private _deleteTimeQuery(query);
  8620. private _getTimeQueryResult(query);
  8621. private _getTimeQueryAvailability(query);
  8622. private _currentNonTimestampToken;
  8623. /**
  8624. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8625. * Please note that only one query can be issued at a time
  8626. * @returns a time token used to track the time span
  8627. */
  8628. startTimeQuery(): Nullable<_TimeToken>;
  8629. /**
  8630. * Ends a time query
  8631. * @param token defines the token used to measure the time span
  8632. * @returns the time spent (in ns)
  8633. */
  8634. endTimeQuery(token: _TimeToken): int;
  8635. private getGlAlgorithmType(algorithmType);
  8636. /**
  8637. * Creates a webGL transform feedback object
  8638. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8639. * @returns the webGL transform feedback object
  8640. */
  8641. createTransformFeedback(): WebGLTransformFeedback;
  8642. /**
  8643. * Delete a webGL transform feedback object
  8644. * @param value defines the webGL transform feedback object to delete
  8645. */
  8646. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8647. /**
  8648. * Bind a webGL transform feedback object to the webgl context
  8649. * @param value defines the webGL transform feedback object to bind
  8650. */
  8651. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8652. /**
  8653. * Begins a transform feedback operation
  8654. * @param usePoints defines if points or triangles must be used
  8655. */
  8656. beginTransformFeedback(usePoints?: boolean): void;
  8657. /**
  8658. * Ends a transform feedback operation
  8659. */
  8660. endTransformFeedback(): void;
  8661. /**
  8662. * Specify the varyings to use with transform feedback
  8663. * @param program defines the associated webGL program
  8664. * @param value defines the list of strings representing the varying names
  8665. */
  8666. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8667. /**
  8668. * Bind a webGL buffer for a transform feedback operation
  8669. * @param value defines the webGL buffer to bind
  8670. */
  8671. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8672. /** @hidden */
  8673. /** @hidden */
  8674. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8675. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8676. /**
  8677. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8678. * @returns true if the engine can be created
  8679. * @ignorenaming
  8680. */
  8681. static isSupported(): boolean;
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. class NullEngineOptions {
  8686. renderWidth: number;
  8687. renderHeight: number;
  8688. textureSize: number;
  8689. deterministicLockstep: boolean;
  8690. lockstepMaxSteps: number;
  8691. }
  8692. /**
  8693. * The null engine class provides support for headless version of babylon.js.
  8694. * This can be used in server side scenario or for testing purposes
  8695. */
  8696. class NullEngine extends Engine {
  8697. private _options;
  8698. isDeterministicLockStep(): boolean;
  8699. getLockstepMaxSteps(): number;
  8700. getHardwareScalingLevel(): number;
  8701. constructor(options?: NullEngineOptions);
  8702. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8703. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8704. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8705. getRenderWidth(useScreen?: boolean): number;
  8706. getRenderHeight(useScreen?: boolean): number;
  8707. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8708. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8709. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8710. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8711. bindSamplers(effect: Effect): void;
  8712. enableEffect(effect: Effect): void;
  8713. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8714. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8715. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8716. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8717. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8718. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8719. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8720. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8721. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8722. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8723. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8724. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8725. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8726. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8727. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8728. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8729. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8730. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8731. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8732. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8733. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8734. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8735. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8736. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8737. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8738. bindBuffers(vertexBuffers: {
  8739. [key: string]: VertexBuffer;
  8740. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8741. wipeCaches(bruteForce?: boolean): void;
  8742. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8743. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8744. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8745. 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;
  8746. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8747. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8749. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8750. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8751. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8752. /**
  8753. * Updates a dynamic vertex buffer.
  8754. * @param vertexBuffer the vertex buffer to update
  8755. * @param data the data used to update the vertex buffer
  8756. * @param byteOffset the byte offset of the data (optional)
  8757. * @param byteLength the byte length of the data (optional)
  8758. */
  8759. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8760. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8761. releaseEffects(): void;
  8762. }
  8763. }
  8764. interface WebGLRenderingContext {
  8765. readonly RASTERIZER_DISCARD: number;
  8766. readonly DEPTH_COMPONENT24: number;
  8767. readonly TEXTURE_3D: number;
  8768. readonly TEXTURE_2D_ARRAY: number;
  8769. readonly TEXTURE_COMPARE_FUNC: number;
  8770. readonly TEXTURE_COMPARE_MODE: number;
  8771. readonly COMPARE_REF_TO_TEXTURE: number;
  8772. readonly TEXTURE_WRAP_R: number;
  8773. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8774. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8775. 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;
  8776. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8777. readonly TRANSFORM_FEEDBACK: number;
  8778. readonly INTERLEAVED_ATTRIBS: number;
  8779. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8780. createTransformFeedback(): WebGLTransformFeedback;
  8781. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8782. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8783. beginTransformFeedback(primitiveMode: number): void;
  8784. endTransformFeedback(): void;
  8785. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8786. }
  8787. interface ImageBitmap {
  8788. readonly width: number;
  8789. readonly height: number;
  8790. close(): void;
  8791. }
  8792. interface WebGLQuery extends WebGLObject {
  8793. }
  8794. declare var WebGLQuery: {
  8795. prototype: WebGLQuery;
  8796. new (): WebGLQuery;
  8797. };
  8798. interface WebGLSampler extends WebGLObject {
  8799. }
  8800. declare var WebGLSampler: {
  8801. prototype: WebGLSampler;
  8802. new (): WebGLSampler;
  8803. };
  8804. interface WebGLSync extends WebGLObject {
  8805. }
  8806. declare var WebGLSync: {
  8807. prototype: WebGLSync;
  8808. new (): WebGLSync;
  8809. };
  8810. interface WebGLTransformFeedback extends WebGLObject {
  8811. }
  8812. declare var WebGLTransformFeedback: {
  8813. prototype: WebGLTransformFeedback;
  8814. new (): WebGLTransformFeedback;
  8815. };
  8816. interface WebGLVertexArrayObject extends WebGLObject {
  8817. }
  8818. declare var WebGLVertexArrayObject: {
  8819. prototype: WebGLVertexArrayObject;
  8820. new (): WebGLVertexArrayObject;
  8821. };
  8822. declare module BABYLON {
  8823. class KeyboardEventTypes {
  8824. private static _KEYDOWN: number;
  8825. private static _KEYUP: number;
  8826. static readonly KEYDOWN: number;
  8827. static readonly KEYUP: number;
  8828. }
  8829. class KeyboardInfo {
  8830. type: number;
  8831. event: KeyboardEvent;
  8832. constructor(type: number, event: KeyboardEvent);
  8833. }
  8834. /**
  8835. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8836. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8837. */
  8838. class KeyboardInfoPre extends KeyboardInfo {
  8839. constructor(type: number, event: KeyboardEvent);
  8840. skipOnPointerObservable: boolean;
  8841. }
  8842. }
  8843. declare module BABYLON {
  8844. class PointerEventTypes {
  8845. private static _POINTERDOWN: number;
  8846. private static _POINTERUP: number;
  8847. private static _POINTERMOVE: number;
  8848. private static _POINTERWHEEL: number;
  8849. private static _POINTERPICK: number;
  8850. private static _POINTERTAP: number;
  8851. private static _POINTERDOUBLETAP: number;
  8852. static readonly POINTERDOWN: number;
  8853. static readonly POINTERUP: number;
  8854. static readonly POINTERMOVE: number;
  8855. static readonly POINTERWHEEL: number;
  8856. static readonly POINTERPICK: number;
  8857. static readonly POINTERTAP: number;
  8858. static readonly POINTERDOUBLETAP: number;
  8859. }
  8860. class PointerInfoBase {
  8861. type: number;
  8862. event: PointerEvent | MouseWheelEvent;
  8863. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  8864. }
  8865. /**
  8866. * This class is used to store pointer related info for the onPrePointerObservable event.
  8867. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8868. */
  8869. class PointerInfoPre extends PointerInfoBase {
  8870. /**
  8871. * Ray from a pointer if availible (eg. 6dof controller)
  8872. */
  8873. ray: Nullable<Ray>;
  8874. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8875. localPosition: Vector2;
  8876. skipOnPointerObservable: boolean;
  8877. }
  8878. /**
  8879. * This type contains all the data related to a pointer event in Babylon.js.
  8880. * 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.
  8881. */
  8882. class PointerInfo extends PointerInfoBase {
  8883. pickInfo: Nullable<PickingInfo>;
  8884. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  8885. }
  8886. }
  8887. /**
  8888. * Module Debug contains the (visual) components to debug a scene correctly
  8889. */
  8890. declare module BABYLON.Debug {
  8891. /**
  8892. * The Axes viewer will show 3 axes in a specific point in space
  8893. */
  8894. class AxesViewer {
  8895. private _xline;
  8896. private _yline;
  8897. private _zline;
  8898. private _xmesh;
  8899. private _ymesh;
  8900. private _zmesh;
  8901. /**
  8902. * Gets the hosting scene
  8903. */
  8904. scene: Nullable<Scene>;
  8905. /**
  8906. * Gets or sets a number used to scale line length
  8907. */
  8908. scaleLines: number;
  8909. /**
  8910. * Creates a new AxesViewer
  8911. * @param scene defines the hosting scene
  8912. * @param scaleLines defines a number used to scale line length (1 by default)
  8913. */
  8914. constructor(scene: Scene, scaleLines?: number);
  8915. /**
  8916. * Force the viewer to update
  8917. * @param position defines the position of the viewer
  8918. * @param xaxis defines the x axis of the viewer
  8919. * @param yaxis defines the y axis of the viewer
  8920. * @param zaxis defines the z axis of the viewer
  8921. */
  8922. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8923. /** Releases resources */
  8924. dispose(): void;
  8925. }
  8926. }
  8927. declare module BABYLON.Debug {
  8928. /**
  8929. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8930. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8931. */
  8932. class BoneAxesViewer extends AxesViewer {
  8933. /**
  8934. * Gets or sets the target mesh where to display the axes viewer
  8935. */
  8936. mesh: Nullable<Mesh>;
  8937. /**
  8938. * Gets or sets the target bone where to display the axes viewer
  8939. */
  8940. bone: Nullable<Bone>;
  8941. /** Gets current position */
  8942. pos: Vector3;
  8943. /** Gets direction of X axis */
  8944. xaxis: Vector3;
  8945. /** Gets direction of Y axis */
  8946. yaxis: Vector3;
  8947. /** Gets direction of Z axis */
  8948. zaxis: Vector3;
  8949. /**
  8950. * Creates a new BoneAxesViewer
  8951. * @param scene defines the hosting scene
  8952. * @param bone defines the target bone
  8953. * @param mesh defines the target mesh
  8954. * @param scaleLines defines a scaling factor for line length (1 by default)
  8955. */
  8956. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8957. /**
  8958. * Force the viewer to update
  8959. */
  8960. update(): void;
  8961. /** Releases resources */
  8962. dispose(): void;
  8963. }
  8964. }
  8965. declare module BABYLON {
  8966. class DebugLayer {
  8967. private _scene;
  8968. static InspectorURL: string;
  8969. private _inspector;
  8970. private BJSINSPECTOR;
  8971. constructor(scene: Scene);
  8972. /** Creates the inspector window. */
  8973. private _createInspector(config?);
  8974. isVisible(): boolean;
  8975. hide(): void;
  8976. show(config?: {
  8977. popup?: boolean;
  8978. initialTab?: number;
  8979. parentElement?: HTMLElement;
  8980. newColors?: {
  8981. backgroundColor?: string;
  8982. backgroundColorLighter?: string;
  8983. backgroundColorLighter2?: string;
  8984. backgroundColorLighter3?: string;
  8985. color?: string;
  8986. colorTop?: string;
  8987. colorBot?: string;
  8988. };
  8989. }): void;
  8990. /**
  8991. * Gets the active tab
  8992. * @return the index of the active tab or -1 if the inspector is hidden
  8993. */
  8994. getActiveTab(): number;
  8995. }
  8996. }
  8997. declare module BABYLON.Debug {
  8998. /**
  8999. * Used to show the physics impostor around the specific mesh
  9000. */
  9001. class PhysicsViewer {
  9002. /** @hidden */
  9003. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9004. /** @hidden */
  9005. protected _meshes: Array<Nullable<AbstractMesh>>;
  9006. /** @hidden */
  9007. protected _scene: Nullable<Scene>;
  9008. /** @hidden */
  9009. protected _numMeshes: number;
  9010. /** @hidden */
  9011. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9012. private _renderFunction;
  9013. private _debugBoxMesh;
  9014. private _debugSphereMesh;
  9015. private _debugMaterial;
  9016. /**
  9017. * Creates a new PhysicsViewer
  9018. * @param scene defines the hosting scene
  9019. */
  9020. constructor(scene: Scene);
  9021. /** @hidden */
  9022. protected _updateDebugMeshes(): void;
  9023. /**
  9024. * Renders a specified physic impostor
  9025. * @param impostor defines the impostor to render
  9026. */
  9027. showImpostor(impostor: PhysicsImpostor): void;
  9028. /**
  9029. * Hides a specified physic impostor
  9030. * @param impostor defines the impostor to hide
  9031. */
  9032. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9033. private _getDebugMaterial(scene);
  9034. private _getDebugBoxMesh(scene);
  9035. private _getDebugSphereMesh(scene);
  9036. private _getDebugMesh(impostor, scene);
  9037. /** Releases all resources */
  9038. dispose(): void;
  9039. }
  9040. }
  9041. declare module BABYLON {
  9042. class RayHelper {
  9043. ray: Nullable<Ray>;
  9044. private _renderPoints;
  9045. private _renderLine;
  9046. private _renderFunction;
  9047. private _scene;
  9048. private _updateToMeshFunction;
  9049. private _attachedToMesh;
  9050. private _meshSpaceDirection;
  9051. private _meshSpaceOrigin;
  9052. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9053. constructor(ray: Ray);
  9054. show(scene: Scene, color: Color3): void;
  9055. hide(): void;
  9056. private _render();
  9057. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9058. detachFromMesh(): void;
  9059. private _updateToMesh();
  9060. dispose(): void;
  9061. }
  9062. }
  9063. declare module BABYLON.Debug {
  9064. /**
  9065. * Class used to render a debug view of a given skeleton
  9066. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9067. */
  9068. class SkeletonViewer {
  9069. /** defines the skeleton to render */
  9070. skeleton: Skeleton;
  9071. /** defines the mesh attached to the skeleton */
  9072. mesh: AbstractMesh;
  9073. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9074. autoUpdateBonesMatrices: boolean;
  9075. /** defines the rendering group id to use with the viewer */
  9076. renderingGroupId: number;
  9077. /** Gets or sets the color used to render the skeleton */
  9078. color: Color3;
  9079. private _scene;
  9080. private _debugLines;
  9081. private _debugMesh;
  9082. private _isEnabled;
  9083. private _renderFunction;
  9084. /**
  9085. * Creates a new SkeletonViewer
  9086. * @param skeleton defines the skeleton to render
  9087. * @param mesh defines the mesh attached to the skeleton
  9088. * @param scene defines the hosting scene
  9089. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9090. * @param renderingGroupId defines the rendering group id to use with the viewer
  9091. */
  9092. constructor(
  9093. /** defines the skeleton to render */
  9094. skeleton: Skeleton,
  9095. /** defines the mesh attached to the skeleton */
  9096. mesh: AbstractMesh, scene: Scene,
  9097. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9098. autoUpdateBonesMatrices?: boolean,
  9099. /** defines the rendering group id to use with the viewer */
  9100. renderingGroupId?: number);
  9101. /** Gets or sets a boolean indicating if the viewer is enabled */
  9102. isEnabled: boolean;
  9103. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  9104. private _getLinesForBonesWithLength(bones, meshMat);
  9105. private _getLinesForBonesNoLength(bones, meshMat);
  9106. /** Update the viewer to sync with current skeleton state */
  9107. update(): void;
  9108. /** Release associated resources */
  9109. dispose(): void;
  9110. }
  9111. }
  9112. declare module BABYLON {
  9113. class StickValues {
  9114. x: number;
  9115. y: number;
  9116. constructor(x: number, y: number);
  9117. }
  9118. interface GamepadButtonChanges {
  9119. changed: boolean;
  9120. pressChanged: boolean;
  9121. touchChanged: boolean;
  9122. valueChanged: boolean;
  9123. }
  9124. class Gamepad {
  9125. id: string;
  9126. index: number;
  9127. browserGamepad: any;
  9128. type: number;
  9129. private _leftStick;
  9130. private _rightStick;
  9131. private _leftStickAxisX;
  9132. private _leftStickAxisY;
  9133. private _rightStickAxisX;
  9134. private _rightStickAxisY;
  9135. private _onleftstickchanged;
  9136. private _onrightstickchanged;
  9137. static GAMEPAD: number;
  9138. static GENERIC: number;
  9139. static XBOX: number;
  9140. static POSE_ENABLED: number;
  9141. protected _invertLeftStickY: boolean;
  9142. readonly isConnected: boolean;
  9143. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9144. onleftstickchanged(callback: (values: StickValues) => void): void;
  9145. onrightstickchanged(callback: (values: StickValues) => void): void;
  9146. leftStick: StickValues;
  9147. rightStick: StickValues;
  9148. update(): void;
  9149. dispose(): void;
  9150. }
  9151. class GenericPad extends Gamepad {
  9152. private _buttons;
  9153. private _onbuttondown;
  9154. private _onbuttonup;
  9155. onButtonDownObservable: Observable<number>;
  9156. onButtonUpObservable: Observable<number>;
  9157. onbuttondown(callback: (buttonPressed: number) => void): void;
  9158. onbuttonup(callback: (buttonReleased: number) => void): void;
  9159. constructor(id: string, index: number, browserGamepad: any);
  9160. private _setButtonValue(newValue, currentValue, buttonIndex);
  9161. update(): void;
  9162. dispose(): void;
  9163. }
  9164. }
  9165. declare module BABYLON {
  9166. class GamepadManager {
  9167. private _scene;
  9168. private _babylonGamepads;
  9169. private _oneGamepadConnected;
  9170. private _gamepadEventSupported;
  9171. private _gamepadSupport;
  9172. onGamepadConnectedObservable: Observable<Gamepad>;
  9173. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9174. private _onGamepadConnectedEvent;
  9175. private _onGamepadDisconnectedEvent;
  9176. constructor(_scene?: Scene | undefined);
  9177. readonly gamepads: Gamepad[];
  9178. getGamepadByType(type?: number): Nullable<Gamepad>;
  9179. dispose(): void;
  9180. private _addNewGamepad(gamepad);
  9181. private _startMonitoringGamepads();
  9182. private _stopMonitoringGamepads();
  9183. private _updateGamepadObjects();
  9184. }
  9185. }
  9186. declare module BABYLON {
  9187. /**
  9188. * Defines supported buttons for XBox360 compatible gamepads
  9189. */
  9190. enum Xbox360Button {
  9191. /** A */
  9192. A = 0,
  9193. /** B */
  9194. B = 1,
  9195. /** X */
  9196. X = 2,
  9197. /** Y */
  9198. Y = 3,
  9199. /** Start */
  9200. Start = 4,
  9201. /** Back */
  9202. Back = 5,
  9203. /** Left button */
  9204. LB = 6,
  9205. /** Right button */
  9206. RB = 7,
  9207. /** Left stick */
  9208. LeftStick = 8,
  9209. /** Right stick */
  9210. RightStick = 9,
  9211. }
  9212. /** Defines values for XBox360 DPad */
  9213. enum Xbox360Dpad {
  9214. /** Up */
  9215. Up = 0,
  9216. /** Down */
  9217. Down = 1,
  9218. /** Left */
  9219. Left = 2,
  9220. /** Right */
  9221. Right = 3,
  9222. }
  9223. /**
  9224. * Defines a XBox360 gamepad
  9225. */
  9226. class Xbox360Pad extends Gamepad {
  9227. private _leftTrigger;
  9228. private _rightTrigger;
  9229. private _onlefttriggerchanged;
  9230. private _onrighttriggerchanged;
  9231. private _onbuttondown;
  9232. private _onbuttonup;
  9233. private _ondpaddown;
  9234. private _ondpadup;
  9235. /** Observable raised when a button is pressed */
  9236. onButtonDownObservable: Observable<Xbox360Button>;
  9237. /** Observable raised when a button is released */
  9238. onButtonUpObservable: Observable<Xbox360Button>;
  9239. /** Observable raised when a pad is pressed */
  9240. onPadDownObservable: Observable<Xbox360Dpad>;
  9241. /** Observable raised when a pad is released */
  9242. onPadUpObservable: Observable<Xbox360Dpad>;
  9243. private _buttonA;
  9244. private _buttonB;
  9245. private _buttonX;
  9246. private _buttonY;
  9247. private _buttonBack;
  9248. private _buttonStart;
  9249. private _buttonLB;
  9250. private _buttonRB;
  9251. private _buttonLeftStick;
  9252. private _buttonRightStick;
  9253. private _dPadUp;
  9254. private _dPadDown;
  9255. private _dPadLeft;
  9256. private _dPadRight;
  9257. private _isXboxOnePad;
  9258. /**
  9259. * Creates a new XBox360 gamepad object
  9260. * @param id defines the id of this gamepad
  9261. * @param index defines its index
  9262. * @param gamepad defines the internal HTML gamepad object
  9263. * @param xboxOne defines if it is a XBox One gamepad
  9264. */
  9265. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9266. /**
  9267. * Defines the callback to call when left trigger is pressed
  9268. * @param callback defines the callback to use
  9269. */
  9270. onlefttriggerchanged(callback: (value: number) => void): void;
  9271. /**
  9272. * Defines the callback to call when right trigger is pressed
  9273. * @param callback defines the callback to use
  9274. */
  9275. onrighttriggerchanged(callback: (value: number) => void): void;
  9276. /**
  9277. * Gets or sets left trigger value
  9278. */
  9279. leftTrigger: number;
  9280. /**
  9281. * Gets or sets right trigger value
  9282. */
  9283. rightTrigger: number;
  9284. /**
  9285. * Defines the callback to call when a button is pressed
  9286. * @param callback defines the callback to use
  9287. */
  9288. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9289. /**
  9290. * Defines the callback to call when a button is released
  9291. * @param callback defines the callback to use
  9292. */
  9293. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9294. /**
  9295. * Defines the callback to call when a pad is pressed
  9296. * @param callback defines the callback to use
  9297. */
  9298. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9299. /**
  9300. * Defines the callback to call when a pad is released
  9301. * @param callback defines the callback to use
  9302. */
  9303. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9304. private _setButtonValue(newValue, currentValue, buttonType);
  9305. private _setDPadValue(newValue, currentValue, buttonType);
  9306. /** Gets or sets value of A button */
  9307. buttonA: number;
  9308. /** Gets or sets value of B button */
  9309. buttonB: number;
  9310. /** Gets or sets value of X button */
  9311. buttonX: number;
  9312. /** Gets or sets value of Y button */
  9313. buttonY: number;
  9314. /** Gets or sets value of Start button */
  9315. buttonStart: number;
  9316. /** Gets or sets value of Back button */
  9317. buttonBack: number;
  9318. /** Gets or sets value of Left button */
  9319. buttonLB: number;
  9320. /** Gets or sets value of Right button */
  9321. buttonRB: number;
  9322. /** Gets or sets value of left stick */
  9323. buttonLeftStick: number;
  9324. /** Gets or sets value of right stick */
  9325. buttonRightStick: number;
  9326. /** Gets or sets value of DPad up */
  9327. dPadUp: number;
  9328. /** Gets or sets value of DPad down */
  9329. dPadDown: number;
  9330. /** Gets or sets value of DPad left */
  9331. dPadLeft: number;
  9332. /** Gets or sets value of DPad right */
  9333. dPadRight: number;
  9334. /**
  9335. * Force the gamepad to synchronize with device values
  9336. */
  9337. update(): void;
  9338. dispose(): void;
  9339. }
  9340. }
  9341. declare module BABYLON {
  9342. /**
  9343. * Single axis drag gizmo
  9344. */
  9345. class AxisDragGizmo extends Gizmo {
  9346. private _dragBehavior;
  9347. /**
  9348. * Creates an AxisDragGizmo
  9349. * @param gizmoLayer The utility layer the gizmo will be added to
  9350. * @param dragAxis The axis which the gizmo will be able to drag on
  9351. * @param color The color of the gizmo
  9352. */
  9353. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9354. protected _onInteractionsEnabledChanged(value: boolean): void;
  9355. /**
  9356. * Disposes of the gizmo
  9357. */
  9358. dispose(): void;
  9359. }
  9360. }
  9361. declare module BABYLON {
  9362. /**
  9363. * Single axis scale gizmo
  9364. */
  9365. class AxisScaleGizmo extends Gizmo {
  9366. private _dragBehavior;
  9367. /**
  9368. * Creates an AxisScaleGizmo
  9369. * @param gizmoLayer The utility layer the gizmo will be added to
  9370. * @param dragAxis The axis which the gizmo will be able to scale on
  9371. * @param color The color of the gizmo
  9372. */
  9373. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9374. protected _onInteractionsEnabledChanged(value: boolean): void;
  9375. /**
  9376. * Disposes of the gizmo
  9377. */
  9378. dispose(): void;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9384. */
  9385. class Gizmo implements IDisposable {
  9386. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9387. /**
  9388. * The root mesh of the gizmo
  9389. */
  9390. protected _rootMesh: Mesh;
  9391. /**
  9392. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9393. */
  9394. attachedMesh: Nullable<AbstractMesh>;
  9395. protected _interactionsEnabled: boolean;
  9396. protected _onInteractionsEnabledChanged(value: boolean): void;
  9397. /**
  9398. * If interactions are enabled with this gizmo. (eg. dragging/rotation)
  9399. */
  9400. interactionsEnabled: boolean;
  9401. private _beforeRenderObserver;
  9402. /**
  9403. * Creates a gizmo
  9404. * @param gizmoLayer The utility layer the gizmo will be added to
  9405. */
  9406. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9407. /**
  9408. * Disposes of the gizmo
  9409. */
  9410. dispose(): void;
  9411. }
  9412. }
  9413. declare module BABYLON {
  9414. /**
  9415. * Single plane rotation gizmo
  9416. */
  9417. class PlaneRotationGizmo extends Gizmo {
  9418. private _dragBehavior;
  9419. /**
  9420. * Creates a PlaneRotationGizmo
  9421. * @param gizmoLayer The utility layer the gizmo will be added to
  9422. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9423. * @param color The color of the gizmo
  9424. */
  9425. constructor(gizmoLayer: UtilityLayerRenderer, planeNormal: Vector3, color: Color3);
  9426. protected _onInteractionsEnabledChanged(value: boolean): void;
  9427. /**
  9428. * Disposes of the gizmo
  9429. */
  9430. dispose(): void;
  9431. }
  9432. }
  9433. declare module BABYLON {
  9434. /**
  9435. * Gizmo that enables dragging a mesh along 3 axis
  9436. */
  9437. class PositionGizmo extends Gizmo {
  9438. private _xDrag;
  9439. private _yDrag;
  9440. private _zDrag;
  9441. attachedMesh: Nullable<AbstractMesh>;
  9442. /**
  9443. * Creates a PositionGizmo
  9444. * @param gizmoLayer The utility layer the gizmo will be added to
  9445. */
  9446. constructor(gizmoLayer: UtilityLayerRenderer);
  9447. protected _onInteractionsEnabledChanged(value: boolean): void;
  9448. /**
  9449. * Disposes of the gizmo
  9450. */
  9451. dispose(): void;
  9452. }
  9453. }
  9454. declare module BABYLON {
  9455. /**
  9456. * Gizmo that enables rotating a mesh along 3 axis
  9457. */
  9458. class RotationGizmo extends Gizmo {
  9459. private _xDrag;
  9460. private _yDrag;
  9461. private _zDrag;
  9462. attachedMesh: Nullable<AbstractMesh>;
  9463. /**
  9464. * Creates a RotationGizmo
  9465. * @param gizmoLayer The utility layer the gizmo will be added to
  9466. */
  9467. constructor(gizmoLayer: UtilityLayerRenderer);
  9468. protected _onInteractionsEnabledChanged(value: boolean): void;
  9469. /**
  9470. * Disposes of the gizmo
  9471. */
  9472. dispose(): void;
  9473. }
  9474. }
  9475. declare module BABYLON {
  9476. /**
  9477. * Gizmo that enables scaling a mesh along 3 axis
  9478. */
  9479. class ScaleGizmo extends Gizmo {
  9480. private _xDrag;
  9481. private _yDrag;
  9482. private _zDrag;
  9483. attachedMesh: Nullable<AbstractMesh>;
  9484. /**
  9485. * Creates a ScaleGizmo
  9486. * @param gizmoLayer The utility layer the gizmo will be added to
  9487. */
  9488. constructor(gizmoLayer: UtilityLayerRenderer);
  9489. protected _onInteractionsEnabledChanged(value: boolean): void;
  9490. /**
  9491. * Disposes of the gizmo
  9492. */
  9493. dispose(): void;
  9494. }
  9495. }
  9496. declare module BABYLON {
  9497. /**
  9498. * Represents the different options available during the creation of
  9499. * a Environment helper.
  9500. *
  9501. * This can control the default ground, skybox and image processing setup of your scene.
  9502. */
  9503. interface IEnvironmentHelperOptions {
  9504. /**
  9505. * Specifies wether or not to create a ground.
  9506. * True by default.
  9507. */
  9508. createGround: boolean;
  9509. /**
  9510. * Specifies the ground size.
  9511. * 15 by default.
  9512. */
  9513. groundSize: number;
  9514. /**
  9515. * The texture used on the ground for the main color.
  9516. * Comes from the BabylonJS CDN by default.
  9517. *
  9518. * Remarks: Can be either a texture or a url.
  9519. */
  9520. groundTexture: string | BaseTexture;
  9521. /**
  9522. * The color mixed in the ground texture by default.
  9523. * BabylonJS clearColor by default.
  9524. */
  9525. groundColor: Color3;
  9526. /**
  9527. * Specifies the ground opacity.
  9528. * 1 by default.
  9529. */
  9530. groundOpacity: number;
  9531. /**
  9532. * Enables the ground to receive shadows.
  9533. * True by default.
  9534. */
  9535. enableGroundShadow: boolean;
  9536. /**
  9537. * Helps preventing the shadow to be fully black on the ground.
  9538. * 0.5 by default.
  9539. */
  9540. groundShadowLevel: number;
  9541. /**
  9542. * Creates a mirror texture attach to the ground.
  9543. * false by default.
  9544. */
  9545. enableGroundMirror: boolean;
  9546. /**
  9547. * Specifies the ground mirror size ratio.
  9548. * 0.3 by default as the default kernel is 64.
  9549. */
  9550. groundMirrorSizeRatio: number;
  9551. /**
  9552. * Specifies the ground mirror blur kernel size.
  9553. * 64 by default.
  9554. */
  9555. groundMirrorBlurKernel: number;
  9556. /**
  9557. * Specifies the ground mirror visibility amount.
  9558. * 1 by default
  9559. */
  9560. groundMirrorAmount: number;
  9561. /**
  9562. * Specifies the ground mirror reflectance weight.
  9563. * This uses the standard weight of the background material to setup the fresnel effect
  9564. * of the mirror.
  9565. * 1 by default.
  9566. */
  9567. groundMirrorFresnelWeight: number;
  9568. /**
  9569. * Specifies the ground mirror Falloff distance.
  9570. * This can helps reducing the size of the reflection.
  9571. * 0 by Default.
  9572. */
  9573. groundMirrorFallOffDistance: number;
  9574. /**
  9575. * Specifies the ground mirror texture type.
  9576. * Unsigned Int by Default.
  9577. */
  9578. groundMirrorTextureType: number;
  9579. /**
  9580. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9581. * the shown objects.
  9582. */
  9583. groundYBias: number;
  9584. /**
  9585. * Specifies wether or not to create a skybox.
  9586. * True by default.
  9587. */
  9588. createSkybox: boolean;
  9589. /**
  9590. * Specifies the skybox size.
  9591. * 20 by default.
  9592. */
  9593. skyboxSize: number;
  9594. /**
  9595. * The texture used on the skybox for the main color.
  9596. * Comes from the BabylonJS CDN by default.
  9597. *
  9598. * Remarks: Can be either a texture or a url.
  9599. */
  9600. skyboxTexture: string | BaseTexture;
  9601. /**
  9602. * The color mixed in the skybox texture by default.
  9603. * BabylonJS clearColor by default.
  9604. */
  9605. skyboxColor: Color3;
  9606. /**
  9607. * The background rotation around the Y axis of the scene.
  9608. * This helps aligning the key lights of your scene with the background.
  9609. * 0 by default.
  9610. */
  9611. backgroundYRotation: number;
  9612. /**
  9613. * Compute automatically the size of the elements to best fit with the scene.
  9614. */
  9615. sizeAuto: boolean;
  9616. /**
  9617. * Default position of the rootMesh if autoSize is not true.
  9618. */
  9619. rootPosition: Vector3;
  9620. /**
  9621. * Sets up the image processing in the scene.
  9622. * true by default.
  9623. */
  9624. setupImageProcessing: boolean;
  9625. /**
  9626. * The texture used as your environment texture in the scene.
  9627. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9628. *
  9629. * Remarks: Can be either a texture or a url.
  9630. */
  9631. environmentTexture: string | BaseTexture;
  9632. /**
  9633. * The value of the exposure to apply to the scene.
  9634. * 0.6 by default if setupImageProcessing is true.
  9635. */
  9636. cameraExposure: number;
  9637. /**
  9638. * The value of the contrast to apply to the scene.
  9639. * 1.6 by default if setupImageProcessing is true.
  9640. */
  9641. cameraContrast: number;
  9642. /**
  9643. * Specifies wether or not tonemapping should be enabled in the scene.
  9644. * true by default if setupImageProcessing is true.
  9645. */
  9646. toneMappingEnabled: boolean;
  9647. }
  9648. /**
  9649. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9650. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9651. * It also helps with the default setup of your imageProcessing configuration.
  9652. */
  9653. class EnvironmentHelper {
  9654. /**
  9655. * Default ground texture URL.
  9656. */
  9657. private static _groundTextureCDNUrl;
  9658. /**
  9659. * Default skybox texture URL.
  9660. */
  9661. private static _skyboxTextureCDNUrl;
  9662. /**
  9663. * Default environment texture URL.
  9664. */
  9665. private static _environmentTextureCDNUrl;
  9666. /**
  9667. * Creates the default options for the helper.
  9668. */
  9669. private static _getDefaultOptions();
  9670. private _rootMesh;
  9671. /**
  9672. * Gets the root mesh created by the helper.
  9673. */
  9674. readonly rootMesh: Mesh;
  9675. private _skybox;
  9676. /**
  9677. * Gets the skybox created by the helper.
  9678. */
  9679. readonly skybox: Nullable<Mesh>;
  9680. private _skyboxTexture;
  9681. /**
  9682. * Gets the skybox texture created by the helper.
  9683. */
  9684. readonly skyboxTexture: Nullable<BaseTexture>;
  9685. private _skyboxMaterial;
  9686. /**
  9687. * Gets the skybox material created by the helper.
  9688. */
  9689. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9690. private _ground;
  9691. /**
  9692. * Gets the ground mesh created by the helper.
  9693. */
  9694. readonly ground: Nullable<Mesh>;
  9695. private _groundTexture;
  9696. /**
  9697. * Gets the ground texture created by the helper.
  9698. */
  9699. readonly groundTexture: Nullable<BaseTexture>;
  9700. private _groundMirror;
  9701. /**
  9702. * Gets the ground mirror created by the helper.
  9703. */
  9704. readonly groundMirror: Nullable<MirrorTexture>;
  9705. /**
  9706. * Gets the ground mirror render list to helps pushing the meshes
  9707. * you wish in the ground reflection.
  9708. */
  9709. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9710. private _groundMaterial;
  9711. /**
  9712. * Gets the ground material created by the helper.
  9713. */
  9714. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9715. /**
  9716. * Stores the creation options.
  9717. */
  9718. private readonly _scene;
  9719. private _options;
  9720. /**
  9721. * This observable will be notified with any error during the creation of the environment,
  9722. * mainly texture creation errors.
  9723. */
  9724. onErrorObservable: Observable<{
  9725. message?: string;
  9726. exception?: any;
  9727. }>;
  9728. /**
  9729. * constructor
  9730. * @param options
  9731. * @param scene The scene to add the material to
  9732. */
  9733. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9734. /**
  9735. * Updates the background according to the new options
  9736. * @param options
  9737. */
  9738. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9739. /**
  9740. * Sets the primary color of all the available elements.
  9741. * @param color the main color to affect to the ground and the background
  9742. */
  9743. setMainColor(color: Color3): void;
  9744. /**
  9745. * Setup the image processing according to the specified options.
  9746. */
  9747. private _setupImageProcessing();
  9748. /**
  9749. * Setup the environment texture according to the specified options.
  9750. */
  9751. private _setupEnvironmentTexture();
  9752. /**
  9753. * Setup the background according to the specified options.
  9754. */
  9755. private _setupBackground();
  9756. /**
  9757. * Get the scene sizes according to the setup.
  9758. */
  9759. private _getSceneSize();
  9760. /**
  9761. * Setup the ground according to the specified options.
  9762. */
  9763. private _setupGround(sceneSize);
  9764. /**
  9765. * Setup the ground material according to the specified options.
  9766. */
  9767. private _setupGroundMaterial();
  9768. /**
  9769. * Setup the ground diffuse texture according to the specified options.
  9770. */
  9771. private _setupGroundDiffuseTexture();
  9772. /**
  9773. * Setup the ground mirror texture according to the specified options.
  9774. */
  9775. private _setupGroundMirrorTexture(sceneSize);
  9776. /**
  9777. * Setup the ground to receive the mirror texture.
  9778. */
  9779. private _setupMirrorInGroundMaterial();
  9780. /**
  9781. * Setup the skybox according to the specified options.
  9782. */
  9783. private _setupSkybox(sceneSize);
  9784. /**
  9785. * Setup the skybox material according to the specified options.
  9786. */
  9787. private _setupSkyboxMaterial();
  9788. /**
  9789. * Setup the skybox reflection texture according to the specified options.
  9790. */
  9791. private _setupSkyboxReflectionTexture();
  9792. private _errorHandler;
  9793. /**
  9794. * Dispose all the elements created by the Helper.
  9795. */
  9796. dispose(): void;
  9797. }
  9798. }
  9799. declare module BABYLON {
  9800. /**
  9801. * Represents all the data needed to create a ParticleSystem.
  9802. */
  9803. interface IParticleSystemData {
  9804. /**
  9805. * ParticleSystem type
  9806. */
  9807. type: string;
  9808. /**
  9809. * Shape of the emitter
  9810. */
  9811. emitterType: string;
  9812. /**
  9813. * Maximum number of particles in the system
  9814. */
  9815. capacity: number;
  9816. /**
  9817. * Link for the texture file
  9818. */
  9819. textureFile: string;
  9820. /**
  9821. * minEmitBox Vector3
  9822. */
  9823. minEmitBox?: {
  9824. x: number;
  9825. y: number;
  9826. z: number;
  9827. };
  9828. /**
  9829. * maxEmitBox Vector3
  9830. */
  9831. maxEmitBox?: {
  9832. x: number;
  9833. y: number;
  9834. z: number;
  9835. };
  9836. /**
  9837. * color1 Color4
  9838. */
  9839. color1: {
  9840. r: number;
  9841. g: number;
  9842. b: number;
  9843. a: number;
  9844. };
  9845. /**
  9846. * color2 Color4
  9847. */
  9848. color2: {
  9849. r: number;
  9850. g: number;
  9851. b: number;
  9852. a: number;
  9853. };
  9854. /**
  9855. * colorDead Color4
  9856. */
  9857. colorDead: {
  9858. r: number;
  9859. g: number;
  9860. b: number;
  9861. a: number;
  9862. };
  9863. /**
  9864. * Minimum size of each particle
  9865. */
  9866. minSize: number;
  9867. /**
  9868. * Maximum size of each particle
  9869. */
  9870. maxSize: number;
  9871. /**
  9872. * Minimum lifetime for each particle
  9873. */
  9874. minLifeTime: number;
  9875. /**
  9876. * Maximum lifetime for each particle
  9877. */
  9878. maxLifeTime: number;
  9879. /**
  9880. * Emit rate
  9881. */
  9882. emitRate: number;
  9883. /**
  9884. * Blend Mode
  9885. */
  9886. blendMode: number;
  9887. /**
  9888. * gravity Vector3
  9889. */
  9890. gravity: {
  9891. x: number;
  9892. y: number;
  9893. z: number;
  9894. };
  9895. /**
  9896. * direction1 Vector3
  9897. */
  9898. direction1?: {
  9899. x: number;
  9900. y: number;
  9901. z: number;
  9902. };
  9903. /**
  9904. * direction2 Vector3
  9905. */
  9906. direction2?: {
  9907. x: number;
  9908. y: number;
  9909. z: number;
  9910. };
  9911. /**
  9912. * Minimum Angular Speed
  9913. */
  9914. minAngularSpeed: number;
  9915. /**
  9916. * Maximum Angular Speed
  9917. */
  9918. maxAngularSpeed: number;
  9919. /**
  9920. * Minimum Emit Power
  9921. */
  9922. minEmitPower: number;
  9923. /**
  9924. * Maximum Emit Power
  9925. */
  9926. maxEmitPower: number;
  9927. /**
  9928. * Update Speed
  9929. */
  9930. updateSpeed: number;
  9931. /**
  9932. * Radius
  9933. */
  9934. radius?: number;
  9935. /**
  9936. * Angle
  9937. */
  9938. angle?: number;
  9939. }
  9940. /**
  9941. * This class is made for on one-liner static method to help creating particle systems.
  9942. */
  9943. class ParticleHelper {
  9944. /**
  9945. * Base Assets URL.
  9946. */
  9947. private static _baseAssetsUrl;
  9948. private static _scene;
  9949. private static _emitter;
  9950. /**
  9951. * This is the main static method (one-liner) of this helper to create different particle systems.
  9952. * @param type This string represents the type to the particle system to create
  9953. * @param emitter The object where the particle system will start to emit from.
  9954. * @param scene The scene where the particle system should live.
  9955. * @param gpu If the system will use gpu.
  9956. * @returns the ParticleSystem created.
  9957. */
  9958. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  9959. private static _createSystem(data);
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9965. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9966. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9967. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9968. */
  9969. class VideoDome extends Node {
  9970. /**
  9971. * The video texture being displayed on the sphere
  9972. */
  9973. protected _videoTexture: VideoTexture;
  9974. /**
  9975. * The skybox material
  9976. */
  9977. protected _material: BackgroundMaterial;
  9978. /**
  9979. * The surface used for the skybox
  9980. */
  9981. protected _mesh: Mesh;
  9982. /**
  9983. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9984. * Also see the options.resolution property.
  9985. */
  9986. fovMultiplier: number;
  9987. /**
  9988. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9989. * @param name Element's name, child elements will append suffixes for their own names.
  9990. * @param urlsOrVideo
  9991. * @param options An object containing optional or exposed sub element properties:
  9992. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9993. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9994. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9995. * @param options **loop=true** Automatically loop video on end.
  9996. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9997. */
  9998. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9999. resolution?: number;
  10000. clickToPlay?: boolean;
  10001. autoPlay?: boolean;
  10002. loop?: boolean;
  10003. size?: number;
  10004. }, scene: Scene);
  10005. /**
  10006. * Releases resources associated with this node.
  10007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10009. */
  10010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10011. }
  10012. }
  10013. declare module BABYLON {
  10014. /**
  10015. * This class can be used to get instrumentation data from a Babylon engine
  10016. */
  10017. class EngineInstrumentation implements IDisposable {
  10018. engine: Engine;
  10019. private _captureGPUFrameTime;
  10020. private _gpuFrameTimeToken;
  10021. private _gpuFrameTime;
  10022. private _captureShaderCompilationTime;
  10023. private _shaderCompilationTime;
  10024. private _onBeginFrameObserver;
  10025. private _onEndFrameObserver;
  10026. private _onBeforeShaderCompilationObserver;
  10027. private _onAfterShaderCompilationObserver;
  10028. /**
  10029. * Gets the perf counter used for GPU frame time
  10030. */
  10031. readonly gpuFrameTimeCounter: PerfCounter;
  10032. /**
  10033. * Gets the GPU frame time capture status
  10034. */
  10035. /**
  10036. * Enable or disable the GPU frame time capture
  10037. */
  10038. captureGPUFrameTime: boolean;
  10039. /**
  10040. * Gets the perf counter used for shader compilation time
  10041. */
  10042. readonly shaderCompilationTimeCounter: PerfCounter;
  10043. /**
  10044. * Gets the shader compilation time capture status
  10045. */
  10046. /**
  10047. * Enable or disable the shader compilation time capture
  10048. */
  10049. captureShaderCompilationTime: boolean;
  10050. constructor(engine: Engine);
  10051. dispose(): void;
  10052. }
  10053. }
  10054. declare module BABYLON {
  10055. /**
  10056. * This class can be used to get instrumentation data from a Babylon engine
  10057. */
  10058. class SceneInstrumentation implements IDisposable {
  10059. scene: Scene;
  10060. private _captureActiveMeshesEvaluationTime;
  10061. private _activeMeshesEvaluationTime;
  10062. private _captureRenderTargetsRenderTime;
  10063. private _renderTargetsRenderTime;
  10064. private _captureFrameTime;
  10065. private _frameTime;
  10066. private _captureRenderTime;
  10067. private _renderTime;
  10068. private _captureInterFrameTime;
  10069. private _interFrameTime;
  10070. private _captureParticlesRenderTime;
  10071. private _particlesRenderTime;
  10072. private _captureSpritesRenderTime;
  10073. private _spritesRenderTime;
  10074. private _capturePhysicsTime;
  10075. private _physicsTime;
  10076. private _captureAnimationsTime;
  10077. private _animationsTime;
  10078. private _onBeforeActiveMeshesEvaluationObserver;
  10079. private _onAfterActiveMeshesEvaluationObserver;
  10080. private _onBeforeRenderTargetsRenderObserver;
  10081. private _onAfterRenderTargetsRenderObserver;
  10082. private _onAfterRenderObserver;
  10083. private _onBeforeDrawPhaseObserver;
  10084. private _onAfterDrawPhaseObserver;
  10085. private _onBeforeAnimationsObserver;
  10086. private _onBeforeParticlesRenderingObserver;
  10087. private _onAfterParticlesRenderingObserver;
  10088. private _onBeforeSpritesRenderingObserver;
  10089. private _onAfterSpritesRenderingObserver;
  10090. private _onBeforePhysicsObserver;
  10091. private _onAfterPhysicsObserver;
  10092. private _onAfterAnimationsObserver;
  10093. /**
  10094. * Gets the perf counter used for active meshes evaluation time
  10095. */
  10096. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10097. /**
  10098. * Gets the active meshes evaluation time capture status
  10099. */
  10100. /**
  10101. * Enable or disable the active meshes evaluation time capture
  10102. */
  10103. captureActiveMeshesEvaluationTime: boolean;
  10104. /**
  10105. * Gets the perf counter used for render targets render time
  10106. */
  10107. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10108. /**
  10109. * Gets the render targets render time capture status
  10110. */
  10111. /**
  10112. * Enable or disable the render targets render time capture
  10113. */
  10114. captureRenderTargetsRenderTime: boolean;
  10115. /**
  10116. * Gets the perf counter used for particles render time
  10117. */
  10118. readonly particlesRenderTimeCounter: PerfCounter;
  10119. /**
  10120. * Gets the particles render time capture status
  10121. */
  10122. /**
  10123. * Enable or disable the particles render time capture
  10124. */
  10125. captureParticlesRenderTime: boolean;
  10126. /**
  10127. * Gets the perf counter used for sprites render time
  10128. */
  10129. readonly spritesRenderTimeCounter: PerfCounter;
  10130. /**
  10131. * Gets the sprites render time capture status
  10132. */
  10133. /**
  10134. * Enable or disable the sprites render time capture
  10135. */
  10136. captureSpritesRenderTime: boolean;
  10137. /**
  10138. * Gets the perf counter used for physics time
  10139. */
  10140. readonly physicsTimeCounter: PerfCounter;
  10141. /**
  10142. * Gets the physics time capture status
  10143. */
  10144. /**
  10145. * Enable or disable the physics time capture
  10146. */
  10147. capturePhysicsTime: boolean;
  10148. /**
  10149. * Gets the perf counter used for animations time
  10150. */
  10151. readonly animationsTimeCounter: PerfCounter;
  10152. /**
  10153. * Gets the animations time capture status
  10154. */
  10155. /**
  10156. * Enable or disable the animations time capture
  10157. */
  10158. captureAnimationsTime: boolean;
  10159. /**
  10160. * Gets the perf counter used for frame time capture
  10161. */
  10162. readonly frameTimeCounter: PerfCounter;
  10163. /**
  10164. * Gets the frame time capture status
  10165. */
  10166. /**
  10167. * Enable or disable the frame time capture
  10168. */
  10169. captureFrameTime: boolean;
  10170. /**
  10171. * Gets the perf counter used for inter-frames time capture
  10172. */
  10173. readonly interFrameTimeCounter: PerfCounter;
  10174. /**
  10175. * Gets the inter-frames time capture status
  10176. */
  10177. /**
  10178. * Enable or disable the inter-frames time capture
  10179. */
  10180. captureInterFrameTime: boolean;
  10181. /**
  10182. * Gets the perf counter used for render time capture
  10183. */
  10184. readonly renderTimeCounter: PerfCounter;
  10185. /**
  10186. * Gets the render time capture status
  10187. */
  10188. /**
  10189. * Enable or disable the render time capture
  10190. */
  10191. captureRenderTime: boolean;
  10192. /**
  10193. * Gets the perf counter used for draw calls
  10194. */
  10195. readonly drawCallsCounter: PerfCounter;
  10196. /**
  10197. * Gets the perf counter used for texture collisions
  10198. */
  10199. readonly textureCollisionsCounter: PerfCounter;
  10200. constructor(scene: Scene);
  10201. dispose(): void;
  10202. }
  10203. }
  10204. declare module BABYLON {
  10205. /**
  10206. * @hidden
  10207. **/
  10208. class _TimeToken {
  10209. }
  10210. }
  10211. declare module BABYLON {
  10212. /**
  10213. * Effect layer options. This helps customizing the behaviour
  10214. * of the effect layer.
  10215. */
  10216. interface IEffectLayerOptions {
  10217. /**
  10218. * Multiplication factor apply to the canvas size to compute the render target size
  10219. * used to generated the objects (the smaller the faster).
  10220. */
  10221. mainTextureRatio: number;
  10222. /**
  10223. * Enforces a fixed size texture to ensure effect stability across devices.
  10224. */
  10225. mainTextureFixedSize?: number;
  10226. /**
  10227. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10228. */
  10229. alphaBlendingMode: number;
  10230. /**
  10231. * The camera attached to the layer.
  10232. */
  10233. camera: Nullable<Camera>;
  10234. }
  10235. /**
  10236. * The effect layer Helps adding post process effect blended with the main pass.
  10237. *
  10238. * This can be for instance use to generate glow or higlight effects on the scene.
  10239. *
  10240. * The effect layer class can not be used directly and is intented to inherited from to be
  10241. * customized per effects.
  10242. */
  10243. abstract class EffectLayer {
  10244. private _vertexBuffers;
  10245. private _indexBuffer;
  10246. private _cachedDefines;
  10247. private _effectLayerMapGenerationEffect;
  10248. private _effectLayerOptions;
  10249. private _mergeEffect;
  10250. protected _scene: Scene;
  10251. protected _engine: Engine;
  10252. protected _maxSize: number;
  10253. protected _mainTextureDesiredSize: ISize;
  10254. protected _mainTexture: RenderTargetTexture;
  10255. protected _shouldRender: boolean;
  10256. protected _postProcesses: PostProcess[];
  10257. protected _textures: BaseTexture[];
  10258. protected _emissiveTextureAndColor: {
  10259. texture: Nullable<BaseTexture>;
  10260. color: Color4;
  10261. };
  10262. /**
  10263. * The name of the layer
  10264. */
  10265. name: string;
  10266. /**
  10267. * The clear color of the texture used to generate the glow map.
  10268. */
  10269. neutralColor: Color4;
  10270. /**
  10271. * Specifies wether the highlight layer is enabled or not.
  10272. */
  10273. isEnabled: boolean;
  10274. /**
  10275. * Gets the camera attached to the layer.
  10276. */
  10277. readonly camera: Nullable<Camera>;
  10278. /**
  10279. * An event triggered when the effect layer has been disposed.
  10280. */
  10281. onDisposeObservable: Observable<EffectLayer>;
  10282. /**
  10283. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10284. */
  10285. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10286. /**
  10287. * An event triggered when the generated texture is being merged in the scene.
  10288. */
  10289. onBeforeComposeObservable: Observable<EffectLayer>;
  10290. /**
  10291. * An event triggered when the generated texture has been merged in the scene.
  10292. */
  10293. onAfterComposeObservable: Observable<EffectLayer>;
  10294. /**
  10295. * An event triggered when the efffect layer changes its size.
  10296. */
  10297. onSizeChangedObservable: Observable<EffectLayer>;
  10298. /**
  10299. * Instantiates a new effect Layer and references it in the scene.
  10300. * @param name The name of the layer
  10301. * @param scene The scene to use the layer in
  10302. */
  10303. constructor(
  10304. /** The Friendly of the effect in the scene */
  10305. name: string, scene: Scene);
  10306. /**
  10307. * Get the effect name of the layer.
  10308. * @return The effect name
  10309. */
  10310. abstract getEffectName(): string;
  10311. /**
  10312. * Checks for the readiness of the element composing the layer.
  10313. * @param subMesh the mesh to check for
  10314. * @param useInstances specify wether or not to use instances to render the mesh
  10315. * @return true if ready otherwise, false
  10316. */
  10317. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10318. /**
  10319. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10320. * @returns true if the effect requires stencil during the main canvas render pass.
  10321. */
  10322. abstract needStencil(): boolean;
  10323. /**
  10324. * Create the merge effect. This is the shader use to blit the information back
  10325. * to the main canvas at the end of the scene rendering.
  10326. * @returns The effect containing the shader used to merge the effect on the main canvas
  10327. */
  10328. protected abstract _createMergeEffect(): Effect;
  10329. /**
  10330. * Creates the render target textures and post processes used in the effect layer.
  10331. */
  10332. protected abstract _createTextureAndPostProcesses(): void;
  10333. /**
  10334. * Implementation specific of rendering the generating effect on the main canvas.
  10335. * @param effect The effect used to render through
  10336. */
  10337. protected abstract _internalRender(effect: Effect): void;
  10338. /**
  10339. * Sets the required values for both the emissive texture and and the main color.
  10340. */
  10341. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10342. /**
  10343. * Free any resources and references associated to a mesh.
  10344. * Internal use
  10345. * @param mesh The mesh to free.
  10346. */
  10347. disposeMesh(mesh: Mesh): void;
  10348. /**
  10349. * Serializes this layer (Glow or Highlight for example)
  10350. * @returns a serialized layer object
  10351. */
  10352. abstract serialize?(): any;
  10353. /**
  10354. * Initializes the effect layer with the required options.
  10355. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10356. */
  10357. protected _init(options: Partial<IEffectLayerOptions>): void;
  10358. /**
  10359. * Generates the index buffer of the full screen quad blending to the main canvas.
  10360. */
  10361. private _generateIndexBuffer();
  10362. /**
  10363. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10364. */
  10365. private _genrateVertexBuffer();
  10366. /**
  10367. * Sets the main texture desired size which is the closest power of two
  10368. * of the engine canvas size.
  10369. */
  10370. private _setMainTextureSize();
  10371. /**
  10372. * Creates the main texture for the effect layer.
  10373. */
  10374. protected _createMainTexture(): void;
  10375. /**
  10376. * Checks for the readiness of the element composing the layer.
  10377. * @param subMesh the mesh to check for
  10378. * @param useInstances specify wether or not to use instances to render the mesh
  10379. * @param emissiveTexture the associated emissive texture used to generate the glow
  10380. * @return true if ready otherwise, false
  10381. */
  10382. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10383. /**
  10384. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10385. */
  10386. render(): void;
  10387. /**
  10388. * Determine if a given mesh will be used in the current effect.
  10389. * @param mesh mesh to test
  10390. * @returns true if the mesh will be used
  10391. */
  10392. hasMesh(mesh: AbstractMesh): boolean;
  10393. /**
  10394. * Returns true if the layer contains information to display, otherwise false.
  10395. * @returns true if the glow layer should be rendered
  10396. */
  10397. shouldRender(): boolean;
  10398. /**
  10399. * Returns true if the mesh should render, otherwise false.
  10400. * @param mesh The mesh to render
  10401. * @returns true if it should render otherwise false
  10402. */
  10403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10404. /**
  10405. * Returns true if the mesh should render, otherwise false.
  10406. * @param mesh The mesh to render
  10407. * @returns true if it should render otherwise false
  10408. */
  10409. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10410. /**
  10411. * Renders the submesh passed in parameter to the generation map.
  10412. */
  10413. protected _renderSubMesh(subMesh: SubMesh): void;
  10414. /**
  10415. * Rebuild the required buffers.
  10416. * @hidden Internal use only.
  10417. */
  10418. /**
  10419. * Dispose only the render target textures and post process.
  10420. */
  10421. private _disposeTextureAndPostProcesses();
  10422. /**
  10423. * Dispose the highlight layer and free resources.
  10424. */
  10425. dispose(): void;
  10426. /**
  10427. * Gets the class name of the effect layer
  10428. * @returns the string with the class name of the effect layer
  10429. */
  10430. getClassName(): string;
  10431. /**
  10432. * Creates an effect layer from parsed effect layer data
  10433. * @param parsedEffectLayer defines effect layer data
  10434. * @param scene defines the current scene
  10435. * @param rootUrl defines the root URL containing the effect layer information
  10436. * @returns a parsed effect Layer
  10437. */
  10438. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10439. }
  10440. }
  10441. declare module BABYLON {
  10442. /**
  10443. * Glow layer options. This helps customizing the behaviour
  10444. * of the glow layer.
  10445. */
  10446. interface IGlowLayerOptions {
  10447. /**
  10448. * Multiplication factor apply to the canvas size to compute the render target size
  10449. * used to generated the glowing objects (the smaller the faster).
  10450. */
  10451. mainTextureRatio: number;
  10452. /**
  10453. * Enforces a fixed size texture to ensure resize independant blur.
  10454. */
  10455. mainTextureFixedSize?: number;
  10456. /**
  10457. * How big is the kernel of the blur texture.
  10458. */
  10459. blurKernelSize: number;
  10460. /**
  10461. * The camera attached to the layer.
  10462. */
  10463. camera: Nullable<Camera>;
  10464. /**
  10465. * Enable MSAA by chosing the number of samples.
  10466. */
  10467. mainTextureSamples?: number;
  10468. }
  10469. /**
  10470. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10471. *
  10472. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10473. * glowy meshes to your scene.
  10474. *
  10475. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10476. */
  10477. class GlowLayer extends EffectLayer {
  10478. /**
  10479. * Effect Name of the layer.
  10480. */
  10481. static readonly EffectName: string;
  10482. /**
  10483. * The default blur kernel size used for the glow.
  10484. */
  10485. static DefaultBlurKernelSize: number;
  10486. /**
  10487. * The default texture size ratio used for the glow.
  10488. */
  10489. static DefaultTextureRatio: number;
  10490. /**
  10491. * Gets the kernel size of the blur.
  10492. */
  10493. /**
  10494. * Sets the kernel size of the blur.
  10495. */
  10496. blurKernelSize: number;
  10497. /**
  10498. * Gets the glow intensity.
  10499. */
  10500. /**
  10501. * Sets the glow intensity.
  10502. */
  10503. intensity: number;
  10504. private _options;
  10505. private _intensity;
  10506. private _horizontalBlurPostprocess1;
  10507. private _verticalBlurPostprocess1;
  10508. private _horizontalBlurPostprocess2;
  10509. private _verticalBlurPostprocess2;
  10510. private _blurTexture1;
  10511. private _blurTexture2;
  10512. private _postProcesses1;
  10513. private _postProcesses2;
  10514. private _includedOnlyMeshes;
  10515. private _excludedMeshes;
  10516. /**
  10517. * Callback used to let the user override the color selection on a per mesh basis
  10518. */
  10519. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10520. /**
  10521. * Callback used to let the user override the texture selection on a per mesh basis
  10522. */
  10523. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10524. /**
  10525. * Instantiates a new glow Layer and references it to the scene.
  10526. * @param name The name of the layer
  10527. * @param scene The scene to use the layer in
  10528. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10529. */
  10530. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10531. /**
  10532. * Get the effect name of the layer.
  10533. * @return The effect name
  10534. */
  10535. getEffectName(): string;
  10536. /**
  10537. * Create the merge effect. This is the shader use to blit the information back
  10538. * to the main canvas at the end of the scene rendering.
  10539. */
  10540. protected _createMergeEffect(): Effect;
  10541. /**
  10542. * Creates the render target textures and post processes used in the glow layer.
  10543. */
  10544. protected _createTextureAndPostProcesses(): void;
  10545. /**
  10546. * Checks for the readiness of the element composing the layer.
  10547. * @param subMesh the mesh to check for
  10548. * @param useInstances specify wether or not to use instances to render the mesh
  10549. * @param emissiveTexture the associated emissive texture used to generate the glow
  10550. * @return true if ready otherwise, false
  10551. */
  10552. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10553. /**
  10554. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10555. */
  10556. needStencil(): boolean;
  10557. /**
  10558. * Implementation specific of rendering the generating effect on the main canvas.
  10559. * @param effect The effect used to render through
  10560. */
  10561. protected _internalRender(effect: Effect): void;
  10562. /**
  10563. * Sets the required values for both the emissive texture and and the main color.
  10564. */
  10565. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10566. /**
  10567. * Returns true if the mesh should render, otherwise false.
  10568. * @param mesh The mesh to render
  10569. * @returns true if it should render otherwise false
  10570. */
  10571. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10572. /**
  10573. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10574. * @param mesh The mesh to exclude from the glow layer
  10575. */
  10576. addExcludedMesh(mesh: Mesh): void;
  10577. /**
  10578. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10579. * @param mesh The mesh to remove
  10580. */
  10581. removeExcludedMesh(mesh: Mesh): void;
  10582. /**
  10583. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10584. * @param mesh The mesh to include in the glow layer
  10585. */
  10586. addIncludedOnlyMesh(mesh: Mesh): void;
  10587. /**
  10588. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10589. * @param mesh The mesh to remove
  10590. */
  10591. removeIncludedOnlyMesh(mesh: Mesh): void;
  10592. /**
  10593. * Determine if a given mesh will be used in the glow layer
  10594. * @param mesh The mesh to test
  10595. * @returns true if the mesh will be highlighted by the current glow layer
  10596. */
  10597. hasMesh(mesh: AbstractMesh): boolean;
  10598. /**
  10599. * Free any resources and references associated to a mesh.
  10600. * Internal use
  10601. * @param mesh The mesh to free.
  10602. */
  10603. /**
  10604. * Gets the class name of the effect layer
  10605. * @returns the string with the class name of the effect layer
  10606. */
  10607. getClassName(): string;
  10608. /**
  10609. * Serializes this glow layer
  10610. * @returns a serialized glow layer object
  10611. */
  10612. serialize(): any;
  10613. /**
  10614. * Creates a Glow Layer from parsed glow layer data
  10615. * @param parsedGlowLayer defines glow layer data
  10616. * @param scene defines the current scene
  10617. * @param rootUrl defines the root URL containing the glow layer information
  10618. * @returns a parsed Glow Layer
  10619. */
  10620. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10621. }
  10622. }
  10623. declare module BABYLON {
  10624. /**
  10625. * Highlight layer options. This helps customizing the behaviour
  10626. * of the highlight layer.
  10627. */
  10628. interface IHighlightLayerOptions {
  10629. /**
  10630. * Multiplication factor apply to the canvas size to compute the render target size
  10631. * used to generated the glowing objects (the smaller the faster).
  10632. */
  10633. mainTextureRatio: number;
  10634. /**
  10635. * Enforces a fixed size texture to ensure resize independant blur.
  10636. */
  10637. mainTextureFixedSize?: number;
  10638. /**
  10639. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10640. * of the picture to blur (the smaller the faster).
  10641. */
  10642. blurTextureSizeRatio: number;
  10643. /**
  10644. * How big in texel of the blur texture is the vertical blur.
  10645. */
  10646. blurVerticalSize: number;
  10647. /**
  10648. * How big in texel of the blur texture is the horizontal blur.
  10649. */
  10650. blurHorizontalSize: number;
  10651. /**
  10652. * Alpha blending mode used to apply the blur. Default is combine.
  10653. */
  10654. alphaBlendingMode: number;
  10655. /**
  10656. * The camera attached to the layer.
  10657. */
  10658. camera: Nullable<Camera>;
  10659. /**
  10660. * Should we display highlight as a solid stroke?
  10661. */
  10662. isStroke?: boolean;
  10663. }
  10664. /**
  10665. * The highlight layer Helps adding a glow effect around a mesh.
  10666. *
  10667. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10668. * glowy meshes to your scene.
  10669. *
  10670. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10671. */
  10672. class HighlightLayer extends EffectLayer {
  10673. name: string;
  10674. /**
  10675. * Effect Name of the highlight layer.
  10676. */
  10677. static readonly EffectName: string;
  10678. /**
  10679. * The neutral color used during the preparation of the glow effect.
  10680. * This is black by default as the blend operation is a blend operation.
  10681. */
  10682. static NeutralColor: Color4;
  10683. /**
  10684. * Stencil value used for glowing meshes.
  10685. */
  10686. static GlowingMeshStencilReference: number;
  10687. /**
  10688. * Stencil value used for the other meshes in the scene.
  10689. */
  10690. static NormalMeshStencilReference: number;
  10691. /**
  10692. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10693. */
  10694. innerGlow: boolean;
  10695. /**
  10696. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10697. */
  10698. outerGlow: boolean;
  10699. /**
  10700. * Gets the horizontal size of the blur.
  10701. */
  10702. /**
  10703. * Specifies the horizontal size of the blur.
  10704. */
  10705. blurHorizontalSize: number;
  10706. /**
  10707. * Gets the vertical size of the blur.
  10708. */
  10709. /**
  10710. * Specifies the vertical size of the blur.
  10711. */
  10712. blurVerticalSize: number;
  10713. /**
  10714. * An event triggered when the highlight layer is being blurred.
  10715. */
  10716. onBeforeBlurObservable: Observable<HighlightLayer>;
  10717. /**
  10718. * An event triggered when the highlight layer has been blurred.
  10719. */
  10720. onAfterBlurObservable: Observable<HighlightLayer>;
  10721. private _instanceGlowingMeshStencilReference;
  10722. private _options;
  10723. private _downSamplePostprocess;
  10724. private _horizontalBlurPostprocess;
  10725. private _verticalBlurPostprocess;
  10726. private _blurTexture;
  10727. private _meshes;
  10728. private _excludedMeshes;
  10729. /**
  10730. * Instantiates a new highlight Layer and references it to the scene..
  10731. * @param name The name of the layer
  10732. * @param scene The scene to use the layer in
  10733. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10734. */
  10735. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10736. /**
  10737. * Get the effect name of the layer.
  10738. * @return The effect name
  10739. */
  10740. getEffectName(): string;
  10741. /**
  10742. * Create the merge effect. This is the shader use to blit the information back
  10743. * to the main canvas at the end of the scene rendering.
  10744. */
  10745. protected _createMergeEffect(): Effect;
  10746. /**
  10747. * Creates the render target textures and post processes used in the highlight layer.
  10748. */
  10749. protected _createTextureAndPostProcesses(): void;
  10750. /**
  10751. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10752. */
  10753. needStencil(): boolean;
  10754. /**
  10755. * Checks for the readiness of the element composing the layer.
  10756. * @param subMesh the mesh to check for
  10757. * @param useInstances specify wether or not to use instances to render the mesh
  10758. * @param emissiveTexture the associated emissive texture used to generate the glow
  10759. * @return true if ready otherwise, false
  10760. */
  10761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10762. /**
  10763. * Implementation specific of rendering the generating effect on the main canvas.
  10764. * @param effect The effect used to render through
  10765. */
  10766. protected _internalRender(effect: Effect): void;
  10767. /**
  10768. * Returns true if the layer contains information to display, otherwise false.
  10769. */
  10770. shouldRender(): boolean;
  10771. /**
  10772. * Returns true if the mesh should render, otherwise false.
  10773. * @param mesh The mesh to render
  10774. * @returns true if it should render otherwise false
  10775. */
  10776. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10777. /**
  10778. * Sets the required values for both the emissive texture and and the main color.
  10779. */
  10780. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10781. /**
  10782. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10783. * @param mesh The mesh to exclude from the highlight layer
  10784. */
  10785. addExcludedMesh(mesh: Mesh): void;
  10786. /**
  10787. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10788. * @param mesh The mesh to highlight
  10789. */
  10790. removeExcludedMesh(mesh: Mesh): void;
  10791. /**
  10792. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10793. * @param mesh mesh to test
  10794. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10795. */
  10796. hasMesh(mesh: AbstractMesh): boolean;
  10797. /**
  10798. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10799. * @param mesh The mesh to highlight
  10800. * @param color The color of the highlight
  10801. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10802. */
  10803. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10804. /**
  10805. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10806. * @param mesh The mesh to highlight
  10807. */
  10808. removeMesh(mesh: Mesh): void;
  10809. /**
  10810. * Force the stencil to the normal expected value for none glowing parts
  10811. */
  10812. private _defaultStencilReference(mesh);
  10813. /**
  10814. * Free any resources and references associated to a mesh.
  10815. * Internal use
  10816. * @param mesh The mesh to free.
  10817. */
  10818. /**
  10819. * Dispose the highlight layer and free resources.
  10820. */
  10821. dispose(): void;
  10822. /**
  10823. * Gets the class name of the effect layer
  10824. * @returns the string with the class name of the effect layer
  10825. */
  10826. getClassName(): string;
  10827. /**
  10828. * Serializes this Highlight layer
  10829. * @returns a serialized Highlight layer object
  10830. */
  10831. serialize(): any;
  10832. /**
  10833. * Creates a Highlight layer from parsed Highlight layer data
  10834. * @param parsedHightlightLayer defines the Highlight layer data
  10835. * @param scene defines the current scene
  10836. * @param rootUrl defines the root URL containing the Highlight layer information
  10837. * @returns a parsed Highlight layer
  10838. */
  10839. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10840. }
  10841. }
  10842. declare module BABYLON {
  10843. class Layer {
  10844. name: string;
  10845. texture: Nullable<Texture>;
  10846. isBackground: boolean;
  10847. color: Color4;
  10848. scale: Vector2;
  10849. offset: Vector2;
  10850. alphaBlendingMode: number;
  10851. alphaTest: boolean;
  10852. layerMask: number;
  10853. private _scene;
  10854. private _vertexBuffers;
  10855. private _indexBuffer;
  10856. private _effect;
  10857. private _alphaTestEffect;
  10858. /**
  10859. * An event triggered when the layer is disposed.
  10860. */
  10861. onDisposeObservable: Observable<Layer>;
  10862. private _onDisposeObserver;
  10863. onDispose: () => void;
  10864. /**
  10865. * An event triggered before rendering the scene
  10866. */
  10867. onBeforeRenderObservable: Observable<Layer>;
  10868. private _onBeforeRenderObserver;
  10869. onBeforeRender: () => void;
  10870. /**
  10871. * An event triggered after rendering the scene
  10872. */
  10873. onAfterRenderObservable: Observable<Layer>;
  10874. private _onAfterRenderObserver;
  10875. onAfterRender: () => void;
  10876. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10877. private _createIndexBuffer();
  10878. render(): void;
  10879. dispose(): void;
  10880. }
  10881. }
  10882. declare module BABYLON {
  10883. class LensFlare {
  10884. size: number;
  10885. position: number;
  10886. color: Color3;
  10887. texture: Nullable<Texture>;
  10888. alphaMode: number;
  10889. private _system;
  10890. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10891. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10892. dispose(): void;
  10893. }
  10894. }
  10895. declare module BABYLON {
  10896. class LensFlareSystem {
  10897. name: string;
  10898. lensFlares: LensFlare[];
  10899. borderLimit: number;
  10900. viewportBorder: number;
  10901. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10902. layerMask: number;
  10903. id: string;
  10904. private _scene;
  10905. private _emitter;
  10906. private _vertexBuffers;
  10907. private _indexBuffer;
  10908. private _effect;
  10909. private _positionX;
  10910. private _positionY;
  10911. private _isEnabled;
  10912. constructor(name: string, emitter: any, scene: Scene);
  10913. isEnabled: boolean;
  10914. getScene(): Scene;
  10915. getEmitter(): any;
  10916. setEmitter(newEmitter: any): void;
  10917. getEmitterPosition(): Vector3;
  10918. computeEffectivePosition(globalViewport: Viewport): boolean;
  10919. render(): boolean;
  10920. dispose(): void;
  10921. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10922. serialize(): any;
  10923. }
  10924. }
  10925. declare module BABYLON {
  10926. /**
  10927. * A directional light is defined by a direction (what a surprise!).
  10928. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10929. * 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.
  10930. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10931. */
  10932. class DirectionalLight extends ShadowLight {
  10933. private _shadowFrustumSize;
  10934. /**
  10935. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10936. */
  10937. /**
  10938. * Specifies a fix frustum size for the shadow generation.
  10939. */
  10940. shadowFrustumSize: number;
  10941. private _shadowOrthoScale;
  10942. /**
  10943. * Gets the shadow projection scale against the optimal computed one.
  10944. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10945. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10946. */
  10947. /**
  10948. * Sets the shadow projection scale against the optimal computed one.
  10949. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10950. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10951. */
  10952. shadowOrthoScale: number;
  10953. /**
  10954. * Automatically compute the projection matrix to best fit (including all the casters)
  10955. * on each frame.
  10956. */
  10957. autoUpdateExtends: boolean;
  10958. private _orthoLeft;
  10959. private _orthoRight;
  10960. private _orthoTop;
  10961. private _orthoBottom;
  10962. /**
  10963. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10964. * The directional light is emitted from everywhere in the given direction.
  10965. * It can cast shawdows.
  10966. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10967. * @param name The friendly name of the light
  10968. * @param direction The direction of the light
  10969. * @param scene The scene the light belongs to
  10970. */
  10971. constructor(name: string, direction: Vector3, scene: Scene);
  10972. /**
  10973. * Returns the string "DirectionalLight".
  10974. * @return The class name
  10975. */
  10976. getClassName(): string;
  10977. /**
  10978. * Returns the integer 1.
  10979. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10980. */
  10981. getTypeID(): number;
  10982. /**
  10983. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10984. * Returns the DirectionalLight Shadow projection matrix.
  10985. */
  10986. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10987. /**
  10988. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10989. * Returns the DirectionalLight Shadow projection matrix.
  10990. */
  10991. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10992. /**
  10993. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10994. * Returns the DirectionalLight Shadow projection matrix.
  10995. */
  10996. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10997. protected _buildUniformLayout(): void;
  10998. /**
  10999. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11000. * @param effect The effect to update
  11001. * @param lightIndex The index of the light in the effect to update
  11002. * @returns The directional light
  11003. */
  11004. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11005. /**
  11006. * Gets the minZ used for shadow according to both the scene and the light.
  11007. *
  11008. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11009. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11010. * @param activeCamera The camera we are returning the min for
  11011. * @returns the depth min z
  11012. */
  11013. getDepthMinZ(activeCamera: Camera): number;
  11014. /**
  11015. * Gets the maxZ used for shadow according to both the scene and the light.
  11016. *
  11017. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11018. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11019. * @param activeCamera The camera we are returning the max for
  11020. * @returns the depth max z
  11021. */
  11022. getDepthMaxZ(activeCamera: Camera): number;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * The HemisphericLight simulates the ambient environment light,
  11028. * so the passed direction is the light reflection direction, not the incoming direction.
  11029. */
  11030. class HemisphericLight extends Light {
  11031. /**
  11032. * The groundColor is the light in the opposite direction to the one specified during creation.
  11033. * 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.
  11034. */
  11035. groundColor: Color3;
  11036. /**
  11037. * The light reflection direction, not the incoming direction.
  11038. */
  11039. direction: Vector3;
  11040. private _worldMatrix;
  11041. /**
  11042. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11043. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11044. * The HemisphericLight can't cast shadows.
  11045. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11046. * @param name The friendly name of the light
  11047. * @param direction The direction of the light reflection
  11048. * @param scene The scene the light belongs to
  11049. */
  11050. constructor(name: string, direction: Vector3, scene: Scene);
  11051. protected _buildUniformLayout(): void;
  11052. /**
  11053. * Returns the string "HemisphericLight".
  11054. * @return The class name
  11055. */
  11056. getClassName(): string;
  11057. /**
  11058. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11059. * Returns the updated direction.
  11060. * @param target The target the direction should point to
  11061. * @return The computed direction
  11062. */
  11063. setDirectionToTarget(target: Vector3): Vector3;
  11064. /**
  11065. * Returns the shadow generator associated to the light.
  11066. * @returns Always null for hemispheric lights because it does not support shadows.
  11067. */
  11068. getShadowGenerator(): Nullable<ShadowGenerator>;
  11069. /**
  11070. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11071. * @param effect The effect to update
  11072. * @param lightIndex The index of the light in the effect to update
  11073. * @returns The hemispheric light
  11074. */
  11075. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11076. /**
  11077. * @hidden internal use only.
  11078. */
  11079. /**
  11080. * Returns the integer 3.
  11081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11082. */
  11083. getTypeID(): number;
  11084. }
  11085. }
  11086. declare module BABYLON {
  11087. /**
  11088. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11089. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11090. * 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.
  11091. */
  11092. abstract class Light extends Node {
  11093. private static _LIGHTMAP_DEFAULT;
  11094. private static _LIGHTMAP_SPECULAR;
  11095. private static _LIGHTMAP_SHADOWSONLY;
  11096. /**
  11097. * If every light affecting the material is in this lightmapMode,
  11098. * material.lightmapTexture adds or multiplies
  11099. * (depends on material.useLightmapAsShadowmap)
  11100. * after every other light calculations.
  11101. */
  11102. static readonly LIGHTMAP_DEFAULT: number;
  11103. /**
  11104. * material.lightmapTexture as only diffuse lighting from this light
  11105. * adds only specular lighting from this light
  11106. * adds dynamic shadows
  11107. */
  11108. static readonly LIGHTMAP_SPECULAR: number;
  11109. /**
  11110. * material.lightmapTexture as only lighting
  11111. * no light calculation from this light
  11112. * only adds dynamic shadows from this light
  11113. */
  11114. static readonly LIGHTMAP_SHADOWSONLY: number;
  11115. private static _INTENSITYMODE_AUTOMATIC;
  11116. private static _INTENSITYMODE_LUMINOUSPOWER;
  11117. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11118. private static _INTENSITYMODE_ILLUMINANCE;
  11119. private static _INTENSITYMODE_LUMINANCE;
  11120. /**
  11121. * Each light type uses the default quantity according to its type:
  11122. * point/spot lights use luminous intensity
  11123. * directional lights use illuminance
  11124. */
  11125. static readonly INTENSITYMODE_AUTOMATIC: number;
  11126. /**
  11127. * lumen (lm)
  11128. */
  11129. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11130. /**
  11131. * candela (lm/sr)
  11132. */
  11133. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11134. /**
  11135. * lux (lm/m^2)
  11136. */
  11137. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11138. /**
  11139. * nit (cd/m^2)
  11140. */
  11141. static readonly INTENSITYMODE_LUMINANCE: number;
  11142. private static _LIGHTTYPEID_POINTLIGHT;
  11143. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11144. private static _LIGHTTYPEID_SPOTLIGHT;
  11145. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11146. /**
  11147. * Light type const id of the point light.
  11148. */
  11149. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11150. /**
  11151. * Light type const id of the directional light.
  11152. */
  11153. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11154. /**
  11155. * Light type const id of the spot light.
  11156. */
  11157. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11158. /**
  11159. * Light type const id of the hemispheric light.
  11160. */
  11161. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11162. /**
  11163. * Diffuse gives the basic color to an object.
  11164. */
  11165. diffuse: Color3;
  11166. /**
  11167. * Specular produces a highlight color on an object.
  11168. * Note: This is note affecting PBR materials.
  11169. */
  11170. specular: Color3;
  11171. /**
  11172. * Strength of the light.
  11173. * Note: By default it is define in the framework own unit.
  11174. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11175. */
  11176. intensity: number;
  11177. /**
  11178. * Defines how far from the source the light is impacting in scene units.
  11179. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11180. */
  11181. range: number;
  11182. /**
  11183. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11184. * of light.
  11185. */
  11186. private _photometricScale;
  11187. private _intensityMode;
  11188. /**
  11189. * Gets the photometric scale used to interpret the intensity.
  11190. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11191. */
  11192. /**
  11193. * Sets the photometric scale used to interpret the intensity.
  11194. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11195. */
  11196. intensityMode: number;
  11197. private _radius;
  11198. /**
  11199. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11200. */
  11201. /**
  11202. * sets the light radius used by PBR Materials to simulate soft area lights.
  11203. */
  11204. radius: number;
  11205. private _renderPriority;
  11206. /**
  11207. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11208. * exceeding the number allowed of the materials.
  11209. */
  11210. renderPriority: number;
  11211. private _shadowEnabled;
  11212. /**
  11213. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11214. * the current shadow generator.
  11215. */
  11216. /**
  11217. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11218. * the current shadow generator.
  11219. */
  11220. shadowEnabled: boolean;
  11221. private _includedOnlyMeshes;
  11222. /**
  11223. * Gets the only meshes impacted by this light.
  11224. */
  11225. /**
  11226. * Sets the only meshes impacted by this light.
  11227. */
  11228. includedOnlyMeshes: AbstractMesh[];
  11229. private _excludedMeshes;
  11230. /**
  11231. * Gets the meshes not impacted by this light.
  11232. */
  11233. /**
  11234. * Sets the meshes not impacted by this light.
  11235. */
  11236. excludedMeshes: AbstractMesh[];
  11237. private _excludeWithLayerMask;
  11238. /**
  11239. * Gets the layer id use to find what meshes are not impacted by the light.
  11240. * Inactive if 0
  11241. */
  11242. /**
  11243. * Sets the layer id use to find what meshes are not impacted by the light.
  11244. * Inactive if 0
  11245. */
  11246. excludeWithLayerMask: number;
  11247. private _includeOnlyWithLayerMask;
  11248. /**
  11249. * Gets the layer id use to find what meshes are impacted by the light.
  11250. * Inactive if 0
  11251. */
  11252. /**
  11253. * Sets the layer id use to find what meshes are impacted by the light.
  11254. * Inactive if 0
  11255. */
  11256. includeOnlyWithLayerMask: number;
  11257. private _lightmapMode;
  11258. /**
  11259. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11260. */
  11261. /**
  11262. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11263. */
  11264. lightmapMode: number;
  11265. private _parentedWorldMatrix;
  11266. /**
  11267. * Shadow generator associted to the light.
  11268. * Internal use only.
  11269. */
  11270. /**
  11271. * @hidden Internal use only.
  11272. */
  11273. /**
  11274. * @hidden Internal use only.
  11275. */
  11276. /**
  11277. * The current light unifom buffer.
  11278. * @hidden Internal use only.
  11279. */
  11280. /**
  11281. * Creates a Light object in the scene.
  11282. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11283. * @param name The firendly name of the light
  11284. * @param scene The scene the light belongs too
  11285. */
  11286. constructor(name: string, scene: Scene);
  11287. protected abstract _buildUniformLayout(): void;
  11288. /**
  11289. * Sets the passed Effect "effect" with the Light information.
  11290. * @param effect The effect to update
  11291. * @param lightIndex The index of the light in the effect to update
  11292. * @returns The light
  11293. */
  11294. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11295. /**
  11296. * @hidden internal use only.
  11297. */
  11298. getWorldMatrix(): Matrix;
  11299. /**
  11300. * Returns the string "Light".
  11301. * @returns the class name
  11302. */
  11303. getClassName(): string;
  11304. /**
  11305. * Converts the light information to a readable string for debug purpose.
  11306. * @param fullDetails Supports for multiple levels of logging within scene loading
  11307. * @returns the human readable light info
  11308. */
  11309. toString(fullDetails?: boolean): string;
  11310. /**
  11311. * Set the enabled state of this node.
  11312. * @param value - the new enabled state
  11313. */
  11314. setEnabled(value: boolean): void;
  11315. /**
  11316. * Returns the Light associated shadow generator if any.
  11317. * @return the associated shadow generator.
  11318. */
  11319. getShadowGenerator(): Nullable<IShadowGenerator>;
  11320. /**
  11321. * Returns a Vector3, the absolute light position in the World.
  11322. * @returns the world space position of the light
  11323. */
  11324. getAbsolutePosition(): Vector3;
  11325. /**
  11326. * Specifies if the light will affect the passed mesh.
  11327. * @param mesh The mesh to test against the light
  11328. * @return true the mesh is affected otherwise, false.
  11329. */
  11330. canAffectMesh(mesh: AbstractMesh): boolean;
  11331. /**
  11332. * Computes and Returns the light World matrix.
  11333. * @returns the world matrix
  11334. */
  11335. getWorldMatrix(): Matrix;
  11336. /**
  11337. * Sort function to order lights for rendering.
  11338. * @param a First Light object to compare to second.
  11339. * @param b Second Light object to compare first.
  11340. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11341. */
  11342. static CompareLightsPriority(a: Light, b: Light): number;
  11343. /**
  11344. * Releases resources associated with this node.
  11345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11347. */
  11348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11349. /**
  11350. * Returns the light type ID (integer).
  11351. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11352. */
  11353. getTypeID(): number;
  11354. /**
  11355. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11356. * @returns the scaled intensity in intensity mode unit
  11357. */
  11358. getScaledIntensity(): number;
  11359. /**
  11360. * Returns a new Light object, named "name", from the current one.
  11361. * @param name The name of the cloned light
  11362. * @returns the new created light
  11363. */
  11364. clone(name: string): Nullable<Light>;
  11365. /**
  11366. * Serializes the current light into a Serialization object.
  11367. * @returns the serialized object.
  11368. */
  11369. serialize(): any;
  11370. /**
  11371. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11372. * This new light is named "name" and added to the passed scene.
  11373. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11374. * @param name The friendly name of the light
  11375. * @param scene The scene the new light will belong to
  11376. * @returns the constructor function
  11377. */
  11378. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11379. /**
  11380. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11381. * @param parsedLight The JSON representation of the light
  11382. * @param scene The scene to create the parsed light in
  11383. * @returns the created light after parsing
  11384. */
  11385. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11386. private _hookArrayForExcluded(array);
  11387. private _hookArrayForIncludedOnly(array);
  11388. private _resyncMeshes();
  11389. /**
  11390. * Forces the meshes to update their light related information in their rendering used effects
  11391. * @hidden Internal Use Only
  11392. */
  11393. /**
  11394. * Recomputes the cached photometric scale if needed.
  11395. */
  11396. private _computePhotometricScale();
  11397. /**
  11398. * Returns the Photometric Scale according to the light type and intensity mode.
  11399. */
  11400. private _getPhotometricScale();
  11401. /**
  11402. * Reorder the light in the scene according to their defined priority.
  11403. * @hidden Internal Use Only
  11404. */
  11405. }
  11406. }
  11407. declare module BABYLON {
  11408. /**
  11409. * A point light is a light defined by an unique point in world space.
  11410. * The light is emitted in every direction from this point.
  11411. * A good example of a point light is a standard light bulb.
  11412. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11413. */
  11414. class PointLight extends ShadowLight {
  11415. private _shadowAngle;
  11416. /**
  11417. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11418. * This specifies what angle the shadow will use to be created.
  11419. *
  11420. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11421. */
  11422. /**
  11423. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11424. * This specifies what angle the shadow will use to be created.
  11425. *
  11426. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11427. */
  11428. shadowAngle: number;
  11429. /**
  11430. * Gets the direction if it has been set.
  11431. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11432. */
  11433. /**
  11434. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11435. */
  11436. direction: Vector3;
  11437. /**
  11438. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11439. * A PointLight emits the light in every direction.
  11440. * It can cast shadows.
  11441. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11442. * ```javascript
  11443. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11444. * ```
  11445. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11446. * @param name The light friendly name
  11447. * @param position The position of the point light in the scene
  11448. * @param scene The scene the lights belongs to
  11449. */
  11450. constructor(name: string, position: Vector3, scene: Scene);
  11451. /**
  11452. * Returns the string "PointLight"
  11453. * @returns the class name
  11454. */
  11455. getClassName(): string;
  11456. /**
  11457. * Returns the integer 0.
  11458. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11459. */
  11460. getTypeID(): number;
  11461. /**
  11462. * Specifies wether or not the shadowmap should be a cube texture.
  11463. * @returns true if the shadowmap needs to be a cube texture.
  11464. */
  11465. needCube(): boolean;
  11466. /**
  11467. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11468. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11469. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11470. */
  11471. getShadowDirection(faceIndex?: number): Vector3;
  11472. /**
  11473. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11474. * - fov = PI / 2
  11475. * - aspect ratio : 1.0
  11476. * - z-near and far equal to the active camera minZ and maxZ.
  11477. * Returns the PointLight.
  11478. */
  11479. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11480. protected _buildUniformLayout(): void;
  11481. /**
  11482. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11483. * @param effect The effect to update
  11484. * @param lightIndex The index of the light in the effect to update
  11485. * @returns The point light
  11486. */
  11487. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Interface describing all the common properties and methods a shadow light needs to implement.
  11493. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11494. * as well as binding the different shadow properties to the effects.
  11495. */
  11496. interface IShadowLight extends Light {
  11497. /**
  11498. * The light id in the scene (used in scene.findLighById for instance)
  11499. */
  11500. id: string;
  11501. /**
  11502. * The position the shdow will be casted from.
  11503. */
  11504. position: Vector3;
  11505. /**
  11506. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11507. */
  11508. direction: Vector3;
  11509. /**
  11510. * The transformed position. Position of the light in world space taking parenting in account.
  11511. */
  11512. transformedPosition: Vector3;
  11513. /**
  11514. * The transformed direction. Direction of the light in world space taking parenting in account.
  11515. */
  11516. transformedDirection: Vector3;
  11517. /**
  11518. * The friendly name of the light in the scene.
  11519. */
  11520. name: string;
  11521. /**
  11522. * Defines the shadow projection clipping minimum z value.
  11523. */
  11524. shadowMinZ: number;
  11525. /**
  11526. * Defines the shadow projection clipping maximum z value.
  11527. */
  11528. shadowMaxZ: number;
  11529. /**
  11530. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11531. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11532. */
  11533. computeTransformedInformation(): boolean;
  11534. /**
  11535. * Gets the scene the light belongs to.
  11536. * @returns The scene
  11537. */
  11538. getScene(): Scene;
  11539. /**
  11540. * Callback defining a custom Projection Matrix Builder.
  11541. * This can be used to override the default projection matrix computation.
  11542. */
  11543. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11544. /**
  11545. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11546. * @param matrix The materix to updated with the projection information
  11547. * @param viewMatrix The transform matrix of the light
  11548. * @param renderList The list of mesh to render in the map
  11549. * @returns The current light
  11550. */
  11551. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11552. /**
  11553. * Gets the current depth scale used in ESM.
  11554. * @returns The scale
  11555. */
  11556. getDepthScale(): number;
  11557. /**
  11558. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11559. * @returns true if a cube texture needs to be use
  11560. */
  11561. needCube(): boolean;
  11562. /**
  11563. * Detects if the projection matrix requires to be recomputed this frame.
  11564. * @returns true if it requires to be recomputed otherwise, false.
  11565. */
  11566. needProjectionMatrixCompute(): boolean;
  11567. /**
  11568. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11569. */
  11570. forceProjectionMatrixCompute(): void;
  11571. /**
  11572. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11573. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11574. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11575. */
  11576. getShadowDirection(faceIndex?: number): Vector3;
  11577. /**
  11578. * Gets the minZ used for shadow according to both the scene and the light.
  11579. * @param activeCamera The camera we are returning the min for
  11580. * @returns the depth min z
  11581. */
  11582. getDepthMinZ(activeCamera: Camera): number;
  11583. /**
  11584. * Gets the maxZ used for shadow according to both the scene and the light.
  11585. * @param activeCamera The camera we are returning the max for
  11586. * @returns the depth max z
  11587. */
  11588. getDepthMaxZ(activeCamera: Camera): number;
  11589. }
  11590. /**
  11591. * Base implementation IShadowLight
  11592. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11593. */
  11594. abstract class ShadowLight extends Light implements IShadowLight {
  11595. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11596. protected _position: Vector3;
  11597. protected _setPosition(value: Vector3): void;
  11598. /**
  11599. * Sets the position the shadow will be casted from. Also use as the light position for both
  11600. * point and spot lights.
  11601. */
  11602. /**
  11603. * Sets the position the shadow will be casted from. Also use as the light position for both
  11604. * point and spot lights.
  11605. */
  11606. position: Vector3;
  11607. protected _direction: Vector3;
  11608. protected _setDirection(value: Vector3): void;
  11609. /**
  11610. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11611. * Also use as the light direction on spot and directional lights.
  11612. */
  11613. /**
  11614. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11615. * Also use as the light direction on spot and directional lights.
  11616. */
  11617. direction: Vector3;
  11618. private _shadowMinZ;
  11619. /**
  11620. * Gets the shadow projection clipping minimum z value.
  11621. */
  11622. /**
  11623. * Sets the shadow projection clipping minimum z value.
  11624. */
  11625. shadowMinZ: number;
  11626. private _shadowMaxZ;
  11627. /**
  11628. * Sets the shadow projection clipping maximum z value.
  11629. */
  11630. /**
  11631. * Gets the shadow projection clipping maximum z value.
  11632. */
  11633. shadowMaxZ: number;
  11634. /**
  11635. * Callback defining a custom Projection Matrix Builder.
  11636. * This can be used to override the default projection matrix computation.
  11637. */
  11638. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11639. /**
  11640. * The transformed position. Position of the light in world space taking parenting in account.
  11641. */
  11642. transformedPosition: Vector3;
  11643. /**
  11644. * The transformed direction. Direction of the light in world space taking parenting in account.
  11645. */
  11646. transformedDirection: Vector3;
  11647. private _worldMatrix;
  11648. private _needProjectionMatrixCompute;
  11649. /**
  11650. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11651. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11652. */
  11653. computeTransformedInformation(): boolean;
  11654. /**
  11655. * Return the depth scale used for the shadow map.
  11656. * @returns the depth scale.
  11657. */
  11658. getDepthScale(): number;
  11659. /**
  11660. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11661. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11662. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11663. */
  11664. getShadowDirection(faceIndex?: number): Vector3;
  11665. /**
  11666. * Returns the ShadowLight absolute position in the World.
  11667. * @returns the position vector in world space
  11668. */
  11669. getAbsolutePosition(): Vector3;
  11670. /**
  11671. * Sets the ShadowLight direction toward the passed target.
  11672. * @param target The point tot target in local space
  11673. * @returns the updated ShadowLight direction
  11674. */
  11675. setDirectionToTarget(target: Vector3): Vector3;
  11676. /**
  11677. * Returns the light rotation in euler definition.
  11678. * @returns the x y z rotation in local space.
  11679. */
  11680. getRotation(): Vector3;
  11681. /**
  11682. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11683. * @returns true if a cube texture needs to be use
  11684. */
  11685. needCube(): boolean;
  11686. /**
  11687. * Detects if the projection matrix requires to be recomputed this frame.
  11688. * @returns true if it requires to be recomputed otherwise, false.
  11689. */
  11690. needProjectionMatrixCompute(): boolean;
  11691. /**
  11692. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11693. */
  11694. forceProjectionMatrixCompute(): void;
  11695. /**
  11696. * Get the world matrix of the sahdow lights.
  11697. * @hidden Internal Use Only
  11698. */
  11699. /**
  11700. * Gets the minZ used for shadow according to both the scene and the light.
  11701. * @param activeCamera The camera we are returning the min for
  11702. * @returns the depth min z
  11703. */
  11704. getDepthMinZ(activeCamera: Camera): number;
  11705. /**
  11706. * Gets the maxZ used for shadow according to both the scene and the light.
  11707. * @param activeCamera The camera we are returning the max for
  11708. * @returns the depth max z
  11709. */
  11710. getDepthMaxZ(activeCamera: Camera): number;
  11711. /**
  11712. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11713. * @param matrix The materix to updated with the projection information
  11714. * @param viewMatrix The transform matrix of the light
  11715. * @param renderList The list of mesh to render in the map
  11716. * @returns The current light
  11717. */
  11718. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11719. }
  11720. }
  11721. declare module BABYLON {
  11722. /**
  11723. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11724. * These values define a cone of light starting from the position, emitting toward the direction.
  11725. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11726. * and the exponent defines the speed of the decay of the light with distance (reach).
  11727. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11728. */
  11729. class SpotLight extends ShadowLight {
  11730. private _angle;
  11731. /**
  11732. * Gets the cone angle of the spot light in Radians.
  11733. */
  11734. /**
  11735. * Sets the cone angle of the spot light in Radians.
  11736. */
  11737. angle: number;
  11738. private _shadowAngleScale;
  11739. /**
  11740. * Allows scaling the angle of the light for shadow generation only.
  11741. */
  11742. /**
  11743. * Allows scaling the angle of the light for shadow generation only.
  11744. */
  11745. shadowAngleScale: number;
  11746. /**
  11747. * The light decay speed with the distance from the emission spot.
  11748. */
  11749. exponent: number;
  11750. private _projectionTextureMatrix;
  11751. /**
  11752. * Allows reading the projecton texture
  11753. */
  11754. readonly projectionTextureMatrix: Matrix;
  11755. protected _projectionTextureLightNear: number;
  11756. /**
  11757. * Gets the near clip of the Spotlight for texture projection.
  11758. */
  11759. /**
  11760. * Sets the near clip of the Spotlight for texture projection.
  11761. */
  11762. projectionTextureLightNear: number;
  11763. protected _projectionTextureLightFar: number;
  11764. /**
  11765. * Gets the far clip of the Spotlight for texture projection.
  11766. */
  11767. /**
  11768. * Sets the far clip of the Spotlight for texture projection.
  11769. */
  11770. projectionTextureLightFar: number;
  11771. protected _projectionTextureUpDirection: Vector3;
  11772. /**
  11773. * Gets the Up vector of the Spotlight for texture projection.
  11774. */
  11775. /**
  11776. * Sets the Up vector of the Spotlight for texture projection.
  11777. */
  11778. projectionTextureUpDirection: Vector3;
  11779. private _projectionTexture;
  11780. /**
  11781. * Gets the projection texture of the light.
  11782. */
  11783. /**
  11784. * Sets the projection texture of the light.
  11785. */
  11786. projectionTexture: Nullable<BaseTexture>;
  11787. private _projectionTextureViewLightDirty;
  11788. private _projectionTextureProjectionLightDirty;
  11789. private _projectionTextureDirty;
  11790. private _projectionTextureViewTargetVector;
  11791. private _projectionTextureViewLightMatrix;
  11792. private _projectionTextureProjectionLightMatrix;
  11793. private _projectionTextureScalingMatrix;
  11794. /**
  11795. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11796. * It can cast shadows.
  11797. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11798. * @param name The light friendly name
  11799. * @param position The position of the spot light in the scene
  11800. * @param direction The direction of the light in the scene
  11801. * @param angle The cone angle of the light in Radians
  11802. * @param exponent The light decay speed with the distance from the emission spot
  11803. * @param scene The scene the lights belongs to
  11804. */
  11805. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11806. /**
  11807. * Returns the string "SpotLight".
  11808. * @returns the class name
  11809. */
  11810. getClassName(): string;
  11811. /**
  11812. * Returns the integer 2.
  11813. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11814. */
  11815. getTypeID(): number;
  11816. /**
  11817. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11818. */
  11819. protected _setDirection(value: Vector3): void;
  11820. /**
  11821. * Overrides the position setter to recompute the projection texture view light Matrix.
  11822. */
  11823. protected _setPosition(value: Vector3): void;
  11824. /**
  11825. * 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.
  11826. * Returns the SpotLight.
  11827. */
  11828. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11829. protected _computeProjectionTextureViewLightMatrix(): void;
  11830. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11831. /**
  11832. * Main function for light texture projection matrix computing.
  11833. */
  11834. protected _computeProjectionTextureMatrix(): void;
  11835. protected _buildUniformLayout(): void;
  11836. /**
  11837. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11838. * @param effect The effect to update
  11839. * @param lightIndex The index of the light in the effect to update
  11840. * @returns The spot light
  11841. */
  11842. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11843. /**
  11844. * Disposes the light and the associated resources.
  11845. */
  11846. dispose(): void;
  11847. }
  11848. }
  11849. declare module BABYLON {
  11850. interface ILoadingScreen {
  11851. displayLoadingUI: () => void;
  11852. hideLoadingUI: () => void;
  11853. loadingUIBackgroundColor: string;
  11854. loadingUIText: string;
  11855. }
  11856. class DefaultLoadingScreen implements ILoadingScreen {
  11857. private _renderingCanvas;
  11858. private _loadingText;
  11859. private _loadingDivBackgroundColor;
  11860. private _loadingDiv;
  11861. private _loadingTextDiv;
  11862. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11863. displayLoadingUI(): void;
  11864. hideLoadingUI(): void;
  11865. loadingUIText: string;
  11866. loadingUIBackgroundColor: string;
  11867. private _resizeLoadingUI;
  11868. }
  11869. }
  11870. declare module BABYLON {
  11871. class SceneLoaderProgressEvent {
  11872. readonly lengthComputable: boolean;
  11873. readonly loaded: number;
  11874. readonly total: number;
  11875. constructor(lengthComputable: boolean, loaded: number, total: number);
  11876. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11877. }
  11878. interface ISceneLoaderPluginExtensions {
  11879. [extension: string]: {
  11880. isBinary: boolean;
  11881. };
  11882. }
  11883. interface ISceneLoaderPluginFactory {
  11884. name: string;
  11885. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11886. canDirectLoad?: (data: string) => boolean;
  11887. }
  11888. interface ISceneLoaderPlugin {
  11889. /**
  11890. * The friendly name of this plugin.
  11891. */
  11892. name: string;
  11893. /**
  11894. * The file extensions supported by this plugin.
  11895. */
  11896. extensions: string | ISceneLoaderPluginExtensions;
  11897. /**
  11898. * Import meshes into a scene.
  11899. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11900. * @param scene The scene to import into
  11901. * @param data The data to import
  11902. * @param rootUrl The root url for scene and resources
  11903. * @param meshes The meshes array to import into
  11904. * @param particleSystems The particle systems array to import into
  11905. * @param skeletons The skeletons array to import into
  11906. * @param onError The callback when import fails
  11907. * @returns True if successful or false otherwise
  11908. */
  11909. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11910. /**
  11911. * Load into a scene.
  11912. * @param scene The scene to load into
  11913. * @param data The data to import
  11914. * @param rootUrl The root url for scene and resources
  11915. * @param onError The callback when import fails
  11916. * @returns true if successful or false otherwise
  11917. */
  11918. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11919. /**
  11920. * The callback that returns true if the data can be directly loaded.
  11921. */
  11922. canDirectLoad?: (data: string) => boolean;
  11923. /**
  11924. * The callback that allows custom handling of the root url based on the response url.
  11925. */
  11926. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11927. /**
  11928. * Load into an asset container.
  11929. * @param scene The scene to load into
  11930. * @param data The data to import
  11931. * @param rootUrl The root url for scene and resources
  11932. * @param onError The callback when import fails
  11933. * @returns The loaded asset container
  11934. */
  11935. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11936. }
  11937. interface ISceneLoaderPluginAsync {
  11938. /**
  11939. * The friendly name of this plugin.
  11940. */
  11941. name: string;
  11942. /**
  11943. * The file extensions supported by this plugin.
  11944. */
  11945. extensions: string | ISceneLoaderPluginExtensions;
  11946. /**
  11947. * Import meshes into a scene.
  11948. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11949. * @param scene The scene to import into
  11950. * @param data The data to import
  11951. * @param rootUrl The root url for scene and resources
  11952. * @param onProgress The callback when the load progresses
  11953. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11954. */
  11955. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11956. meshes: AbstractMesh[];
  11957. particleSystems: ParticleSystem[];
  11958. skeletons: Skeleton[];
  11959. animationGroups: AnimationGroup[];
  11960. }>;
  11961. /**
  11962. * Load into a scene.
  11963. * @param scene The scene to load into
  11964. * @param data The data to import
  11965. * @param rootUrl The root url for scene and resources
  11966. * @param onProgress The callback when the load progresses
  11967. * @returns Nothing
  11968. */
  11969. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11970. /**
  11971. * The callback that returns true if the data can be directly loaded.
  11972. */
  11973. canDirectLoad?: (data: string) => boolean;
  11974. /**
  11975. * The callback that allows custom handling of the root url based on the response url.
  11976. */
  11977. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11978. /**
  11979. * Load into an asset container.
  11980. * @param scene The scene to load into
  11981. * @param data The data to import
  11982. * @param rootUrl The root url for scene and resources
  11983. * @param onProgress The callback when the load progresses
  11984. * @returns The loaded asset container
  11985. */
  11986. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11987. }
  11988. class SceneLoader {
  11989. private static _ForceFullSceneLoadingForIncremental;
  11990. private static _ShowLoadingScreen;
  11991. private static _CleanBoneMatrixWeights;
  11992. static readonly NO_LOGGING: number;
  11993. static readonly MINIMAL_LOGGING: number;
  11994. static readonly SUMMARY_LOGGING: number;
  11995. static readonly DETAILED_LOGGING: number;
  11996. private static _loggingLevel;
  11997. static ForceFullSceneLoadingForIncremental: boolean;
  11998. static ShowLoadingScreen: boolean;
  11999. static loggingLevel: number;
  12000. static CleanBoneMatrixWeights: boolean;
  12001. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12002. private static _registeredPlugins;
  12003. private static _getDefaultPlugin();
  12004. private static _getPluginForExtension(extension);
  12005. private static _getPluginForDirectLoad(data);
  12006. private static _getPluginForFilename(sceneFilename);
  12007. private static _getDirectLoad(sceneFilename);
  12008. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12009. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12010. static IsPluginForExtensionAvailable(extension: string): boolean;
  12011. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12012. /**
  12013. * Import meshes into a scene
  12014. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12015. * @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)
  12016. * @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)
  12017. * @param scene the instance of BABYLON.Scene to append to
  12018. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12019. * @param onProgress a callback with a progress event for each file being loaded
  12020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12021. * @param pluginExtension the extension used to determine the plugin
  12022. * @returns The loaded plugin
  12023. */
  12024. 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>;
  12025. /**
  12026. * Import meshes into a scene
  12027. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12028. * @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)
  12029. * @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)
  12030. * @param scene the instance of BABYLON.Scene to append to
  12031. * @param onProgress a callback with a progress event for each file being loaded
  12032. * @param pluginExtension the extension used to determine the plugin
  12033. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12034. */
  12035. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12036. meshes: AbstractMesh[];
  12037. particleSystems: ParticleSystem[];
  12038. skeletons: Skeleton[];
  12039. animationGroups: AnimationGroup[];
  12040. }>;
  12041. /**
  12042. * Load a scene
  12043. * @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)
  12044. * @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)
  12045. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12046. * @param onSuccess a callback with the scene when import succeeds
  12047. * @param onProgress a callback with a progress event for each file being loaded
  12048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12049. * @param pluginExtension the extension used to determine the plugin
  12050. * @returns The loaded plugin
  12051. */
  12052. 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>;
  12053. /**
  12054. * Load a scene
  12055. * @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)
  12056. * @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)
  12057. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12058. * @param onProgress a callback with a progress event for each file being loaded
  12059. * @param pluginExtension the extension used to determine the plugin
  12060. * @returns The loaded scene
  12061. */
  12062. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12063. /**
  12064. * Append a scene
  12065. * @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)
  12066. * @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)
  12067. * @param scene is the instance of BABYLON.Scene to append to
  12068. * @param onSuccess a callback with the scene when import succeeds
  12069. * @param onProgress a callback with a progress event for each file being loaded
  12070. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12071. * @param pluginExtension the extension used to determine the plugin
  12072. * @returns The loaded plugin
  12073. */
  12074. 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>;
  12075. /**
  12076. * Append a scene
  12077. * @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)
  12078. * @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)
  12079. * @param scene is the instance of BABYLON.Scene to append to
  12080. * @param onProgress a callback with a progress event for each file being loaded
  12081. * @param pluginExtension the extension used to determine the plugin
  12082. * @returns The given scene
  12083. */
  12084. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12085. /**
  12086. * Load a scene into an asset container
  12087. * @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)
  12088. * @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)
  12089. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12090. * @param onSuccess a callback with the scene when import succeeds
  12091. * @param onProgress a callback with a progress event for each file being loaded
  12092. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12093. * @param pluginExtension the extension used to determine the plugin
  12094. * @returns The loaded plugin
  12095. */
  12096. 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>;
  12097. /**
  12098. * Load a scene into an asset container
  12099. * @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)
  12100. * @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)
  12101. * @param scene is the instance of BABYLON.Scene to append to
  12102. * @param onProgress a callback with a progress event for each file being loaded
  12103. * @param pluginExtension the extension used to determine the plugin
  12104. * @returns The loaded asset container
  12105. */
  12106. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12107. }
  12108. }
  12109. declare module BABYLON {
  12110. class Scalar {
  12111. /**
  12112. * Two pi constants convenient for computation.
  12113. */
  12114. static TwoPi: number;
  12115. /**
  12116. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  12117. */
  12118. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  12119. /**
  12120. * Returns a string : the upper case translation of the number i to hexadecimal.
  12121. */
  12122. static ToHex(i: number): string;
  12123. /**
  12124. * Returns -1 if value is negative and +1 is value is positive.
  12125. * Returns the value itself if it's equal to zero.
  12126. */
  12127. static Sign(value: number): number;
  12128. /**
  12129. * Returns the value itself if it's between min and max.
  12130. * Returns min if the value is lower than min.
  12131. * Returns max if the value is greater than max.
  12132. */
  12133. static Clamp(value: number, min?: number, max?: number): number;
  12134. /**
  12135. * Returns the log2 of value.
  12136. */
  12137. static Log2(value: number): number;
  12138. /**
  12139. * Loops the value, so that it is never larger than length and never smaller than 0.
  12140. *
  12141. * This is similar to the modulo operator but it works with floating point numbers.
  12142. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  12143. * With t = 5 and length = 2.5, the result would be 0.0.
  12144. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  12145. */
  12146. static Repeat(value: number, length: number): number;
  12147. /**
  12148. * Normalize the value between 0.0 and 1.0 using min and max values
  12149. */
  12150. static Normalize(value: number, min: number, max: number): number;
  12151. /**
  12152. * Denormalize the value from 0.0 and 1.0 using min and max values
  12153. */
  12154. static Denormalize(normalized: number, min: number, max: number): number;
  12155. /**
  12156. * Calculates the shortest difference between two given angles given in degrees.
  12157. */
  12158. static DeltaAngle(current: number, target: number): number;
  12159. /**
  12160. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  12161. *
  12162. * The returned value will move back and forth between 0 and length
  12163. */
  12164. static PingPong(tx: number, length: number): number;
  12165. /**
  12166. * Interpolates between min and max with smoothing at the limits.
  12167. *
  12168. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  12169. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  12170. */
  12171. static SmoothStep(from: number, to: number, tx: number): number;
  12172. /**
  12173. * Moves a value current towards target.
  12174. *
  12175. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  12176. * Negative values of maxDelta pushes the value away from target.
  12177. */
  12178. static MoveTowards(current: number, target: number, maxDelta: number): number;
  12179. /**
  12180. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12181. *
  12182. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  12183. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  12184. */
  12185. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  12186. /**
  12187. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  12188. */
  12189. static Lerp(start: number, end: number, amount: number): number;
  12190. /**
  12191. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12192. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  12193. */
  12194. static LerpAngle(start: number, end: number, amount: number): number;
  12195. /**
  12196. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  12197. */
  12198. static InverseLerp(a: number, b: number, value: number): number;
  12199. /**
  12200. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  12201. */
  12202. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  12203. /**
  12204. * Returns a random float number between and min and max values
  12205. */
  12206. static RandomRange(min: number, max: number): number;
  12207. /**
  12208. * This function returns percentage of a number in a given range.
  12209. *
  12210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  12211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  12212. */
  12213. static RangeToPercent(number: number, min: number, max: number): number;
  12214. /**
  12215. * This function returns number that corresponds to the percentage in a given range.
  12216. *
  12217. * PercentToRange(0.34,0,100) will return 34.
  12218. */
  12219. static PercentToRange(percent: number, min: number, max: number): number;
  12220. /**
  12221. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  12222. * @param angle The angle to normalize in radian.
  12223. * @return The converted angle.
  12224. */
  12225. static NormalizeRadians(angle: number): number;
  12226. }
  12227. }
  12228. declare module BABYLON {
  12229. const ToGammaSpace: number;
  12230. const ToLinearSpace = 2.2;
  12231. const Epsilon = 0.001;
  12232. /**
  12233. * Class used to hold a RBG color
  12234. */
  12235. class Color3 {
  12236. /**
  12237. * Defines the red component (between 0 and 1, default is 0)
  12238. */
  12239. r: number;
  12240. /**
  12241. * Defines the green component (between 0 and 1, default is 0)
  12242. */
  12243. g: number;
  12244. /**
  12245. * Defines the blue component (between 0 and 1, default is 0)
  12246. */
  12247. b: number;
  12248. /**
  12249. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  12250. * @param r defines the red component (between 0 and 1, default is 0)
  12251. * @param g defines the green component (between 0 and 1, default is 0)
  12252. * @param b defines the blue component (between 0 and 1, default is 0)
  12253. */
  12254. constructor(
  12255. /**
  12256. * Defines the red component (between 0 and 1, default is 0)
  12257. */
  12258. r?: number,
  12259. /**
  12260. * Defines the green component (between 0 and 1, default is 0)
  12261. */
  12262. g?: number,
  12263. /**
  12264. * Defines the blue component (between 0 and 1, default is 0)
  12265. */
  12266. b?: number);
  12267. /**
  12268. * Creates a string with the Color3 current values
  12269. * @returns the string representation of the Color3 object
  12270. */
  12271. toString(): string;
  12272. /**
  12273. * Returns the string "Color3"
  12274. * @returns "Color3"
  12275. */
  12276. getClassName(): string;
  12277. /**
  12278. * Compute the Color3 hash code
  12279. * @returns an unique number that can be used to hash Color3 objects
  12280. */
  12281. getHashCode(): number;
  12282. /**
  12283. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  12284. * @param array defines the array where to store the r,g,b components
  12285. * @param index defines an optional index in the target array to define where to start storing values
  12286. * @returns the current Color3 object
  12287. */
  12288. toArray(array: FloatArray, index?: number): Color3;
  12289. /**
  12290. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  12291. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  12292. * @returns a new {BABYLON.Color4} object
  12293. */
  12294. toColor4(alpha?: number): Color4;
  12295. /**
  12296. * Returns a new array populated with 3 numeric elements : red, green and blue values
  12297. * @returns the new array
  12298. */
  12299. asArray(): number[];
  12300. /**
  12301. * Returns the luminance value
  12302. * @returns a float value
  12303. */
  12304. toLuminance(): number;
  12305. /**
  12306. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  12307. * @param otherColor defines the second operand
  12308. * @returns the new Color3 object
  12309. */
  12310. multiply(otherColor: Color3): Color3;
  12311. /**
  12312. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  12313. * @param otherColor defines the second operand
  12314. * @param result defines the Color3 object where to store the result
  12315. * @returns the current Color3
  12316. */
  12317. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  12318. /**
  12319. * Determines equality between Color3 objects
  12320. * @param otherColor defines the second operand
  12321. * @returns true if the rgb values are equal to the given ones
  12322. */
  12323. equals(otherColor: Color3): boolean;
  12324. /**
  12325. * Determines equality between the current Color3 object and a set of r,b,g values
  12326. * @param r defines the red component to check
  12327. * @param g defines the green component to check
  12328. * @param b defines the blue component to check
  12329. * @returns true if the rgb values are equal to the given ones
  12330. */
  12331. equalsFloats(r: number, g: number, b: number): boolean;
  12332. /**
  12333. * Multiplies in place each rgb value by scale
  12334. * @param scale defines the scaling factor
  12335. * @returns the updated Color3
  12336. */
  12337. scale(scale: number): Color3;
  12338. /**
  12339. * Multiplies the rgb values by scale and stores the result into "result"
  12340. * @param scale defines the scaling factor
  12341. * @param result defines the Color3 object where to store the result
  12342. * @returns the unmodified current Color3
  12343. */
  12344. scaleToRef(scale: number, result: Color3): Color3;
  12345. /**
  12346. * Scale the current Color3 values by a factor and add the result to a given Color3
  12347. * @param scale defines the scale factor
  12348. * @param result defines color to store the result into
  12349. * @returns the unmodified current Color3
  12350. */
  12351. scaleAndAddToRef(scale: number, result: Color3): Color3;
  12352. /**
  12353. * Clamps the rgb values by the min and max values and stores the result into "result"
  12354. * @param min defines minimum clamping value (default is 0)
  12355. * @param max defines maximum clamping value (default is 1)
  12356. * @param result defines color to store the result into
  12357. * @returns the original Color3
  12358. */
  12359. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  12360. /**
  12361. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  12362. * @param otherColor defines the second operand
  12363. * @returns the new Color3
  12364. */
  12365. add(otherColor: Color3): Color3;
  12366. /**
  12367. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  12368. * @param otherColor defines the second operand
  12369. * @param result defines Color3 object to store the result into
  12370. * @returns the unmodified current Color3
  12371. */
  12372. addToRef(otherColor: Color3, result: Color3): Color3;
  12373. /**
  12374. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  12375. * @param otherColor defines the second operand
  12376. * @returns the new Color3
  12377. */
  12378. subtract(otherColor: Color3): Color3;
  12379. /**
  12380. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  12381. * @param otherColor defines the second operand
  12382. * @param result defines Color3 object to store the result into
  12383. * @returns the unmodified current Color3
  12384. */
  12385. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12386. /**
  12387. * Copy the current object
  12388. * @returns a new Color3 copied the current one
  12389. */
  12390. clone(): Color3;
  12391. /**
  12392. * Copies the rgb values from the source in the current Color3
  12393. * @param source defines the source Color3 object
  12394. * @returns the updated Color3 object
  12395. */
  12396. copyFrom(source: Color3): Color3;
  12397. /**
  12398. * Updates the Color3 rgb values from the given floats
  12399. * @param r defines the red component to read from
  12400. * @param g defines the green component to read from
  12401. * @param b defines the blue component to read from
  12402. * @returns the current Color3 object
  12403. */
  12404. copyFromFloats(r: number, g: number, b: number): Color3;
  12405. /**
  12406. * Updates the Color3 rgb values from the given floats
  12407. * @param r defines the red component to read from
  12408. * @param g defines the green component to read from
  12409. * @param b defines the blue component to read from
  12410. * @returns the current Color3 object
  12411. */
  12412. set(r: number, g: number, b: number): Color3;
  12413. /**
  12414. * Compute the Color3 hexadecimal code as a string
  12415. * @returns a string containing the hexadecimal representation of the Color3 object
  12416. */
  12417. toHexString(): string;
  12418. /**
  12419. * Computes a new Color3 converted from the current one to linear space
  12420. * @returns a new Color3 object
  12421. */
  12422. toLinearSpace(): Color3;
  12423. /**
  12424. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12425. * @param convertedColor defines the Color3 object where to store the linear space version
  12426. * @returns the unmodified Color3
  12427. */
  12428. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12429. /**
  12430. * Computes a new Color3 converted from the current one to gamma space
  12431. * @returns a new Color3 object
  12432. */
  12433. toGammaSpace(): Color3;
  12434. /**
  12435. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12436. * @param convertedColor defines the Color3 object where to store the gamma space version
  12437. * @returns the unmodified Color3
  12438. */
  12439. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12440. /**
  12441. * Creates a new Color3 from the string containing valid hexadecimal values
  12442. * @param hex defines a string containing valid hexadecimal values
  12443. * @returns a new Color3 object
  12444. */
  12445. static FromHexString(hex: string): Color3;
  12446. /**
  12447. * Creates a new Vector3 from the starting index of the given array
  12448. * @param array defines the source array
  12449. * @param offset defines an offset in the source array
  12450. * @returns a new Color3 object
  12451. */
  12452. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12453. /**
  12454. * Creates a new Color3 from integer values (< 256)
  12455. * @param r defines the red component to read from (value between 0 and 255)
  12456. * @param g defines the green component to read from (value between 0 and 255)
  12457. * @param b defines the blue component to read from (value between 0 and 255)
  12458. * @returns a new Color3 object
  12459. */
  12460. static FromInts(r: number, g: number, b: number): Color3;
  12461. /**
  12462. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12463. * @param start defines the start Color3 value
  12464. * @param end defines the end Color3 value
  12465. * @param amount defines the gradient value between start and end
  12466. * @returns a new Color3 object
  12467. */
  12468. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12469. /**
  12470. * Returns a Color3 value containing a red color
  12471. * @returns a new Color3 object
  12472. */
  12473. static Red(): Color3;
  12474. /**
  12475. * Returns a Color3 value containing a green color
  12476. * @returns a new Color3 object
  12477. */
  12478. static Green(): Color3;
  12479. /**
  12480. * Returns a Color3 value containing a blue color
  12481. * @returns a new Color3 object
  12482. */
  12483. static Blue(): Color3;
  12484. /**
  12485. * Returns a Color3 value containing a black color
  12486. * @returns a new Color3 object
  12487. */
  12488. static Black(): Color3;
  12489. /**
  12490. * Returns a Color3 value containing a white color
  12491. * @returns a new Color3 object
  12492. */
  12493. static White(): Color3;
  12494. /**
  12495. * Returns a Color3 value containing a purple color
  12496. * @returns a new Color3 object
  12497. */
  12498. static Purple(): Color3;
  12499. /**
  12500. * Returns a Color3 value containing a magenta color
  12501. * @returns a new Color3 object
  12502. */
  12503. static Magenta(): Color3;
  12504. /**
  12505. * Returns a Color3 value containing a yellow color
  12506. * @returns a new Color3 object
  12507. */
  12508. static Yellow(): Color3;
  12509. /**
  12510. * Returns a Color3 value containing a gray color
  12511. * @returns a new Color3 object
  12512. */
  12513. static Gray(): Color3;
  12514. /**
  12515. * Returns a Color3 value containing a teal color
  12516. * @returns a new Color3 object
  12517. */
  12518. static Teal(): Color3;
  12519. /**
  12520. * Returns a Color3 value containing a random color
  12521. * @returns a new Color3 object
  12522. */
  12523. static Random(): Color3;
  12524. }
  12525. /**
  12526. * Class used to hold a RBGA color
  12527. */
  12528. class Color4 {
  12529. /**
  12530. * Defines the red component (between 0 and 1, default is 0)
  12531. */
  12532. r: number;
  12533. /**
  12534. * Defines the green component (between 0 and 1, default is 0)
  12535. */
  12536. g: number;
  12537. /**
  12538. * Defines the blue component (between 0 and 1, default is 0)
  12539. */
  12540. b: number;
  12541. /**
  12542. * Defines the alpha component (between 0 and 1, default is 1)
  12543. */
  12544. a: number;
  12545. /**
  12546. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12547. * @param r defines the red component (between 0 and 1, default is 0)
  12548. * @param g defines the green component (between 0 and 1, default is 0)
  12549. * @param b defines the blue component (between 0 and 1, default is 0)
  12550. * @param a defines the alpha component (between 0 and 1, default is 1)
  12551. */
  12552. constructor(
  12553. /**
  12554. * Defines the red component (between 0 and 1, default is 0)
  12555. */
  12556. r?: number,
  12557. /**
  12558. * Defines the green component (between 0 and 1, default is 0)
  12559. */
  12560. g?: number,
  12561. /**
  12562. * Defines the blue component (between 0 and 1, default is 0)
  12563. */
  12564. b?: number,
  12565. /**
  12566. * Defines the alpha component (between 0 and 1, default is 1)
  12567. */
  12568. a?: number);
  12569. /**
  12570. * Adds in place the given Color4 values to the current Color4 object
  12571. * @param right defines the second operand
  12572. * @returns the current updated Color4 object
  12573. */
  12574. addInPlace(right: Color4): Color4;
  12575. /**
  12576. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12577. * @returns the new array
  12578. */
  12579. asArray(): number[];
  12580. /**
  12581. * Stores from the starting index in the given array the Color4 successive values
  12582. * @param array defines the array where to store the r,g,b components
  12583. * @param index defines an optional index in the target array to define where to start storing values
  12584. * @returns the current Color4 object
  12585. */
  12586. toArray(array: number[], index?: number): Color4;
  12587. /**
  12588. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12589. * @param right defines the second operand
  12590. * @returns a new Color4 object
  12591. */
  12592. add(right: Color4): Color4;
  12593. /**
  12594. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12595. * @param right defines the second operand
  12596. * @returns a new Color4 object
  12597. */
  12598. subtract(right: Color4): Color4;
  12599. /**
  12600. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12601. * @param right defines the second operand
  12602. * @param result defines the Color4 object where to store the result
  12603. * @returns the current Color4 object
  12604. */
  12605. subtractToRef(right: Color4, result: Color4): Color4;
  12606. /**
  12607. * Creates a new Color4 with the current Color4 values multiplied by scale
  12608. * @param scale defines the scaling factor to apply
  12609. * @returns a new Color4 object
  12610. */
  12611. scale(scale: number): Color4;
  12612. /**
  12613. * Multiplies the current Color4 values by scale and stores the result in "result"
  12614. * @param scale defines the scaling factor to apply
  12615. * @param result defines the Color4 object where to store the result
  12616. * @returns the current unmodified Color4
  12617. */
  12618. scaleToRef(scale: number, result: Color4): Color4;
  12619. /**
  12620. * Scale the current Color4 values by a factor and add the result to a given Color4
  12621. * @param scale defines the scale factor
  12622. * @param result defines the Color4 object where to store the result
  12623. * @returns the unmodified current Color4
  12624. */
  12625. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12626. /**
  12627. * Clamps the rgb values by the min and max values and stores the result into "result"
  12628. * @param min defines minimum clamping value (default is 0)
  12629. * @param max defines maximum clamping value (default is 1)
  12630. * @param result defines color to store the result into.
  12631. * @returns the cuurent Color4
  12632. */
  12633. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12634. /**
  12635. * Multipy an Color4 value by another and return a new Color4 object
  12636. * @param color defines the Color4 value to multiply by
  12637. * @returns a new Color4 object
  12638. */
  12639. multiply(color: Color4): Color4;
  12640. /**
  12641. * Multipy a Color4 value by another and push the result in a reference value
  12642. * @param color defines the Color4 value to multiply by
  12643. * @param result defines the Color4 to fill the result in
  12644. * @returns the result Color4
  12645. */
  12646. multiplyToRef(color: Color4, result: Color4): Color4;
  12647. /**
  12648. * Creates a string with the Color4 current values
  12649. * @returns the string representation of the Color4 object
  12650. */
  12651. toString(): string;
  12652. /**
  12653. * Returns the string "Color4"
  12654. * @returns "Color4"
  12655. */
  12656. getClassName(): string;
  12657. /**
  12658. * Compute the Color4 hash code
  12659. * @returns an unique number that can be used to hash Color4 objects
  12660. */
  12661. getHashCode(): number;
  12662. /**
  12663. * Creates a new Color4 copied from the current one
  12664. * @returns a new Color4 object
  12665. */
  12666. clone(): Color4;
  12667. /**
  12668. * Copies the given Color4 values into the current one
  12669. * @param source defines the source Color4 object
  12670. * @returns the current updated Color4 object
  12671. */
  12672. copyFrom(source: Color4): Color4;
  12673. /**
  12674. * Copies the given float values into the current one
  12675. * @param r defines the red component to read from
  12676. * @param g defines the green component to read from
  12677. * @param b defines the blue component to read from
  12678. * @param a defines the alpha component to read from
  12679. * @returns the current updated Color4 object
  12680. */
  12681. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12682. /**
  12683. * Copies the given float values into the current one
  12684. * @param r defines the red component to read from
  12685. * @param g defines the green component to read from
  12686. * @param b defines the blue component to read from
  12687. * @param a defines the alpha component to read from
  12688. * @returns the current updated Color4 object
  12689. */
  12690. set(r: number, g: number, b: number, a: number): Color4;
  12691. /**
  12692. * Compute the Color4 hexadecimal code as a string
  12693. * @returns a string containing the hexadecimal representation of the Color4 object
  12694. */
  12695. toHexString(): string;
  12696. /**
  12697. * Computes a new Color4 converted from the current one to linear space
  12698. * @returns a new Color4 object
  12699. */
  12700. toLinearSpace(): Color4;
  12701. /**
  12702. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12703. * @param convertedColor defines the Color4 object where to store the linear space version
  12704. * @returns the unmodified Color4
  12705. */
  12706. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12707. /**
  12708. * Computes a new Color4 converted from the current one to gamma space
  12709. * @returns a new Color4 object
  12710. */
  12711. toGammaSpace(): Color4;
  12712. /**
  12713. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12714. * @param convertedColor defines the Color4 object where to store the gamma space version
  12715. * @returns the unmodified Color4
  12716. */
  12717. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12718. /**
  12719. * Creates a new Color4 from the string containing valid hexadecimal values
  12720. * @param hex defines a string containing valid hexadecimal values
  12721. * @returns a new Color4 object
  12722. */
  12723. static FromHexString(hex: string): Color4;
  12724. /**
  12725. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12726. * @param left defines the start value
  12727. * @param right defines the end value
  12728. * @param amount defines the gradient factor
  12729. * @returns a new Color4 object
  12730. */
  12731. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12732. /**
  12733. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12734. * @param left defines the start value
  12735. * @param right defines the end value
  12736. * @param amount defines the gradient factor
  12737. * @param result defines the Color4 object where to store data
  12738. */
  12739. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12740. /**
  12741. * Creates a new Color4 from the starting index element of the given array
  12742. * @param array defines the source array to read from
  12743. * @param offset defines the offset in the source array
  12744. * @returns a new Color4 object
  12745. */
  12746. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12747. /**
  12748. * Creates a new Color3 from integer values (< 256)
  12749. * @param r defines the red component to read from (value between 0 and 255)
  12750. * @param g defines the green component to read from (value between 0 and 255)
  12751. * @param b defines the blue component to read from (value between 0 and 255)
  12752. * @param a defines the alpha component to read from (value between 0 and 255)
  12753. * @returns a new Color3 object
  12754. */
  12755. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12756. /**
  12757. * Check the content of a given array and convert it to an array containing RGBA data
  12758. * If the original array was already containing count * 4 values then it is returned directly
  12759. * @param colors defines the array to check
  12760. * @param count defines the number of RGBA data to expect
  12761. * @returns an array containing count * 4 values (RGBA)
  12762. */
  12763. static CheckColors4(colors: number[], count: number): number[];
  12764. }
  12765. /**
  12766. * Class representing a vector containing 2 coordinates
  12767. */
  12768. class Vector2 {
  12769. /** defines the first coordinate */
  12770. x: number;
  12771. /** defines the second coordinate */
  12772. y: number;
  12773. /**
  12774. * Creates a new Vector2 from the given x and y coordinates
  12775. * @param x defines the first coordinate
  12776. * @param y defines the second coordinate
  12777. */
  12778. constructor(
  12779. /** defines the first coordinate */
  12780. x: number,
  12781. /** defines the second coordinate */
  12782. y: number);
  12783. /**
  12784. * Gets a string with the Vector2 coordinates
  12785. * @returns a string with the Vector2 coordinates
  12786. */
  12787. toString(): string;
  12788. /**
  12789. * Gets class name
  12790. * @returns the string "Vector2"
  12791. */
  12792. getClassName(): string;
  12793. /**
  12794. * Gets current vector hash code
  12795. * @returns the Vector2 hash code as a number
  12796. */
  12797. getHashCode(): number;
  12798. /**
  12799. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  12800. * @param array defines the source array
  12801. * @param index defines the offset in source array
  12802. * @returns the current Vector2
  12803. */
  12804. toArray(array: FloatArray, index?: number): Vector2;
  12805. /**
  12806. * Copy the current vector to an array
  12807. * @returns a new array with 2 elements: the Vector2 coordinates.
  12808. */
  12809. asArray(): number[];
  12810. /**
  12811. * Sets the Vector2 coordinates with the given Vector2 coordinates
  12812. * @param source defines the source Vector2
  12813. * @returns the current updated Vector2
  12814. */
  12815. copyFrom(source: Vector2): Vector2;
  12816. /**
  12817. * Sets the Vector2 coordinates with the given floats
  12818. * @param x defines the first coordinate
  12819. * @param y defines the second coordinate
  12820. * @returns the current updated Vector2
  12821. */
  12822. copyFromFloats(x: number, y: number): Vector2;
  12823. /**
  12824. * Sets the Vector2 coordinates with the given floats
  12825. * @param x defines the first coordinate
  12826. * @param y defines the second coordinate
  12827. * @returns the current updated Vector2
  12828. */
  12829. set(x: number, y: number): Vector2;
  12830. /**
  12831. * Add another vector with the current one
  12832. * @param otherVector defines the other vector
  12833. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  12834. */
  12835. add(otherVector: Vector2): Vector2;
  12836. /**
  12837. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  12838. * @param otherVector defines the other vector
  12839. * @param result defines the target vector
  12840. * @returns the unmodified current Vector2
  12841. */
  12842. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  12843. /**
  12844. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  12845. * @param otherVector defines the other vector
  12846. * @returns the current updated Vector2
  12847. */
  12848. addInPlace(otherVector: Vector2): Vector2;
  12849. /**
  12850. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  12851. * @param otherVector defines the other vector
  12852. * @returns a new Vector2
  12853. */
  12854. addVector3(otherVector: Vector3): Vector2;
  12855. /**
  12856. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  12857. * @param otherVector defines the other vector
  12858. * @returns a new Vector2
  12859. */
  12860. subtract(otherVector: Vector2): Vector2;
  12861. /**
  12862. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  12863. * @param otherVector defines the other vector
  12864. * @param result defines the target vector
  12865. * @returns the unmodified current Vector2
  12866. */
  12867. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  12868. /**
  12869. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  12870. * @param otherVector defines the other vector
  12871. * @returns the current updated Vector2
  12872. */
  12873. subtractInPlace(otherVector: Vector2): Vector2;
  12874. /**
  12875. * Multiplies in place the current Vector2 coordinates by the given ones
  12876. * @param otherVector defines the other vector
  12877. * @returns the current updated Vector2
  12878. */
  12879. multiplyInPlace(otherVector: Vector2): Vector2;
  12880. /**
  12881. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  12882. * @param otherVector defines the other vector
  12883. * @returns a new Vector2
  12884. */
  12885. multiply(otherVector: Vector2): Vector2;
  12886. /**
  12887. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  12888. * @param otherVector defines the other vector
  12889. * @param result defines the target vector
  12890. * @returns the unmodified current Vector2
  12891. */
  12892. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  12893. /**
  12894. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  12895. * @param x defines the first coordinate
  12896. * @param y defines the second coordinate
  12897. * @returns a new Vector2
  12898. */
  12899. multiplyByFloats(x: number, y: number): Vector2;
  12900. /**
  12901. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  12902. * @param otherVector defines the other vector
  12903. * @returns a new Vector2
  12904. */
  12905. divide(otherVector: Vector2): Vector2;
  12906. /**
  12907. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  12908. * @param otherVector defines the other vector
  12909. * @param result defines the target vector
  12910. * @returns the unmodified current Vector2
  12911. */
  12912. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  12913. /**
  12914. * Divides the current Vector3 coordinates by the given ones
  12915. * @param otherVector defines the other vector
  12916. * @returns the current updated Vector2
  12917. */
  12918. divideInPlace(otherVector: Vector2): Vector2;
  12919. /**
  12920. * Gets a new Vector2 with current Vector2 negated coordinates
  12921. * @returns a new Vector2
  12922. */
  12923. negate(): Vector2;
  12924. /**
  12925. * Multiply the Vector2 coordinates by scale
  12926. * @param scale defines the scaling factor
  12927. * @returns the current updated Vector2
  12928. */
  12929. scaleInPlace(scale: number): Vector2;
  12930. /**
  12931. * Returns a new Vector2 scaled by "scale" from the current Vector2
  12932. * @param scale defines the scaling factor
  12933. * @returns a new Vector2
  12934. */
  12935. scale(scale: number): Vector2;
  12936. /**
  12937. * Scale the current Vector2 values by a factor to a given Vector2
  12938. * @param scale defines the scale factor
  12939. * @param result defines the Vector2 object where to store the result
  12940. * @returns the unmodified current Vector2
  12941. */
  12942. scaleToRef(scale: number, result: Vector2): Vector2;
  12943. /**
  12944. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  12945. * @param scale defines the scale factor
  12946. * @param result defines the Vector2 object where to store the result
  12947. * @returns the unmodified current Vector2
  12948. */
  12949. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  12950. /**
  12951. * Gets a boolean if two vectors are equals
  12952. * @param otherVector defines the other vector
  12953. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  12954. */
  12955. equals(otherVector: Vector2): boolean;
  12956. /**
  12957. * Gets a boolean if two vectors are equals (using an epsilon value)
  12958. * @param otherVector defines the other vector
  12959. * @param epsilon defines the minimal distance to consider equality
  12960. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  12961. */
  12962. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  12963. /**
  12964. * Gets the length of the vector
  12965. * @returns the vector length (float)
  12966. */
  12967. length(): number;
  12968. /**
  12969. * Gets the vector squared length
  12970. * @returns the vector squared length (float)
  12971. */
  12972. lengthSquared(): number;
  12973. /**
  12974. * Normalize the vector
  12975. * @returns the current updated Vector2
  12976. */
  12977. normalize(): Vector2;
  12978. /**
  12979. * Gets a new Vector2 copied from the Vector2
  12980. * @returns a new Vector2
  12981. */
  12982. clone(): Vector2;
  12983. /**
  12984. * Gets a new Vector2(0, 0)
  12985. * @returns a new Vector2
  12986. */
  12987. static Zero(): Vector2;
  12988. /**
  12989. * Gets a new Vector2(1, 1)
  12990. * @returns a new Vector2
  12991. */
  12992. static One(): Vector2;
  12993. /**
  12994. * Gets a new Vector2 set from the given index element of the given array
  12995. * @param array defines the data source
  12996. * @param offset defines the offset in the data source
  12997. * @returns a new Vector2
  12998. */
  12999. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  13000. /**
  13001. * Sets "result" from the given index element of the given array
  13002. * @param array defines the data source
  13003. * @param offset defines the offset in the data source
  13004. * @param result defines the target vector
  13005. */
  13006. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  13007. /**
  13008. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  13009. * @param value1 defines 1st point of control
  13010. * @param value2 defines 2nd point of control
  13011. * @param value3 defines 3rd point of control
  13012. * @param value4 defines 4th point of control
  13013. * @param amount defines the interpolation factor
  13014. * @returns a new Vector2
  13015. */
  13016. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  13017. /**
  13018. * 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".
  13019. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  13020. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  13021. * @param value defines the value to clamp
  13022. * @param min defines the lower limit
  13023. * @param max defines the upper limit
  13024. * @returns a new Vector2
  13025. */
  13026. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  13027. /**
  13028. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  13029. * @param value1 defines the 1st control point
  13030. * @param tangent1 defines the outgoing tangent
  13031. * @param value2 defines the 2nd control point
  13032. * @param tangent2 defines the incoming tangent
  13033. * @param amount defines the interpolation factor
  13034. * @returns a new Vector2
  13035. */
  13036. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  13037. /**
  13038. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  13039. * @param start defines the start vector
  13040. * @param end defines the end vector
  13041. * @param amount defines the interpolation factor
  13042. * @returns a new Vector2
  13043. */
  13044. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  13045. /**
  13046. * Gets the dot product of the vector "left" and the vector "right"
  13047. * @param left defines first vector
  13048. * @param right defines second vector
  13049. * @returns the dot product (float)
  13050. */
  13051. static Dot(left: Vector2, right: Vector2): number;
  13052. /**
  13053. * Returns a new Vector2 equal to the normalized given vector
  13054. * @param vector defines the vector to normalize
  13055. * @returns a new Vector2
  13056. */
  13057. static Normalize(vector: Vector2): Vector2;
  13058. /**
  13059. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  13060. * @param left defines 1st vector
  13061. * @param right defines 2nd vector
  13062. * @returns a new Vector2
  13063. */
  13064. static Minimize(left: Vector2, right: Vector2): Vector2;
  13065. /**
  13066. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  13067. * @param left defines 1st vector
  13068. * @param right defines 2nd vector
  13069. * @returns a new Vector2
  13070. */
  13071. static Maximize(left: Vector2, right: Vector2): Vector2;
  13072. /**
  13073. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  13074. * @param vector defines the vector to transform
  13075. * @param transformation defines the matrix to apply
  13076. * @returns a new Vector2
  13077. */
  13078. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  13079. /**
  13080. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  13081. * @param vector defines the vector to transform
  13082. * @param transformation defines the matrix to apply
  13083. * @param result defines the target vector
  13084. */
  13085. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  13086. /**
  13087. * Determines if a given vector is included in a triangle
  13088. * @param p defines the vector to test
  13089. * @param p0 defines 1st triangle point
  13090. * @param p1 defines 2nd triangle point
  13091. * @param p2 defines 3rd triangle point
  13092. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  13093. */
  13094. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  13095. /**
  13096. * Gets the distance between the vectors "value1" and "value2"
  13097. * @param value1 defines first vector
  13098. * @param value2 defines second vector
  13099. * @returns the distance between vectors
  13100. */
  13101. static Distance(value1: Vector2, value2: Vector2): number;
  13102. /**
  13103. * Returns the squared distance between the vectors "value1" and "value2"
  13104. * @param value1 defines first vector
  13105. * @param value2 defines second vector
  13106. * @returns the squared distance between vectors
  13107. */
  13108. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  13109. /**
  13110. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  13111. * @param value1 defines first vector
  13112. * @param value2 defines second vector
  13113. * @returns a new Vector2
  13114. */
  13115. static Center(value1: Vector2, value2: Vector2): Vector2;
  13116. /**
  13117. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  13118. * @param p defines the middle point
  13119. * @param segA defines one point of the segment
  13120. * @param segB defines the other point of the segment
  13121. * @returns the shortest distance
  13122. */
  13123. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  13124. }
  13125. /**
  13126. * Classed used to store (x,y,z) vector representation
  13127. * A Vector3 is the main object used in 3D geometry
  13128. * It can represent etiher the coordinates of a point the space, either a direction
  13129. * Reminder: Babylon.js uses a left handed forward facing system
  13130. */
  13131. class Vector3 {
  13132. /**
  13133. * Defines the first coordinates (on X axis)
  13134. */
  13135. x: number;
  13136. /**
  13137. * Defines the second coordinates (on Y axis)
  13138. */
  13139. y: number;
  13140. /**
  13141. * Defines the third coordinates (on Z axis)
  13142. */
  13143. z: number;
  13144. /**
  13145. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  13146. * @param x defines the first coordinates (on X axis)
  13147. * @param y defines the second coordinates (on Y axis)
  13148. * @param z defines the third coordinates (on Z axis)
  13149. */
  13150. constructor(
  13151. /**
  13152. * Defines the first coordinates (on X axis)
  13153. */
  13154. x: number,
  13155. /**
  13156. * Defines the second coordinates (on Y axis)
  13157. */
  13158. y: number,
  13159. /**
  13160. * Defines the third coordinates (on Z axis)
  13161. */
  13162. z: number);
  13163. /**
  13164. * Creates a string representation of the Vector3
  13165. * @returns a string with the Vector3 coordinates.
  13166. */
  13167. toString(): string;
  13168. /**
  13169. * Gets the class name
  13170. * @returns the string "Vector3"
  13171. */
  13172. getClassName(): string;
  13173. /**
  13174. * Creates the Vector3 hash code
  13175. * @returns a number which tends to be unique between Vector3 instances
  13176. */
  13177. getHashCode(): number;
  13178. /**
  13179. * Creates an array containing three elements : the coordinates of the Vector3
  13180. * @returns a new array of numbers
  13181. */
  13182. asArray(): number[];
  13183. /**
  13184. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  13185. * @param array defines the destination array
  13186. * @param index defines the offset in the destination array
  13187. * @returns the current Vector3
  13188. */
  13189. toArray(array: FloatArray, index?: number): Vector3;
  13190. /**
  13191. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  13192. * @returns a new Quaternion object, computed from the Vector3 coordinates
  13193. */
  13194. toQuaternion(): Quaternion;
  13195. /**
  13196. * Adds the given vector to the current Vector3
  13197. * @param otherVector defines the second operand
  13198. * @returns the current updated Vector3
  13199. */
  13200. addInPlace(otherVector: Vector3): Vector3;
  13201. /**
  13202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  13203. * @param otherVector defines the second operand
  13204. * @returns the resulting Vector3
  13205. */
  13206. add(otherVector: Vector3): Vector3;
  13207. /**
  13208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  13209. * @param otherVector defines the second operand
  13210. * @param result defines the Vector3 object where to store the result
  13211. * @returns the current Vector3
  13212. */
  13213. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  13214. /**
  13215. * Subtract the given vector from the current Vector3
  13216. * @param otherVector defines the second operand
  13217. * @returns the current updated Vector3
  13218. */
  13219. subtractInPlace(otherVector: Vector3): Vector3;
  13220. /**
  13221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  13222. * @param otherVector defines the second operand
  13223. * @returns the resulting Vector3
  13224. */
  13225. subtract(otherVector: Vector3): Vector3;
  13226. /**
  13227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  13228. * @param otherVector defines the second operand
  13229. * @param result defines the Vector3 object where to store the result
  13230. * @returns the current Vector3
  13231. */
  13232. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  13233. /**
  13234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  13235. * @param x defines the x coordinate of the operand
  13236. * @param y defines the y coordinate of the operand
  13237. * @param z defines the z coordinate of the operand
  13238. * @returns the resulting Vector3
  13239. */
  13240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  13241. /**
  13242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  13243. * @param x defines the x coordinate of the operand
  13244. * @param y defines the y coordinate of the operand
  13245. * @param z defines the z coordinate of the operand
  13246. * @param result defines the Vector3 object where to store the result
  13247. * @returns the current Vector3
  13248. */
  13249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  13250. /**
  13251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  13252. * @returns a new Vector3
  13253. */
  13254. negate(): Vector3;
  13255. /**
  13256. * Multiplies the Vector3 coordinates by the float "scale"
  13257. * @param scale defines the multiplier factor
  13258. * @returns the current updated Vector3
  13259. */
  13260. scaleInPlace(scale: number): Vector3;
  13261. /**
  13262. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  13263. * @param scale defines the multiplier factor
  13264. * @returns a new Vector3
  13265. */
  13266. scale(scale: number): Vector3;
  13267. /**
  13268. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  13269. * @param scale defines the multiplier factor
  13270. * @param result defines the Vector3 object where to store the result
  13271. * @returns the current Vector3
  13272. */
  13273. scaleToRef(scale: number, result: Vector3): Vector3;
  13274. /**
  13275. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  13276. * @param scale defines the scale factor
  13277. * @param result defines the Vector3 object where to store the result
  13278. * @returns the unmodified current Vector3
  13279. */
  13280. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  13281. /**
  13282. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  13283. * @param otherVector defines the second operand
  13284. * @returns true if both vectors are equals
  13285. */
  13286. equals(otherVector: Vector3): boolean;
  13287. /**
  13288. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  13289. * @param otherVector defines the second operand
  13290. * @param epsilon defines the minimal distance to define values as equals
  13291. * @returns true if both vectors are distant less than epsilon
  13292. */
  13293. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  13294. /**
  13295. * Returns true if the current Vector3 coordinates equals the given floats
  13296. * @param x defines the x coordinate of the operand
  13297. * @param y defines the y coordinate of the operand
  13298. * @param z defines the z coordinate of the operand
  13299. * @returns true if both vectors are equals
  13300. */
  13301. equalsToFloats(x: number, y: number, z: number): boolean;
  13302. /**
  13303. * Multiplies the current Vector3 coordinates by the given ones
  13304. * @param otherVector defines the second operand
  13305. * @returns the current updated Vector3
  13306. */
  13307. multiplyInPlace(otherVector: Vector3): Vector3;
  13308. /**
  13309. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  13310. * @param otherVector defines the second operand
  13311. * @returns the new Vector3
  13312. */
  13313. multiply(otherVector: Vector3): Vector3;
  13314. /**
  13315. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  13316. * @param otherVector defines the second operand
  13317. * @param result defines the Vector3 object where to store the result
  13318. * @returns the current Vector3
  13319. */
  13320. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  13321. /**
  13322. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  13323. * @param x defines the x coordinate of the operand
  13324. * @param y defines the y coordinate of the operand
  13325. * @param z defines the z coordinate of the operand
  13326. * @returns the new Vector3
  13327. */
  13328. multiplyByFloats(x: number, y: number, z: number): Vector3;
  13329. /**
  13330. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  13331. * @param otherVector defines the second operand
  13332. * @returns the new Vector3
  13333. */
  13334. divide(otherVector: Vector3): Vector3;
  13335. /**
  13336. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  13337. * @param otherVector defines the second operand
  13338. * @param result defines the Vector3 object where to store the result
  13339. * @returns the current Vector3
  13340. */
  13341. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  13342. /**
  13343. * Divides the current Vector3 coordinates by the given ones.
  13344. * @param otherVector defines the second operand
  13345. * @returns the current updated Vector3
  13346. */
  13347. divideInPlace(otherVector: Vector3): Vector3;
  13348. /**
  13349. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  13350. * @param other defines the second operand
  13351. * @returns the current updated Vector3
  13352. */
  13353. minimizeInPlace(other: Vector3): Vector3;
  13354. /**
  13355. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  13356. * @param other defines the second operand
  13357. * @returns the current updated Vector3
  13358. */
  13359. maximizeInPlace(other: Vector3): Vector3;
  13360. /**
  13361. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  13362. */
  13363. readonly isNonUniform: boolean;
  13364. /**
  13365. * Gets the length of the Vector3
  13366. * @returns the length of the Vecto3
  13367. */
  13368. length(): number;
  13369. /**
  13370. * Gets the squared length of the Vector3
  13371. * @returns squared length of the Vector3
  13372. */
  13373. lengthSquared(): number;
  13374. /**
  13375. * Normalize the current Vector3.
  13376. * Please note that this is an in place operation.
  13377. * @returns the current updated Vector3
  13378. */
  13379. normalize(): Vector3;
  13380. /**
  13381. * Normalize the current Vector3 to a new vector
  13382. * @returns the new Vector3
  13383. */
  13384. normalizeToNew(): Vector3;
  13385. /**
  13386. * Normalize the current Vector3 to the reference
  13387. * @param reference define the Vector3 to update
  13388. * @returns the updated Vector3
  13389. */
  13390. normalizeToRef(reference: Vector3): Vector3;
  13391. /**
  13392. * Creates a new Vector3 copied from the current Vector3
  13393. * @returns the new Vector3
  13394. */
  13395. clone(): Vector3;
  13396. /**
  13397. * Copies the given vector coordinates to the current Vector3 ones
  13398. * @param source defines the source Vector3
  13399. * @returns the current updated Vector3
  13400. */
  13401. copyFrom(source: Vector3): Vector3;
  13402. /**
  13403. * Copies the given floats to the current Vector3 coordinates
  13404. * @param x defines the x coordinate of the operand
  13405. * @param y defines the y coordinate of the operand
  13406. * @param z defines the z coordinate of the operand
  13407. * @returns the current updated Vector3
  13408. */
  13409. copyFromFloats(x: number, y: number, z: number): Vector3;
  13410. /**
  13411. * Copies the given floats to the current Vector3 coordinates
  13412. * @param x defines the x coordinate of the operand
  13413. * @param y defines the y coordinate of the operand
  13414. * @param z defines the z coordinate of the operand
  13415. * @returns the current updated Vector3
  13416. */
  13417. set(x: number, y: number, z: number): Vector3;
  13418. /**
  13419. * Get the clip factor between two vectors
  13420. * @param vector0 defines the first operand
  13421. * @param vector1 defines the second operand
  13422. * @param axis defines the axis to use
  13423. * @param size defines the size along the axis
  13424. * @returns the clip factor
  13425. */
  13426. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13427. /**
  13428. * Get angle between two vectors
  13429. * @param vector0 angle between vector0 and vector1
  13430. * @param vector1 angle between vector0 and vector1
  13431. * @param normal direction of the normal
  13432. * @return the angle between vector0 and vector1
  13433. */
  13434. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13435. /**
  13436. * Returns a new Vector3 set from the index "offset" of the given array
  13437. * @param array defines the source array
  13438. * @param offset defines the offset in the source array
  13439. * @returns the new Vector3
  13440. */
  13441. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13442. /**
  13443. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  13444. * This function is deprecated. Use FromArray instead
  13445. * @param array defines the source array
  13446. * @param offset defines the offset in the source array
  13447. * @returns the new Vector3
  13448. */
  13449. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13450. /**
  13451. * Sets the given vector "result" with the element values from the index "offset" of the given array
  13452. * @param array defines the source array
  13453. * @param offset defines the offset in the source array
  13454. * @param result defines the Vector3 where to store the result
  13455. */
  13456. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13457. /**
  13458. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  13459. * This function is deprecated. Use FromArrayToRef instead.
  13460. * @param array defines the source array
  13461. * @param offset defines the offset in the source array
  13462. * @param result defines the Vector3 where to store the result
  13463. */
  13464. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13465. /**
  13466. * Sets the given vector "result" with the given floats.
  13467. * @param x defines the x coordinate of the source
  13468. * @param y defines the y coordinate of the source
  13469. * @param z defines the z coordinate of the source
  13470. * @param result defines the Vector3 where to store the result
  13471. */
  13472. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13473. /**
  13474. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  13475. * @returns a new empty Vector3
  13476. */
  13477. static Zero(): Vector3;
  13478. /**
  13479. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  13480. * @returns a new unit Vector3
  13481. */
  13482. static One(): Vector3;
  13483. /**
  13484. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13485. * @returns a new up Vector3
  13486. */
  13487. static Up(): Vector3;
  13488. /**
  13489. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13490. * @returns a new forward Vector3
  13491. */
  13492. static Forward(): Vector3;
  13493. /**
  13494. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13495. * @returns a new right Vector3
  13496. */
  13497. static Right(): Vector3;
  13498. /**
  13499. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13500. * @returns a new left Vector3
  13501. */
  13502. static Left(): Vector3;
  13503. /**
  13504. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  13505. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13506. * @param vector defines the Vector3 to transform
  13507. * @param transformation defines the transformation matrix
  13508. * @returns the transformed Vector3
  13509. */
  13510. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13511. /**
  13512. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  13513. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13514. * @param vector defines the Vector3 to transform
  13515. * @param transformation defines the transformation matrix
  13516. * @param result defines the Vector3 where to store the result
  13517. */
  13518. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13519. /**
  13520. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  13521. * This method computes tranformed coordinates only, not transformed direction vectors
  13522. * @param x define the x coordinate of the source vector
  13523. * @param y define the y coordinate of the source vector
  13524. * @param z define the z coordinate of the source vector
  13525. * @param transformation defines the transformation matrix
  13526. * @param result defines the Vector3 where to store the result
  13527. */
  13528. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13529. /**
  13530. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  13531. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13532. * @param vector defines the Vector3 to transform
  13533. * @param transformation defines the transformation matrix
  13534. * @returns the new Vector3
  13535. */
  13536. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13537. /**
  13538. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  13539. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13540. * @param vector defines the Vector3 to transform
  13541. * @param transformation defines the transformation matrix
  13542. * @param result defines the Vector3 where to store the result
  13543. */
  13544. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13545. /**
  13546. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13547. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13548. * @param x define the x coordinate of the source vector
  13549. * @param y define the y coordinate of the source vector
  13550. * @param z define the z coordinate of the source vector
  13551. * @param transformation defines the transformation matrix
  13552. * @param result defines the Vector3 where to store the result
  13553. */
  13554. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13555. /**
  13556. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13557. * @param value1 defines the first control point
  13558. * @param value2 defines the second control point
  13559. * @param value3 defines the third control point
  13560. * @param value4 defines the fourth control point
  13561. * @param amount defines the amount on the spline to use
  13562. * @returns the new Vector3
  13563. */
  13564. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13565. /**
  13566. * 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"
  13567. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13568. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13569. * @param value defines the current value
  13570. * @param min defines the lower range value
  13571. * @param max defines the upper range value
  13572. * @returns the new Vector3
  13573. */
  13574. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13575. /**
  13576. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13577. * @param value1 defines the first control point
  13578. * @param tangent1 defines the first tangent vector
  13579. * @param value2 defines the second control point
  13580. * @param tangent2 defines the second tangent vector
  13581. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13582. * @returns the new Vector3
  13583. */
  13584. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13585. /**
  13586. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13587. * @param start defines the start value
  13588. * @param end defines the end value
  13589. * @param amount max defines amount between both (between 0 and 1)
  13590. * @returns the new Vector3
  13591. */
  13592. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13593. /**
  13594. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13595. * @param start defines the start value
  13596. * @param end defines the end value
  13597. * @param amount max defines amount between both (between 0 and 1)
  13598. * @param result defines the Vector3 where to store the result
  13599. */
  13600. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13601. /**
  13602. * Returns the dot product (float) between the vectors "left" and "right"
  13603. * @param left defines the left operand
  13604. * @param right defines the right operand
  13605. * @returns the dot product
  13606. */
  13607. static Dot(left: Vector3, right: Vector3): number;
  13608. /**
  13609. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13610. * The cross product is then orthogonal to both "left" and "right"
  13611. * @param left defines the left operand
  13612. * @param right defines the right operand
  13613. * @returns the cross product
  13614. */
  13615. static Cross(left: Vector3, right: Vector3): Vector3;
  13616. /**
  13617. * Sets the given vector "result" with the cross product of "left" and "right"
  13618. * The cross product is then orthogonal to both "left" and "right"
  13619. * @param left defines the left operand
  13620. * @param right defines the right operand
  13621. * @param result defines the Vector3 where to store the result
  13622. */
  13623. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13624. /**
  13625. * Returns a new Vector3 as the normalization of the given vector
  13626. * @param vector defines the Vector3 to normalize
  13627. * @returns the new Vector3
  13628. */
  13629. static Normalize(vector: Vector3): Vector3;
  13630. /**
  13631. * Sets the given vector "result" with the normalization of the given first vector
  13632. * @param vector defines the Vector3 to normalize
  13633. * @param result defines the Vector3 where to store the result
  13634. */
  13635. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13636. private static _viewportMatrixCache;
  13637. /**
  13638. * Project a Vector3 onto screen space
  13639. * @param vector defines the Vector3 to project
  13640. * @param world defines the world matrix to use
  13641. * @param transform defines the transform (view x projection) matrix to use
  13642. * @param viewport defines the screen viewport to use
  13643. * @returns the new Vector3
  13644. */
  13645. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13646. /**
  13647. * Unproject from screen space to object space
  13648. * @param source defines the screen space Vector3 to use
  13649. * @param viewportWidth defines the current width of the viewport
  13650. * @param viewportHeight defines the current height of the viewport
  13651. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13652. * @param transform defines the transform (view x projection) matrix to use
  13653. * @returns the new Vector3
  13654. */
  13655. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13656. /**
  13657. * Unproject from screen space to object space
  13658. * @param source defines the screen space Vector3 to use
  13659. * @param viewportWidth defines the current width of the viewport
  13660. * @param viewportHeight defines the current height of the viewport
  13661. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13662. * @param view defines the view matrix to use
  13663. * @param projection defines the projection matrix to use
  13664. * @returns the new Vector3
  13665. */
  13666. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13667. /**
  13668. * Unproject from screen space to object space
  13669. * @param source defines the screen space Vector3 to use
  13670. * @param viewportWidth defines the current width of the viewport
  13671. * @param viewportHeight defines the current height of the viewport
  13672. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13673. * @param view defines the view matrix to use
  13674. * @param projection defines the projection matrix to use
  13675. * @param result defines the Vector3 where to store the result
  13676. */
  13677. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13678. /**
  13679. * Unproject from screen space to object space
  13680. * @param sourceX defines the screen space x coordinate to use
  13681. * @param sourceY defines the screen space y coordinate to use
  13682. * @param sourceZ defines the screen space z coordinate to use
  13683. * @param viewportWidth defines the current width of the viewport
  13684. * @param viewportHeight defines the current height of the viewport
  13685. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13686. * @param view defines the view matrix to use
  13687. * @param projection defines the projection matrix to use
  13688. * @param result defines the Vector3 where to store the result
  13689. */
  13690. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13691. /**
  13692. * Gets the minimal coordinate values between two Vector3
  13693. * @param left defines the first operand
  13694. * @param right defines the second operand
  13695. * @returns the new Vector3
  13696. */
  13697. static Minimize(left: Vector3, right: Vector3): Vector3;
  13698. /**
  13699. * Gets the maximal coordinate values between two Vector3
  13700. * @param left defines the first operand
  13701. * @param right defines the second operand
  13702. * @returns the new Vector3
  13703. */
  13704. static Maximize(left: Vector3, right: Vector3): Vector3;
  13705. /**
  13706. * Returns the distance between the vectors "value1" and "value2"
  13707. * @param value1 defines the first operand
  13708. * @param value2 defines the second operand
  13709. * @returns the distance
  13710. */
  13711. static Distance(value1: Vector3, value2: Vector3): number;
  13712. /**
  13713. * Returns the squared distance between the vectors "value1" and "value2"
  13714. * @param value1 defines the first operand
  13715. * @param value2 defines the second operand
  13716. * @returns the squared distance
  13717. */
  13718. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13719. /**
  13720. * Returns a new Vector3 located at the center between "value1" and "value2"
  13721. * @param value1 defines the first operand
  13722. * @param value2 defines the second operand
  13723. * @returns the new Vector3
  13724. */
  13725. static Center(value1: Vector3, value2: Vector3): Vector3;
  13726. /**
  13727. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13728. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13729. * to something in order to rotate it from its local system to the given target system
  13730. * Note: axis1, axis2 and axis3 are normalized during this operation
  13731. * @param axis1 defines the first axis
  13732. * @param axis2 defines the second axis
  13733. * @param axis3 defines the third axis
  13734. * @returns a new Vector3
  13735. */
  13736. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13737. /**
  13738. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  13739. * @param axis1 defines the first axis
  13740. * @param axis2 defines the second axis
  13741. * @param axis3 defines the third axis
  13742. * @param ref defines the Vector3 where to store the result
  13743. */
  13744. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13745. }
  13746. class Vector4 {
  13747. x: number;
  13748. y: number;
  13749. z: number;
  13750. w: number;
  13751. /**
  13752. * Creates a Vector4 object from the given floats.
  13753. */
  13754. constructor(x: number, y: number, z: number, w: number);
  13755. /**
  13756. * Returns the string with the Vector4 coordinates.
  13757. */
  13758. toString(): string;
  13759. /**
  13760. * Returns the string "Vector4".
  13761. */
  13762. getClassName(): string;
  13763. /**
  13764. * Returns the Vector4 hash code.
  13765. */
  13766. getHashCode(): number;
  13767. /**
  13768. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13769. */
  13770. asArray(): number[];
  13771. /**
  13772. * Populates the given array from the given index with the Vector4 coordinates.
  13773. * Returns the Vector4.
  13774. */
  13775. toArray(array: FloatArray, index?: number): Vector4;
  13776. /**
  13777. * Adds the given vector to the current Vector4.
  13778. * Returns the updated Vector4.
  13779. */
  13780. addInPlace(otherVector: Vector4): Vector4;
  13781. /**
  13782. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  13783. */
  13784. add(otherVector: Vector4): Vector4;
  13785. /**
  13786. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  13787. * Returns the current Vector4.
  13788. */
  13789. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  13790. /**
  13791. * Subtract in place the given vector from the current Vector4.
  13792. * Returns the updated Vector4.
  13793. */
  13794. subtractInPlace(otherVector: Vector4): Vector4;
  13795. /**
  13796. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  13797. */
  13798. subtract(otherVector: Vector4): Vector4;
  13799. /**
  13800. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  13801. * Returns the current Vector4.
  13802. */
  13803. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  13804. /**
  13805. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13806. */
  13807. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13808. /**
  13809. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13810. * Returns the current Vector4.
  13811. */
  13812. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  13813. /**
  13814. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  13815. */
  13816. negate(): Vector4;
  13817. /**
  13818. * Multiplies the current Vector4 coordinates by scale (float).
  13819. * Returns the updated Vector4.
  13820. */
  13821. scaleInPlace(scale: number): Vector4;
  13822. /**
  13823. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  13824. */
  13825. scale(scale: number): Vector4;
  13826. /**
  13827. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  13828. * Returns the current Vector4.
  13829. */
  13830. scaleToRef(scale: number, result: Vector4): Vector4;
  13831. /**
  13832. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  13833. * @param scale defines the scale factor
  13834. * @param result defines the Vector4 object where to store the result
  13835. * @returns the unmodified current Vector4
  13836. */
  13837. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  13838. /**
  13839. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  13840. */
  13841. equals(otherVector: Vector4): boolean;
  13842. /**
  13843. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  13844. */
  13845. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  13846. /**
  13847. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  13848. */
  13849. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  13850. /**
  13851. * Multiplies in place the current Vector4 by the given one.
  13852. * Returns the updated Vector4.
  13853. */
  13854. multiplyInPlace(otherVector: Vector4): Vector4;
  13855. /**
  13856. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  13857. */
  13858. multiply(otherVector: Vector4): Vector4;
  13859. /**
  13860. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  13861. * Returns the current Vector4.
  13862. */
  13863. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  13864. /**
  13865. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  13866. */
  13867. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  13868. /**
  13869. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  13870. */
  13871. divide(otherVector: Vector4): Vector4;
  13872. /**
  13873. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  13874. * Returns the current Vector4.
  13875. */
  13876. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  13877. /**
  13878. * Divides the current Vector3 coordinates by the given ones.
  13879. * @returns the updated Vector3.
  13880. */
  13881. divideInPlace(otherVector: Vector4): Vector4;
  13882. /**
  13883. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  13884. * @param other defines the second operand
  13885. * @returns the current updated Vector4
  13886. */
  13887. minimizeInPlace(other: Vector4): Vector4;
  13888. /**
  13889. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  13890. * @param other defines the second operand
  13891. * @returns the current updated Vector4
  13892. */
  13893. maximizeInPlace(other: Vector4): Vector4;
  13894. /**
  13895. * Returns the Vector4 length (float).
  13896. */
  13897. length(): number;
  13898. /**
  13899. * Returns the Vector4 squared length (float).
  13900. */
  13901. lengthSquared(): number;
  13902. /**
  13903. * Normalizes in place the Vector4.
  13904. * Returns the updated Vector4.
  13905. */
  13906. normalize(): Vector4;
  13907. /**
  13908. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  13909. */
  13910. toVector3(): Vector3;
  13911. /**
  13912. * Returns a new Vector4 copied from the current one.
  13913. */
  13914. clone(): Vector4;
  13915. /**
  13916. * Updates the current Vector4 with the given one coordinates.
  13917. * Returns the updated Vector4.
  13918. */
  13919. copyFrom(source: Vector4): Vector4;
  13920. /**
  13921. * Updates the current Vector4 coordinates with the given floats.
  13922. * Returns the updated Vector4.
  13923. */
  13924. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13925. /**
  13926. * Updates the current Vector4 coordinates with the given floats.
  13927. * Returns the updated Vector4.
  13928. */
  13929. set(x: number, y: number, z: number, w: number): Vector4;
  13930. /**
  13931. * Returns a new Vector4 set from the starting index of the given array.
  13932. */
  13933. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  13934. /**
  13935. * Updates the given vector "result" from the starting index of the given array.
  13936. */
  13937. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  13938. /**
  13939. * Updates the given vector "result" from the starting index of the given Float32Array.
  13940. */
  13941. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  13942. /**
  13943. * Updates the given vector "result" coordinates from the given floats.
  13944. */
  13945. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  13946. /**
  13947. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  13948. */
  13949. static Zero(): Vector4;
  13950. /**
  13951. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  13952. */
  13953. static One(): Vector4;
  13954. /**
  13955. * Returns a new normalized Vector4 from the given one.
  13956. */
  13957. static Normalize(vector: Vector4): Vector4;
  13958. /**
  13959. * Updates the given vector "result" from the normalization of the given one.
  13960. */
  13961. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  13962. static Minimize(left: Vector4, right: Vector4): Vector4;
  13963. static Maximize(left: Vector4, right: Vector4): Vector4;
  13964. /**
  13965. * Returns the distance (float) between the vectors "value1" and "value2".
  13966. */
  13967. static Distance(value1: Vector4, value2: Vector4): number;
  13968. /**
  13969. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13970. */
  13971. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  13972. /**
  13973. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  13974. */
  13975. static Center(value1: Vector4, value2: Vector4): Vector4;
  13976. /**
  13977. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  13978. * This methods computes transformed normalized direction vectors only.
  13979. */
  13980. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  13981. /**
  13982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  13983. * This methods computes transformed normalized direction vectors only.
  13984. */
  13985. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  13986. /**
  13987. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  13988. * This methods computes transformed normalized direction vectors only.
  13989. */
  13990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  13991. }
  13992. interface ISize {
  13993. width: number;
  13994. height: number;
  13995. }
  13996. class Size implements ISize {
  13997. width: number;
  13998. height: number;
  13999. /**
  14000. * Creates a Size object from the given width and height (floats).
  14001. */
  14002. constructor(width: number, height: number);
  14003. toString(): string;
  14004. /**
  14005. * Returns the string "Size"
  14006. */
  14007. getClassName(): string;
  14008. /**
  14009. * Returns the Size hash code.
  14010. */
  14011. getHashCode(): number;
  14012. /**
  14013. * Updates the current size from the given one.
  14014. * Returns the updated Size.
  14015. */
  14016. copyFrom(src: Size): void;
  14017. /**
  14018. * Updates in place the current Size from the given floats.
  14019. * Returns the updated Size.
  14020. */
  14021. copyFromFloats(width: number, height: number): Size;
  14022. /**
  14023. * Updates in place the current Size from the given floats.
  14024. * Returns the updated Size.
  14025. */
  14026. set(width: number, height: number): Size;
  14027. /**
  14028. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  14029. */
  14030. multiplyByFloats(w: number, h: number): Size;
  14031. /**
  14032. * Returns a new Size copied from the given one.
  14033. */
  14034. clone(): Size;
  14035. /**
  14036. * Boolean : True if the current Size and the given one width and height are strictly equal.
  14037. */
  14038. equals(other: Size): boolean;
  14039. /**
  14040. * Returns the surface of the Size : width * height (float).
  14041. */
  14042. readonly surface: number;
  14043. /**
  14044. * Returns a new Size set to (0.0, 0.0)
  14045. */
  14046. static Zero(): Size;
  14047. /**
  14048. * Returns a new Size set as the addition result of the current Size and the given one.
  14049. */
  14050. add(otherSize: Size): Size;
  14051. /**
  14052. * Returns a new Size set as the subtraction result of the given one from the current Size.
  14053. */
  14054. subtract(otherSize: Size): Size;
  14055. /**
  14056. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  14057. */
  14058. static Lerp(start: Size, end: Size, amount: number): Size;
  14059. }
  14060. /**
  14061. * Class used to store quaternion data
  14062. * @see https://en.wikipedia.org/wiki/Quaternion
  14063. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  14064. */
  14065. class Quaternion {
  14066. /** defines the first component (0 by default) */
  14067. x: number;
  14068. /** defines the second component (0 by default) */
  14069. y: number;
  14070. /** defines the third component (0 by default) */
  14071. z: number;
  14072. /** defines the fourth component (1.0 by default) */
  14073. w: number;
  14074. /**
  14075. * Creates a new Quaternion from the given floats
  14076. * @param x defines the first component (0 by default)
  14077. * @param y defines the second component (0 by default)
  14078. * @param z defines the third component (0 by default)
  14079. * @param w defines the fourth component (1.0 by default)
  14080. */
  14081. constructor(
  14082. /** defines the first component (0 by default) */
  14083. x?: number,
  14084. /** defines the second component (0 by default) */
  14085. y?: number,
  14086. /** defines the third component (0 by default) */
  14087. z?: number,
  14088. /** defines the fourth component (1.0 by default) */
  14089. w?: number);
  14090. /**
  14091. * Gets a string representation for the current quaternion
  14092. * @returns a string with the Quaternion coordinates
  14093. */
  14094. toString(): string;
  14095. /**
  14096. * Gets the class name of the quaternion
  14097. * @returns the string "Quaternion"
  14098. */
  14099. getClassName(): string;
  14100. /**
  14101. * Gets a hash code for this quaternion
  14102. * @returns the quaternion hash code
  14103. */
  14104. getHashCode(): number;
  14105. /**
  14106. * Copy the quaternion to an array
  14107. * @returns a new array populated with 4 elements from the quaternion coordinates
  14108. */
  14109. asArray(): number[];
  14110. /**
  14111. * Check if two quaternions are equals
  14112. * @param otherQuaternion defines the second operand
  14113. * @return true if the current quaternion and the given one coordinates are strictly equals
  14114. */
  14115. equals(otherQuaternion: Quaternion): boolean;
  14116. /**
  14117. * Clone the current quaternion
  14118. * @returns a new quaternion copied from the current one
  14119. */
  14120. clone(): Quaternion;
  14121. /**
  14122. * Copy a quaternion to the current one
  14123. * @param other defines the other quaternion
  14124. * @returns the updated current quaternion
  14125. */
  14126. copyFrom(other: Quaternion): Quaternion;
  14127. /**
  14128. * Updates the current quaternion with the given float coordinates
  14129. * @param x defines the x coordinate
  14130. * @param y defines the y coordinate
  14131. * @param z defines the z coordinate
  14132. * @param w defines the w coordinate
  14133. * @returns the updated current quaternion
  14134. */
  14135. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  14136. /**
  14137. * Updates the current quaternion from the given float coordinates
  14138. * @param x defines the x coordinate
  14139. * @param y defines the y coordinate
  14140. * @param z defines the z coordinate
  14141. * @param w defines the w coordinate
  14142. * @returns the updated current quaternion
  14143. */
  14144. set(x: number, y: number, z: number, w: number): Quaternion;
  14145. /**
  14146. * Adds two quaternions
  14147. * @param other defines the second operand
  14148. * @returns a new quaternion as the addition result of the given one and the current quaternion
  14149. */
  14150. add(other: Quaternion): Quaternion;
  14151. /**
  14152. * Add a quaternion to the current one
  14153. * @param other defines the quaternion to add
  14154. * @returns the current quaternion
  14155. */
  14156. addInPlace(other: Quaternion): Quaternion;
  14157. /**
  14158. * Subtract two quaternions
  14159. * @param other defines the second operand
  14160. * @returns a new quaternion as the subtraction result of the given one from the current one
  14161. */
  14162. subtract(other: Quaternion): Quaternion;
  14163. /**
  14164. * Multiplies the current quaternion by a scale factor
  14165. * @param value defines the scale factor
  14166. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  14167. */
  14168. scale(value: number): Quaternion;
  14169. /**
  14170. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  14171. * @param scale defines the scale factor
  14172. * @param result defines the Quaternion object where to store the result
  14173. * @returns the unmodified current quaternion
  14174. */
  14175. scaleToRef(scale: number, result: Quaternion): Quaternion;
  14176. /**
  14177. * Multiplies in place the current quaternion by a scale factor
  14178. * @param value defines the scale factor
  14179. * @returns the current modified quaternion
  14180. */
  14181. scaleInPlace(value: number): Quaternion;
  14182. /**
  14183. * Scale the current quaternion values by a factor and add the result to a given quaternion
  14184. * @param scale defines the scale factor
  14185. * @param result defines the Quaternion object where to store the result
  14186. * @returns the unmodified current quaternion
  14187. */
  14188. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  14189. /**
  14190. * Multiplies two quaternions
  14191. * @param q1 defines the second operand
  14192. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  14193. */
  14194. multiply(q1: Quaternion): Quaternion;
  14195. /**
  14196. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  14197. * @param q1 defines the second operand
  14198. * @param result defines the target quaternion
  14199. * @returns the current quaternion
  14200. */
  14201. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  14202. /**
  14203. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  14204. * @param q1 defines the second operand
  14205. * @returns the currentupdated quaternion
  14206. */
  14207. multiplyInPlace(q1: Quaternion): Quaternion;
  14208. /**
  14209. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  14210. * @param ref defines the target quaternion
  14211. * @returns the current quaternion
  14212. */
  14213. conjugateToRef(ref: Quaternion): Quaternion;
  14214. /**
  14215. * Conjugates in place (1-q) the current quaternion
  14216. * @returns the current updated quaternion
  14217. */
  14218. conjugateInPlace(): Quaternion;
  14219. /**
  14220. * Conjugates in place (1-q) the current quaternion
  14221. * @returns a new quaternion
  14222. */
  14223. conjugate(): Quaternion;
  14224. /**
  14225. * Gets length of current quaternion
  14226. * @returns the quaternion length (float)
  14227. */
  14228. length(): number;
  14229. /**
  14230. * Normalize in place the current quaternion
  14231. * @returns the current updated quaternion
  14232. */
  14233. normalize(): Quaternion;
  14234. /**
  14235. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  14236. * @param order is a reserved parameter and is ignore for now
  14237. * @returns a new Vector3 containing the Euler angles
  14238. */
  14239. toEulerAngles(order?: string): Vector3;
  14240. /**
  14241. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  14242. * @param result defines the vector which will be filled with the Euler angles
  14243. * @param order is a reserved parameter and is ignore for now
  14244. * @returns the current unchanged quaternion
  14245. */
  14246. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  14247. /**
  14248. * Updates the given rotation matrix with the current quaternion values
  14249. * @param result defines the target matrix
  14250. * @returns the current unchanged quaternion
  14251. */
  14252. toRotationMatrix(result: Matrix): Quaternion;
  14253. /**
  14254. * Updates the current quaternion from the given rotation matrix values
  14255. * @param matrix defines the source matrix
  14256. * @returns the current updated quaternion
  14257. */
  14258. fromRotationMatrix(matrix: Matrix): Quaternion;
  14259. /**
  14260. * Creates a new quaternion from a rotation matrix
  14261. * @param matrix defines the source matrix
  14262. * @returns a new quaternion created from the given rotation matrix values
  14263. */
  14264. static FromRotationMatrix(matrix: Matrix): Quaternion;
  14265. /**
  14266. * Updates the given quaternion with the given rotation matrix values
  14267. * @param matrix defines the source matrix
  14268. * @param result defines the target quaternion
  14269. */
  14270. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  14271. /**
  14272. * Returns the dot product (float) between the quaternions "left" and "right"
  14273. * @param left defines the left operand
  14274. * @param right defines the right operand
  14275. * @returns the dot product
  14276. */
  14277. static Dot(left: Quaternion, right: Quaternion): number;
  14278. /**
  14279. * Checks if the two quaternions are close to each other
  14280. * @param quat0 defines the first quaternion to check
  14281. * @param quat1 defines the second quaternion to check
  14282. * @returns true if the two quaternions are close to each other
  14283. */
  14284. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  14285. /**
  14286. * Creates an empty quaternion
  14287. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  14288. */
  14289. static Zero(): Quaternion;
  14290. /**
  14291. * Inverse a given quaternion
  14292. * @param q defines the source quaternion
  14293. * @returns a new quaternion as the inverted current quaternion
  14294. */
  14295. static Inverse(q: Quaternion): Quaternion;
  14296. /**
  14297. * Creates an identity quaternion
  14298. * @returns the identity quaternion
  14299. */
  14300. static Identity(): Quaternion;
  14301. /**
  14302. * Gets a boolean indicating if the given quaternion is identity
  14303. * @param quaternion defines the quaternion to check
  14304. * @returns true if the quaternion is identity
  14305. */
  14306. static IsIdentity(quaternion: Quaternion): boolean;
  14307. /**
  14308. * Creates a quaternion from a rotation around an axis
  14309. * @param axis defines the axis to use
  14310. * @param angle defines the angle to use
  14311. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  14312. */
  14313. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  14314. /**
  14315. * Creates a rotation around an axis and stores it into the given quaternion
  14316. * @param axis defines the axis to use
  14317. * @param angle defines the angle to use
  14318. * @param result defines the target quaternion
  14319. * @returns the target quaternion
  14320. */
  14321. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  14322. /**
  14323. * Creates a new quaternion from data stored into an array
  14324. * @param array defines the data source
  14325. * @param offset defines the offset in the source array where the data starts
  14326. * @returns a new quaternion
  14327. */
  14328. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  14329. /**
  14330. * Creates a new quaternion from the given Euler float angles (y, x, z)
  14331. * @param yaw defines the rotation around Y axis
  14332. * @param pitch defines the rotation around X axis
  14333. * @param roll defines the rotation around Z axis
  14334. * @returns the new quaternion
  14335. */
  14336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  14337. /**
  14338. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  14339. * @param yaw defines the rotation around Y axis
  14340. * @param pitch defines the rotation around X axis
  14341. * @param roll defines the rotation around Z axis
  14342. * @param result defines the target quaternion
  14343. */
  14344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  14345. /**
  14346. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  14347. * @param alpha defines the rotation around first axis
  14348. * @param beta defines the rotation around second axis
  14349. * @param gamma defines the rotation around third axis
  14350. * @returns the new quaternion
  14351. */
  14352. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  14353. /**
  14354. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  14355. * @param alpha defines the rotation around first axis
  14356. * @param beta defines the rotation around second axis
  14357. * @param gamma defines the rotation around third axis
  14358. * @param result defines the target quaternion
  14359. */
  14360. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14361. /**
  14362. * 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)
  14363. * @param axis1 defines the first axis
  14364. * @param axis2 defines the second axis
  14365. * @param axis3 defines the third axis
  14366. * @returns the new quaternion
  14367. */
  14368. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  14369. /**
  14370. * 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
  14371. * @param axis1 defines the first axis
  14372. * @param axis2 defines the second axis
  14373. * @param axis3 defines the third axis
  14374. * @param ref defines the target quaternion
  14375. */
  14376. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14377. /**
  14378. * Interpolates between two quaternions
  14379. * @param left defines first quaternion
  14380. * @param right defines second quaternion
  14381. * @param amount defines the gradient to use
  14382. * @returns the new interpolated quaternion
  14383. */
  14384. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14385. /**
  14386. * Interpolates between two quaternions and stores it into a target quaternion
  14387. * @param left defines first quaternion
  14388. * @param right defines second quaternion
  14389. * @param amount defines the gradient to use
  14390. * @param result defines the target quaternion
  14391. */
  14392. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14393. /**
  14394. * Interpolate between two quaternions using Hermite interpolation
  14395. * @param value1 defines first quaternion
  14396. * @param tangent1 defines the incoming tangent
  14397. * @param value2 defines second quaternion
  14398. * @param tangent2 defines the outgoing tangent
  14399. * @param amount defines the target quaternion
  14400. * @returns the new interpolated quaternion
  14401. */
  14402. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14403. }
  14404. /**
  14405. * Class used to store matrix data (4x4)
  14406. */
  14407. class Matrix {
  14408. private static _tempQuaternion;
  14409. private static _xAxis;
  14410. private static _yAxis;
  14411. private static _zAxis;
  14412. private static _updateFlagSeed;
  14413. private static _identityReadOnly;
  14414. private _isIdentity;
  14415. private _isIdentityDirty;
  14416. /**
  14417. * Gets the update flag of the matrix which is an unique number for the matrix.
  14418. * It will be incremented every time the matrix data change.
  14419. * You can use it to speed the comparison between two versions of the same matrix.
  14420. */
  14421. updateFlag: number;
  14422. /**
  14423. * Gets or sets the internal data of the matrix
  14424. */
  14425. m: Float32Array;
  14426. /** @hidden */
  14427. /**
  14428. * Creates an empty matrix (filled with zeros)
  14429. */
  14430. constructor();
  14431. /**
  14432. * Check if the current matrix is indentity
  14433. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  14434. * @returns true is the matrix is the identity matrix
  14435. */
  14436. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14437. /**
  14438. * Gets the determinant of the matrix
  14439. * @returns the matrix determinant
  14440. */
  14441. determinant(): number;
  14442. /**
  14443. * Returns the matrix as a Float32Array
  14444. * @returns the matrix underlying array
  14445. */
  14446. toArray(): Float32Array;
  14447. /**
  14448. * Returns the matrix as a Float32Array
  14449. * @returns the matrix underlying array.
  14450. */
  14451. asArray(): Float32Array;
  14452. /**
  14453. * Inverts the current matrix in place
  14454. * @returns the current inverted matrix
  14455. */
  14456. invert(): Matrix;
  14457. /**
  14458. * Sets all the matrix elements to zero
  14459. * @returns the current matrix
  14460. */
  14461. reset(): Matrix;
  14462. /**
  14463. * Adds the current matrix with a second one
  14464. * @param other defines the matrix to add
  14465. * @returns a new matrix as the addition of the current matrix and the given one
  14466. */
  14467. add(other: Matrix): Matrix;
  14468. /**
  14469. * Sets the given matrix "result" to the addition of the current matrix and the given one
  14470. * @param other defines the matrix to add
  14471. * @param result defines the target matrix
  14472. * @returns the current matrix
  14473. */
  14474. addToRef(other: Matrix, result: Matrix): Matrix;
  14475. /**
  14476. * Adds in place the given matrix to the current matrix
  14477. * @param other defines the second operand
  14478. * @returns the current updated matrix
  14479. */
  14480. addToSelf(other: Matrix): Matrix;
  14481. /**
  14482. * Sets the given matrix to the current inverted Matrix
  14483. * @param other defines the target matrix
  14484. * @returns the unmodified current matrix
  14485. */
  14486. invertToRef(other: Matrix): Matrix;
  14487. /**
  14488. * Inserts the translation vector (using 3 floats) in the current matrix
  14489. * @param x defines the 1st component of the translation
  14490. * @param y defines the 2nd component of the translation
  14491. * @param z defines the 3rd component of the translation
  14492. * @returns the current updated matrix
  14493. */
  14494. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14495. /**
  14496. * Inserts the translation vector in the current matrix
  14497. * @param vector3 defines the translation to insert
  14498. * @returns the current updated matrix
  14499. */
  14500. setTranslation(vector3: Vector3): Matrix;
  14501. /**
  14502. * Gets the translation value of the current matrix
  14503. * @returns a new Vector3 as the extracted translation from the matrix
  14504. */
  14505. getTranslation(): Vector3;
  14506. /**
  14507. * Fill a Vector3 with the extracted translation from the matrix
  14508. * @param result defines the Vector3 where to store the translation
  14509. * @returns the current matrix
  14510. */
  14511. getTranslationToRef(result: Vector3): Matrix;
  14512. /**
  14513. * Remove rotation and scaling part from the matrix
  14514. * @returns the updated matrix
  14515. */
  14516. removeRotationAndScaling(): Matrix;
  14517. /**
  14518. * Multiply two matrices
  14519. * @param other defines the second operand
  14520. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  14521. */
  14522. multiply(other: Matrix): Matrix;
  14523. /**
  14524. * Copy the current matrix from the given one
  14525. * @param other defines the source matrix
  14526. * @returns the current updated matrix
  14527. */
  14528. copyFrom(other: Matrix): Matrix;
  14529. /**
  14530. * Populates the given array from the starting index with the current matrix values
  14531. * @param array defines the target array
  14532. * @param offset defines the offset in the target array where to start storing values
  14533. * @returns the current matrix
  14534. */
  14535. copyToArray(array: Float32Array, offset?: number): Matrix;
  14536. /**
  14537. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  14538. * @param other defines the second operand
  14539. * @param result defines the matrix where to store the multiplication
  14540. * @returns the current matrix
  14541. */
  14542. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14543. /**
  14544. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  14545. * @param other defines the second operand
  14546. * @param result defines the array where to store the multiplication
  14547. * @param offset defines the offset in the target array where to start storing values
  14548. * @returns the current matrix
  14549. */
  14550. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14551. /**
  14552. * Check equality between this matrix and a second one
  14553. * @param value defines the second matrix to compare
  14554. * @returns true is the current matrix and the given one values are strictly equal
  14555. */
  14556. equals(value: Matrix): boolean;
  14557. /**
  14558. * Clone the current matrix
  14559. * @returns a new matrix from the current matrix
  14560. */
  14561. clone(): Matrix;
  14562. /**
  14563. * Returns the name of the current matrix class
  14564. * @returns the string "Matrix"
  14565. */
  14566. getClassName(): string;
  14567. /**
  14568. * Gets the hash code of the current matrix
  14569. * @returns the hash code
  14570. */
  14571. getHashCode(): number;
  14572. /**
  14573. * Decomposes the current Matrix into a translation, rotation and scaling components
  14574. * @param scale defines the scale vector3 given as a reference to update
  14575. * @param rotation defines the rotation quaternion given as a reference to update
  14576. * @param translation defines the translation vector3 given as a reference to update
  14577. * @returns true if operation was successful
  14578. */
  14579. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14580. /**
  14581. * Gets specific row of the matrix
  14582. * @param index defines the number of the row to get
  14583. * @returns the index-th row of the current matrix as a new Vector4
  14584. */
  14585. getRow(index: number): Nullable<Vector4>;
  14586. /**
  14587. * Sets the index-th row of the current matrix to the vector4 values
  14588. * @param index defines the number of the row to set
  14589. * @param row defines the target vector4
  14590. * @returns the updated current matrix
  14591. */
  14592. setRow(index: number, row: Vector4): Matrix;
  14593. /**
  14594. * Compute the transpose of the matrix
  14595. * @returns the new transposed matrix
  14596. */
  14597. transpose(): Matrix;
  14598. /**
  14599. * Compute the transpose of the matrix and store it in a given matrix
  14600. * @param result defines the target matrix
  14601. * @returns the current matrix
  14602. */
  14603. transposeToRef(result: Matrix): Matrix;
  14604. /**
  14605. * Sets the index-th row of the current matrix with the given 4 x float values
  14606. * @param index defines the row index
  14607. * @param x defines the x component to set
  14608. * @param y defines the y component to set
  14609. * @param z defines the z component to set
  14610. * @param w defines the w component to set
  14611. * @returns the updated current matrix
  14612. */
  14613. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14614. /**
  14615. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14616. * @param scale defines the scale factor
  14617. * @returns a new matrix
  14618. */
  14619. scale(scale: number): Matrix;
  14620. /**
  14621. * Scale the current matrix values by a factor to a given result matrix
  14622. * @param scale defines the scale factor
  14623. * @param result defines the matrix to store the result
  14624. * @returns the current matrix
  14625. */
  14626. scaleToRef(scale: number, result: Matrix): Matrix;
  14627. /**
  14628. * Scale the current matrix values by a factor and add the result to a given matrix
  14629. * @param scale defines the scale factor
  14630. * @param result defines the Matrix to store the result
  14631. * @returns the current matrix
  14632. */
  14633. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14634. /**
  14635. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14636. * @param ref matrix to store the result
  14637. */
  14638. toNormalMatrix(ref: Matrix): void;
  14639. /**
  14640. * Gets only rotation part of the current matrix
  14641. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14642. */
  14643. getRotationMatrix(): Matrix;
  14644. /**
  14645. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14646. * @param result defines the target matrix to store data to
  14647. * @returns the current matrix
  14648. */
  14649. getRotationMatrixToRef(result: Matrix): Matrix;
  14650. /**
  14651. * Creates a matrix from an array
  14652. * @param array defines the source array
  14653. * @param offset defines an offset in the source array
  14654. * @returns a new Matrix set from the starting index of the given array
  14655. */
  14656. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14657. /**
  14658. * Copy the content of an array into a given matrix
  14659. * @param array defines the source array
  14660. * @param offset defines an offset in the source array
  14661. * @param result defines the target matrix
  14662. */
  14663. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14664. /**
  14665. * Stores an array into a matrix after having multiplied each component by a given factor
  14666. * @param array defines the source array
  14667. * @param offset defines the offset in the source array
  14668. * @param scale defines the scaling factor
  14669. * @param result defines the target matrix
  14670. */
  14671. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14672. /**
  14673. * Stores a list of values (16) inside a given matrix
  14674. * @param initialM11 defines 1st value of 1st row
  14675. * @param initialM12 defines 2nd value of 1st row
  14676. * @param initialM13 defines 3rd value of 1st row
  14677. * @param initialM14 defines 4th value of 1st row
  14678. * @param initialM21 defines 1st value of 2nd row
  14679. * @param initialM22 defines 2nd value of 2nd row
  14680. * @param initialM23 defines 3rd value of 2nd row
  14681. * @param initialM24 defines 4th value of 2nd row
  14682. * @param initialM31 defines 1st value of 3rd row
  14683. * @param initialM32 defines 2nd value of 3rd row
  14684. * @param initialM33 defines 3rd value of 3rd row
  14685. * @param initialM34 defines 4th value of 3rd row
  14686. * @param initialM41 defines 1st value of 4th row
  14687. * @param initialM42 defines 2nd value of 4th row
  14688. * @param initialM43 defines 3rd value of 4th row
  14689. * @param initialM44 defines 4th value of 4th row
  14690. * @param result defines the target matrix
  14691. */
  14692. 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;
  14693. /**
  14694. * Gets an identity matrix that must not be updated
  14695. */
  14696. static readonly IdentityReadOnly: Matrix;
  14697. /**
  14698. * Creates new matrix from a list of values (16)
  14699. * @param initialM11 defines 1st value of 1st row
  14700. * @param initialM12 defines 2nd value of 1st row
  14701. * @param initialM13 defines 3rd value of 1st row
  14702. * @param initialM14 defines 4th value of 1st row
  14703. * @param initialM21 defines 1st value of 2nd row
  14704. * @param initialM22 defines 2nd value of 2nd row
  14705. * @param initialM23 defines 3rd value of 2nd row
  14706. * @param initialM24 defines 4th value of 2nd row
  14707. * @param initialM31 defines 1st value of 3rd row
  14708. * @param initialM32 defines 2nd value of 3rd row
  14709. * @param initialM33 defines 3rd value of 3rd row
  14710. * @param initialM34 defines 4th value of 3rd row
  14711. * @param initialM41 defines 1st value of 4th row
  14712. * @param initialM42 defines 2nd value of 4th row
  14713. * @param initialM43 defines 3rd value of 4th row
  14714. * @param initialM44 defines 4th value of 4th row
  14715. * @returns the new matrix
  14716. */
  14717. 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;
  14718. /**
  14719. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14720. * @param scale defines the scale vector3
  14721. * @param rotation defines the rotation quaternion
  14722. * @param translation defines the translation vector3
  14723. * @returns a new matrix
  14724. */
  14725. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14726. /**
  14727. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14728. * @param scale defines the scale vector3
  14729. * @param rotation defines the rotation quaternion
  14730. * @param translation defines the translation vector3
  14731. * @param result defines the target matrix
  14732. */
  14733. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14734. /**
  14735. * Creates a new identity matrix
  14736. * @returns a new identity matrix
  14737. */
  14738. static Identity(): Matrix;
  14739. /**
  14740. * Creates a new identity matrix and stores the result in a given matrix
  14741. * @param result defines the target matrix
  14742. */
  14743. static IdentityToRef(result: Matrix): void;
  14744. /**
  14745. * Creates a new zero matrix
  14746. * @returns a new zero matrix
  14747. */
  14748. static Zero(): Matrix;
  14749. /**
  14750. * Creates a new rotation matrix for "angle" radians around the X axis
  14751. * @param angle defines the angle (in radians) to use
  14752. * @return the new matrix
  14753. */
  14754. static RotationX(angle: number): Matrix;
  14755. /**
  14756. * Creates a new matrix as the invert of a given matrix
  14757. * @param source defines the source matrix
  14758. * @returns the new matrix
  14759. */
  14760. static Invert(source: Matrix): Matrix;
  14761. /**
  14762. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  14763. * @param angle defines the angle (in radians) to use
  14764. * @param result defines the target matrix
  14765. */
  14766. static RotationXToRef(angle: number, result: Matrix): void;
  14767. /**
  14768. * Creates a new rotation matrix for "angle" radians around the Y axis
  14769. * @param angle defines the angle (in radians) to use
  14770. * @return the new matrix
  14771. */
  14772. static RotationY(angle: number): Matrix;
  14773. /**
  14774. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  14775. * @param angle defines the angle (in radians) to use
  14776. * @param result defines the target matrix
  14777. */
  14778. static RotationYToRef(angle: number, result: Matrix): void;
  14779. /**
  14780. * Creates a new rotation matrix for "angle" radians around the Z axis
  14781. * @param angle defines the angle (in radians) to use
  14782. * @return the new matrix
  14783. */
  14784. static RotationZ(angle: number): Matrix;
  14785. /**
  14786. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  14787. * @param angle defines the angle (in radians) to use
  14788. * @param result defines the target matrix
  14789. */
  14790. static RotationZToRef(angle: number, result: Matrix): void;
  14791. /**
  14792. * Creates a new rotation matrix for "angle" radians around the given axis
  14793. * @param axis defines the axis to use
  14794. * @param angle defines the angle (in radians) to use
  14795. * @return the new matrix
  14796. */
  14797. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14798. /**
  14799. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  14800. * @param axis defines the axis to use
  14801. * @param angle defines the angle (in radians) to use
  14802. * @param result defines the target matrix
  14803. */
  14804. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14805. /**
  14806. * Creates a rotation matrix
  14807. * @param yaw defines the yaw angle in radians (Y axis)
  14808. * @param pitch defines the pitch angle in radians (X axis)
  14809. * @param roll defines the roll angle in radians (X axis)
  14810. * @returns the new rotation matrix
  14811. */
  14812. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14813. /**
  14814. * Creates a rotation matrix and stores it in a given matrix
  14815. * @param yaw defines the yaw angle in radians (Y axis)
  14816. * @param pitch defines the pitch angle in radians (X axis)
  14817. * @param roll defines the roll angle in radians (X axis)
  14818. * @param result defines the target matrix
  14819. */
  14820. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14821. /**
  14822. * Creates a scaling matrix
  14823. * @param x defines the scale factor on X axis
  14824. * @param y defines the scale factor on Y axis
  14825. * @param z defines the scale factor on Z axis
  14826. * @returns the new matrix
  14827. */
  14828. static Scaling(x: number, y: number, z: number): Matrix;
  14829. /**
  14830. * Creates a scaling matrix and stores it in a given matrix
  14831. * @param x defines the scale factor on X axis
  14832. * @param y defines the scale factor on Y axis
  14833. * @param z defines the scale factor on Z axis
  14834. * @param result defines the target matrix
  14835. */
  14836. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14837. /**
  14838. * Creates a translation matrix
  14839. * @param x defines the translation on X axis
  14840. * @param y defines the translation on Y axis
  14841. * @param z defines the translationon Z axis
  14842. * @returns the new matrix
  14843. */
  14844. static Translation(x: number, y: number, z: number): Matrix;
  14845. /**
  14846. * Creates a translation matrix and stores it in a given matrix
  14847. * @param x defines the translation on X axis
  14848. * @param y defines the translation on Y axis
  14849. * @param z defines the translationon Z axis
  14850. * @param result defines the target matrix
  14851. */
  14852. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14853. /**
  14854. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14855. * @param startValue defines the start value
  14856. * @param endValue defines the end value
  14857. * @param gradient defines the gradient factor
  14858. * @returns the new matrix
  14859. */
  14860. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14861. /**
  14862. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14863. * @param startValue defines the start value
  14864. * @param endValue defines the end value
  14865. * @param gradient defines the gradient factor
  14866. * @param result defines the Matrix object where to store data
  14867. */
  14868. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14869. /**
  14870. * Builds a new matrix whose values are computed by:
  14871. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14872. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14873. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14874. * @param startValue defines the first matrix
  14875. * @param endValue defines the second matrix
  14876. * @param gradient defines the gradient between the two matrices
  14877. * @returns the new matrix
  14878. */
  14879. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14880. /**
  14881. * Update a matrix to values which are computed by:
  14882. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14883. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14884. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14885. * @param startValue defines the first matrix
  14886. * @param endValue defines the second matrix
  14887. * @param gradient defines the gradient between the two matrices
  14888. * @param result defines the target matrix
  14889. */
  14890. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14891. /**
  14892. * 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"
  14893. * This function works in left handed mode
  14894. * @param eye defines the final position of the entity
  14895. * @param target defines where the entity should look at
  14896. * @param up defines the up vector for the entity
  14897. * @returns the new matrix
  14898. */
  14899. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14900. /**
  14901. * 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".
  14902. * This function works in left handed mode
  14903. * @param eye defines the final position of the entity
  14904. * @param target defines where the entity should look at
  14905. * @param up defines the up vector for the entity
  14906. * @param result defines the target matrix
  14907. */
  14908. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14909. /**
  14910. * 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"
  14911. * This function works in right handed mode
  14912. * @param eye defines the final position of the entity
  14913. * @param target defines where the entity should look at
  14914. * @param up defines the up vector for the entity
  14915. * @returns the new matrix
  14916. */
  14917. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14918. /**
  14919. * 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".
  14920. * This function works in right handed mode
  14921. * @param eye defines the final position of the entity
  14922. * @param target defines where the entity should look at
  14923. * @param up defines the up vector for the entity
  14924. * @param result defines the target matrix
  14925. */
  14926. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14927. /**
  14928. * Create a left-handed orthographic projection matrix
  14929. * @param width defines the viewport width
  14930. * @param height defines the viewport height
  14931. * @param znear defines the near clip plane
  14932. * @param zfar defines the far clip plane
  14933. * @returns a new matrix as a left-handed orthographic projection matrix
  14934. */
  14935. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14936. /**
  14937. * Store a left-handed orthographic projection to a given matrix
  14938. * @param width defines the viewport width
  14939. * @param height defines the viewport height
  14940. * @param znear defines the near clip plane
  14941. * @param zfar defines the far clip plane
  14942. * @param result defines the target matrix
  14943. */
  14944. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14945. /**
  14946. * Create a left-handed orthographic projection matrix
  14947. * @param left defines the viewport left coordinate
  14948. * @param right defines the viewport right coordinate
  14949. * @param bottom defines the viewport bottom coordinate
  14950. * @param top defines the viewport top coordinate
  14951. * @param znear defines the near clip plane
  14952. * @param zfar defines the far clip plane
  14953. * @returns a new matrix as a left-handed orthographic projection matrix
  14954. */
  14955. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14956. /**
  14957. * Stores a left-handed orthographic projection into a given matrix
  14958. * @param left defines the viewport left coordinate
  14959. * @param right defines the viewport right coordinate
  14960. * @param bottom defines the viewport bottom coordinate
  14961. * @param top defines the viewport top coordinate
  14962. * @param znear defines the near clip plane
  14963. * @param zfar defines the far clip plane
  14964. * @param result defines the target matrix
  14965. */
  14966. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14967. /**
  14968. * Creates a right-handed orthographic projection matrix
  14969. * @param left defines the viewport left coordinate
  14970. * @param right defines the viewport right coordinate
  14971. * @param bottom defines the viewport bottom coordinate
  14972. * @param top defines the viewport top coordinate
  14973. * @param znear defines the near clip plane
  14974. * @param zfar defines the far clip plane
  14975. * @returns a new matrix as a right-handed orthographic projection matrix
  14976. */
  14977. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14978. /**
  14979. * Stores a right-handed orthographic projection into a given matrix
  14980. * @param left defines the viewport left coordinate
  14981. * @param right defines the viewport right coordinate
  14982. * @param bottom defines the viewport bottom coordinate
  14983. * @param top defines the viewport top coordinate
  14984. * @param znear defines the near clip plane
  14985. * @param zfar defines the far clip plane
  14986. * @param result defines the target matrix
  14987. */
  14988. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14989. /**
  14990. * Creates a left-handed perspective projection matrix
  14991. * @param width defines the viewport width
  14992. * @param height defines the viewport height
  14993. * @param znear defines the near clip plane
  14994. * @param zfar defines the far clip plane
  14995. * @returns a new matrix as a left-handed perspective projection matrix
  14996. */
  14997. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14998. /**
  14999. * Creates a left-handed perspective projection matrix
  15000. * @param fov defines the horizontal field of view
  15001. * @param aspect defines the aspect ratio
  15002. * @param znear defines the near clip plane
  15003. * @param zfar defines the far clip plane
  15004. * @returns a new matrix as a left-handed perspective projection matrix
  15005. */
  15006. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15007. /**
  15008. * Stores a left-handed perspective projection into a given matrix
  15009. * @param fov defines the horizontal field of view
  15010. * @param aspect defines the aspect ratio
  15011. * @param znear defines the near clip plane
  15012. * @param zfar defines the far clip plane
  15013. * @param result defines the target matrix
  15014. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15015. */
  15016. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15017. /**
  15018. * Creates a right-handed perspective projection matrix
  15019. * @param fov defines the horizontal field of view
  15020. * @param aspect defines the aspect ratio
  15021. * @param znear defines the near clip plane
  15022. * @param zfar defines the far clip plane
  15023. * @returns a new matrix as a right-handed perspective projection matrix
  15024. */
  15025. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15026. /**
  15027. * Stores a right-handed perspective projection into a given matrix
  15028. * @param fov defines the horizontal field of view
  15029. * @param aspect defines the aspect ratio
  15030. * @param znear defines the near clip plane
  15031. * @param zfar defines the far clip plane
  15032. * @param result defines the target matrix
  15033. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  15034. */
  15035. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15036. /**
  15037. * Stores a perspective projection for WebVR info a given matrix
  15038. * @param fov defines the field of view
  15039. * @param znear defines the near clip plane
  15040. * @param zfar defines the far clip plane
  15041. * @param result defines the target matrix
  15042. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  15043. */
  15044. static PerspectiveFovWebVRToRef(fov: {
  15045. upDegrees: number;
  15046. downDegrees: number;
  15047. leftDegrees: number;
  15048. rightDegrees: number;
  15049. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  15050. /**
  15051. * Computes a complete transformation matrix
  15052. * @param viewport defines the viewport to use
  15053. * @param world defines the world matrix
  15054. * @param view defines the view matrix
  15055. * @param projection defines the projection matrix
  15056. * @param zmin defines the near clip plane
  15057. * @param zmax defines the far clip plane
  15058. * @returns the transformation matrix
  15059. */
  15060. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  15061. /**
  15062. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  15063. * @param matrix defines the matrix to use
  15064. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  15065. */
  15066. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  15067. /**
  15068. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  15069. * @param matrix defines the matrix to use
  15070. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  15071. */
  15072. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  15073. /**
  15074. * Compute the transpose of a given matrix
  15075. * @param matrix defines the matrix to transpose
  15076. * @returns the new matrix
  15077. */
  15078. static Transpose(matrix: Matrix): Matrix;
  15079. /**
  15080. * Compute the transpose of a matrix and store it in a target matrix
  15081. * @param matrix defines the matrix to transpose
  15082. * @param result defines the target matrix
  15083. */
  15084. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  15085. /**
  15086. * Computes a reflection matrix from a plane
  15087. * @param plane defines the reflection plane
  15088. * @returns a new matrix
  15089. */
  15090. static Reflection(plane: Plane): Matrix;
  15091. /**
  15092. * Computes a reflection matrix from a plane
  15093. * @param plane defines the reflection plane
  15094. * @param result defines the target matrix
  15095. */
  15096. static ReflectionToRef(plane: Plane, result: Matrix): void;
  15097. /**
  15098. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  15099. * @param xaxis defines the value of the 1st axis
  15100. * @param yaxis defines the value of the 2nd axis
  15101. * @param zaxis defines the value of the 3rd axis
  15102. * @param result defines the target matrix
  15103. */
  15104. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  15105. /**
  15106. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  15107. * @param quat defines the quaternion to use
  15108. * @param result defines the target matrix
  15109. */
  15110. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  15111. }
  15112. class Plane {
  15113. normal: Vector3;
  15114. d: number;
  15115. /**
  15116. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  15117. */
  15118. constructor(a: number, b: number, c: number, d: number);
  15119. /**
  15120. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  15121. */
  15122. asArray(): number[];
  15123. /**
  15124. * Returns a new plane copied from the current Plane.
  15125. */
  15126. clone(): Plane;
  15127. /**
  15128. * Returns the string "Plane".
  15129. */
  15130. getClassName(): string;
  15131. /**
  15132. * Returns the Plane hash code.
  15133. */
  15134. getHashCode(): number;
  15135. /**
  15136. * Normalize the current Plane in place.
  15137. * Returns the updated Plane.
  15138. */
  15139. normalize(): Plane;
  15140. /**
  15141. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  15142. */
  15143. transform(transformation: Matrix): Plane;
  15144. /**
  15145. * Returns the dot product (float) of the point coordinates and the plane normal.
  15146. */
  15147. dotCoordinate(point: Vector3): number;
  15148. /**
  15149. * Updates the current Plane from the plane defined by the three given points.
  15150. * Returns the updated Plane.
  15151. */
  15152. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15153. /**
  15154. * Boolean : True is the vector "direction" is the same side than the plane normal.
  15155. */
  15156. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  15157. /**
  15158. * Returns the signed distance (float) from the given point to the Plane.
  15159. */
  15160. signedDistanceTo(point: Vector3): number;
  15161. /**
  15162. * Returns a new Plane from the given array.
  15163. */
  15164. static FromArray(array: ArrayLike<number>): Plane;
  15165. /**
  15166. * Returns a new Plane defined by the three given points.
  15167. */
  15168. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15169. /**
  15170. * Returns a new Plane the normal vector to this plane at the given origin point.
  15171. * Note : the vector "normal" is updated because normalized.
  15172. */
  15173. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  15174. /**
  15175. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  15176. */
  15177. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  15178. }
  15179. class Viewport {
  15180. x: number;
  15181. y: number;
  15182. width: number;
  15183. height: number;
  15184. /**
  15185. * Creates a Viewport object located at (x, y) and sized (width, height).
  15186. */
  15187. constructor(x: number, y: number, width: number, height: number);
  15188. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  15189. /**
  15190. * Returns a new Viewport copied from the current one.
  15191. */
  15192. clone(): Viewport;
  15193. }
  15194. class Frustum {
  15195. /**
  15196. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15197. */
  15198. static GetPlanes(transform: Matrix): Plane[];
  15199. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15200. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15201. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15202. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15203. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15204. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15205. /**
  15206. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15207. */
  15208. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  15209. }
  15210. /** Defines supported spaces */
  15211. enum Space {
  15212. /** Local (object) space */
  15213. LOCAL = 0,
  15214. /** World space */
  15215. WORLD = 1,
  15216. /** Bone space */
  15217. BONE = 2,
  15218. }
  15219. /** Defines the 3 main axes */
  15220. class Axis {
  15221. /** X axis */
  15222. static X: Vector3;
  15223. /** Y axis */
  15224. static Y: Vector3;
  15225. /** Z axis */
  15226. static Z: Vector3;
  15227. }
  15228. class BezierCurve {
  15229. /**
  15230. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  15231. */
  15232. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  15233. }
  15234. /**
  15235. * Defines potential orientation for back face culling
  15236. */
  15237. enum Orientation {
  15238. /**
  15239. * Clockwise
  15240. */
  15241. CW = 0,
  15242. /** Counter clockwise */
  15243. CCW = 1,
  15244. }
  15245. /**
  15246. * Defines angle representation
  15247. */
  15248. class Angle {
  15249. private _radians;
  15250. /**
  15251. * Creates an Angle object of "radians" radians (float).
  15252. */
  15253. constructor(radians: number);
  15254. /**
  15255. * Get value in degrees
  15256. * @returns the Angle value in degrees (float)
  15257. */
  15258. degrees(): number;
  15259. /**
  15260. * Get value in radians
  15261. * @returns the Angle value in radians (float)
  15262. */
  15263. radians(): number;
  15264. /**
  15265. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  15266. * @param a defines first vector
  15267. * @param b defines second vector
  15268. * @returns a new Angle
  15269. */
  15270. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  15271. /**
  15272. * Gets a new Angle object from the given float in radians
  15273. * @param radians defines the angle value in radians
  15274. * @returns a new Angle
  15275. */
  15276. static FromRadians(radians: number): Angle;
  15277. /**
  15278. * Gets a new Angle object from the given float in degrees
  15279. * @param degrees defines the angle value in degrees
  15280. * @returns a new Angle
  15281. */
  15282. static FromDegrees(degrees: number): Angle;
  15283. }
  15284. class Arc2 {
  15285. startPoint: Vector2;
  15286. midPoint: Vector2;
  15287. endPoint: Vector2;
  15288. centerPoint: Vector2;
  15289. radius: number;
  15290. angle: Angle;
  15291. startAngle: Angle;
  15292. orientation: Orientation;
  15293. /**
  15294. * Creates an Arc object from the three given points : start, middle and end.
  15295. */
  15296. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  15297. }
  15298. class Path2 {
  15299. private _points;
  15300. private _length;
  15301. closed: boolean;
  15302. /**
  15303. * Creates a Path2 object from the starting 2D coordinates x and y.
  15304. */
  15305. constructor(x: number, y: number);
  15306. /**
  15307. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  15308. * Returns the updated Path2.
  15309. */
  15310. addLineTo(x: number, y: number): Path2;
  15311. /**
  15312. * 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.
  15313. * Returns the updated Path2.
  15314. */
  15315. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  15316. /**
  15317. * Closes the Path2.
  15318. * Returns the Path2.
  15319. */
  15320. close(): Path2;
  15321. /**
  15322. * Returns the Path2 total length (float).
  15323. */
  15324. length(): number;
  15325. /**
  15326. * Returns the Path2 internal array of points.
  15327. */
  15328. getPoints(): Vector2[];
  15329. /**
  15330. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  15331. */
  15332. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  15333. /**
  15334. * Returns a new Path2 starting at the coordinates (x, y).
  15335. */
  15336. static StartingAt(x: number, y: number): Path2;
  15337. }
  15338. class Path3D {
  15339. path: Vector3[];
  15340. private _curve;
  15341. private _distances;
  15342. private _tangents;
  15343. private _normals;
  15344. private _binormals;
  15345. private _raw;
  15346. /**
  15347. * new Path3D(path, normal, raw)
  15348. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  15349. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  15350. * path : an array of Vector3, the curve axis of the Path3D
  15351. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  15352. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  15353. */
  15354. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  15355. /**
  15356. * Returns the Path3D array of successive Vector3 designing its curve.
  15357. */
  15358. getCurve(): Vector3[];
  15359. /**
  15360. * Returns an array populated with tangent vectors on each Path3D curve point.
  15361. */
  15362. getTangents(): Vector3[];
  15363. /**
  15364. * Returns an array populated with normal vectors on each Path3D curve point.
  15365. */
  15366. getNormals(): Vector3[];
  15367. /**
  15368. * Returns an array populated with binormal vectors on each Path3D curve point.
  15369. */
  15370. getBinormals(): Vector3[];
  15371. /**
  15372. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15373. */
  15374. getDistances(): number[];
  15375. /**
  15376. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15377. * Returns the same object updated.
  15378. */
  15379. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15380. private _compute(firstNormal);
  15381. private _getFirstNonNullVector(index);
  15382. private _getLastNonNullVector(index);
  15383. private _normalVector(v0, vt, va);
  15384. }
  15385. class Curve3 {
  15386. private _points;
  15387. private _length;
  15388. /**
  15389. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15390. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15391. * @param v1 (Vector3) the control point
  15392. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15393. * @param nbPoints (integer) the wanted number of points in the curve
  15394. */
  15395. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15396. /**
  15397. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15398. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15399. * @param v1 (Vector3) the first control point
  15400. * @param v2 (Vector3) the second control point
  15401. * @param v3 (Vector3) the end point of the Cubic Bezier
  15402. * @param nbPoints (integer) the wanted number of points in the curve
  15403. */
  15404. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15405. /**
  15406. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15407. * @param p1 (Vector3) the origin point of the Hermite Spline
  15408. * @param t1 (Vector3) the tangent vector at the origin point
  15409. * @param p2 (Vector3) the end point of the Hermite Spline
  15410. * @param t2 (Vector3) the tangent vector at the end point
  15411. * @param nbPoints (integer) the wanted number of points in the curve
  15412. */
  15413. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15414. /**
  15415. * Returns a Curve3 object along a CatmullRom Spline curve :
  15416. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  15417. * @param nbPoints (integer) the wanted number of points between each curve control points
  15418. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  15419. */
  15420. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  15421. /**
  15422. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15423. * A Curve3 is designed from a series of successive Vector3.
  15424. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15425. */
  15426. constructor(points: Vector3[]);
  15427. /**
  15428. * Returns the Curve3 stored array of successive Vector3
  15429. */
  15430. getPoints(): Vector3[];
  15431. /**
  15432. * Returns the computed length (float) of the curve.
  15433. */
  15434. length(): number;
  15435. /**
  15436. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15437. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15438. * curveA and curveB keep unchanged.
  15439. */
  15440. continue(curve: Curve3): Curve3;
  15441. private _computeLength(path);
  15442. }
  15443. class PositionNormalVertex {
  15444. position: Vector3;
  15445. normal: Vector3;
  15446. constructor(position?: Vector3, normal?: Vector3);
  15447. clone(): PositionNormalVertex;
  15448. }
  15449. class PositionNormalTextureVertex {
  15450. position: Vector3;
  15451. normal: Vector3;
  15452. uv: Vector2;
  15453. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15454. clone(): PositionNormalTextureVertex;
  15455. }
  15456. class Tmp {
  15457. static Color3: Color3[];
  15458. static Vector2: Vector2[];
  15459. static Vector3: Vector3[];
  15460. static Vector4: Vector4[];
  15461. static Quaternion: Quaternion[];
  15462. static Matrix: Matrix[];
  15463. }
  15464. }
  15465. declare module BABYLON {
  15466. class SphericalPolynomial {
  15467. x: Vector3;
  15468. y: Vector3;
  15469. z: Vector3;
  15470. xx: Vector3;
  15471. yy: Vector3;
  15472. zz: Vector3;
  15473. xy: Vector3;
  15474. yz: Vector3;
  15475. zx: Vector3;
  15476. addAmbient(color: Color3): void;
  15477. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15478. scale(scale: number): void;
  15479. }
  15480. class SphericalHarmonics {
  15481. L00: Vector3;
  15482. L1_1: Vector3;
  15483. L10: Vector3;
  15484. L11: Vector3;
  15485. L2_2: Vector3;
  15486. L2_1: Vector3;
  15487. L20: Vector3;
  15488. L21: Vector3;
  15489. L22: Vector3;
  15490. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15491. scale(scale: number): void;
  15492. convertIncidentRadianceToIrradiance(): void;
  15493. convertIrradianceToLambertianRadiance(): void;
  15494. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15501. * 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;
  15502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15503. */
  15504. class ColorCurves {
  15505. private _dirty;
  15506. private _tempColor;
  15507. private _globalCurve;
  15508. private _highlightsCurve;
  15509. private _midtonesCurve;
  15510. private _shadowsCurve;
  15511. private _positiveCurve;
  15512. private _negativeCurve;
  15513. private _globalHue;
  15514. private _globalDensity;
  15515. private _globalSaturation;
  15516. private _globalExposure;
  15517. /**
  15518. * Gets the global Hue value.
  15519. * 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).
  15520. */
  15521. /**
  15522. * Sets the global Hue value.
  15523. * 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).
  15524. */
  15525. globalHue: number;
  15526. /**
  15527. * Gets the global Density value.
  15528. * 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.
  15529. * Values less than zero provide a filter of opposite hue.
  15530. */
  15531. /**
  15532. * Sets the global Density value.
  15533. * 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.
  15534. * Values less than zero provide a filter of opposite hue.
  15535. */
  15536. globalDensity: number;
  15537. /**
  15538. * Gets the global Saturation value.
  15539. * 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.
  15540. */
  15541. /**
  15542. * Sets the global Saturation value.
  15543. * 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.
  15544. */
  15545. globalSaturation: number;
  15546. /**
  15547. * Gets the global Exposure value.
  15548. * 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.
  15549. */
  15550. /**
  15551. * Sets the global Exposure value.
  15552. * 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.
  15553. */
  15554. globalExposure: number;
  15555. private _highlightsHue;
  15556. private _highlightsDensity;
  15557. private _highlightsSaturation;
  15558. private _highlightsExposure;
  15559. /**
  15560. * Gets the highlights Hue value.
  15561. * 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).
  15562. */
  15563. /**
  15564. * Sets the highlights Hue value.
  15565. * 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).
  15566. */
  15567. highlightsHue: number;
  15568. /**
  15569. * Gets the highlights Density value.
  15570. * 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.
  15571. * Values less than zero provide a filter of opposite hue.
  15572. */
  15573. /**
  15574. * Sets the highlights Density value.
  15575. * 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.
  15576. * Values less than zero provide a filter of opposite hue.
  15577. */
  15578. highlightsDensity: number;
  15579. /**
  15580. * Gets the highlights Saturation value.
  15581. * 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.
  15582. */
  15583. /**
  15584. * Sets the highlights Saturation value.
  15585. * 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.
  15586. */
  15587. highlightsSaturation: number;
  15588. /**
  15589. * Gets the highlights Exposure value.
  15590. * 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.
  15591. */
  15592. /**
  15593. * Sets the highlights Exposure value.
  15594. * 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.
  15595. */
  15596. highlightsExposure: number;
  15597. private _midtonesHue;
  15598. private _midtonesDensity;
  15599. private _midtonesSaturation;
  15600. private _midtonesExposure;
  15601. /**
  15602. * Gets the midtones Hue value.
  15603. * 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).
  15604. */
  15605. /**
  15606. * Sets the midtones Hue value.
  15607. * 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).
  15608. */
  15609. midtonesHue: number;
  15610. /**
  15611. * Gets the midtones Density value.
  15612. * 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.
  15613. * Values less than zero provide a filter of opposite hue.
  15614. */
  15615. /**
  15616. * Sets the midtones Density value.
  15617. * 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.
  15618. * Values less than zero provide a filter of opposite hue.
  15619. */
  15620. midtonesDensity: number;
  15621. /**
  15622. * Gets the midtones Saturation value.
  15623. * 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.
  15624. */
  15625. /**
  15626. * Sets the midtones Saturation value.
  15627. * 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.
  15628. */
  15629. midtonesSaturation: number;
  15630. /**
  15631. * Gets the midtones Exposure value.
  15632. * 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.
  15633. */
  15634. /**
  15635. * Sets the midtones Exposure value.
  15636. * 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.
  15637. */
  15638. midtonesExposure: number;
  15639. private _shadowsHue;
  15640. private _shadowsDensity;
  15641. private _shadowsSaturation;
  15642. private _shadowsExposure;
  15643. /**
  15644. * Gets the shadows Hue value.
  15645. * 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).
  15646. */
  15647. /**
  15648. * Sets the shadows Hue value.
  15649. * 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).
  15650. */
  15651. shadowsHue: number;
  15652. /**
  15653. * Gets the shadows Density value.
  15654. * 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.
  15655. * Values less than zero provide a filter of opposite hue.
  15656. */
  15657. /**
  15658. * Sets the shadows Density value.
  15659. * 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.
  15660. * Values less than zero provide a filter of opposite hue.
  15661. */
  15662. shadowsDensity: number;
  15663. /**
  15664. * Gets the shadows Saturation value.
  15665. * 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.
  15666. */
  15667. /**
  15668. * Sets the shadows Saturation value.
  15669. * 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.
  15670. */
  15671. shadowsSaturation: number;
  15672. /**
  15673. * Gets the shadows Exposure value.
  15674. * 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.
  15675. */
  15676. /**
  15677. * Sets the shadows Exposure value.
  15678. * 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.
  15679. */
  15680. shadowsExposure: number;
  15681. getClassName(): string;
  15682. /**
  15683. * Binds the color curves to the shader.
  15684. * @param colorCurves The color curve to bind
  15685. * @param effect The effect to bind to
  15686. */
  15687. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15688. /**
  15689. * Prepare the list of uniforms associated with the ColorCurves effects.
  15690. * @param uniformsList The list of uniforms used in the effect
  15691. */
  15692. static PrepareUniforms(uniformsList: string[]): void;
  15693. /**
  15694. * Returns color grading data based on a hue, density, saturation and exposure value.
  15695. * @param filterHue The hue of the color filter.
  15696. * @param filterDensity The density of the color filter.
  15697. * @param saturation The saturation.
  15698. * @param exposure The exposure.
  15699. * @param result The result data container.
  15700. */
  15701. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  15702. /**
  15703. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15704. * @param value The input slider value in range [-100,100].
  15705. * @returns Adjusted value.
  15706. */
  15707. private static applyColorGradingSliderNonlinear(value);
  15708. /**
  15709. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15710. * @param hue The hue (H) input.
  15711. * @param saturation The saturation (S) input.
  15712. * @param brightness The brightness (B) input.
  15713. * @result An RGBA color represented as Vector4.
  15714. */
  15715. private static fromHSBToRef(hue, saturation, brightness, result);
  15716. /**
  15717. * Returns a value clamped between min and max
  15718. * @param value The value to clamp
  15719. * @param min The minimum of value
  15720. * @param max The maximum of value
  15721. * @returns The clamped value.
  15722. */
  15723. private static clamp(value, min, max);
  15724. /**
  15725. * Clones the current color curve instance.
  15726. * @return The cloned curves
  15727. */
  15728. clone(): ColorCurves;
  15729. /**
  15730. * Serializes the current color curve instance to a json representation.
  15731. * @return a JSON representation
  15732. */
  15733. serialize(): any;
  15734. /**
  15735. * Parses the color curve from a json representation.
  15736. * @param source the JSON source to parse
  15737. * @return The parsed curves
  15738. */
  15739. static Parse(source: any): ColorCurves;
  15740. }
  15741. }
  15742. declare module BABYLON {
  15743. /**
  15744. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15745. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15746. */
  15747. class EffectFallbacks {
  15748. private _defines;
  15749. private _currentRank;
  15750. private _maxRank;
  15751. private _mesh;
  15752. /**
  15753. * Removes the fallback from the bound mesh.
  15754. */
  15755. unBindMesh(): void;
  15756. /**
  15757. * Adds a fallback on the specified property.
  15758. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15759. * @param define The name of the define in the shader
  15760. */
  15761. addFallback(rank: number, define: string): void;
  15762. /**
  15763. * Sets the mesh to use CPU skinning when needing to fallback.
  15764. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15765. * @param mesh The mesh to use the fallbacks.
  15766. */
  15767. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15768. /**
  15769. * Checks to see if more fallbacks are still availible.
  15770. */
  15771. readonly isMoreFallbacks: boolean;
  15772. /**
  15773. * Removes the defines that shoould be removed when falling back.
  15774. * @param currentDefines defines the current define statements for the shader.
  15775. * @param effect defines the current effect we try to compile
  15776. * @returns The resulting defines with defines of the current rank removed.
  15777. */
  15778. reduce(currentDefines: string, effect: Effect): string;
  15779. }
  15780. /**
  15781. * Options to be used when creating an effect.
  15782. */
  15783. class EffectCreationOptions {
  15784. /**
  15785. * Atrributes that will be used in the shader.
  15786. */
  15787. attributes: string[];
  15788. /**
  15789. * Uniform varible names that will be set in the shader.
  15790. */
  15791. uniformsNames: string[];
  15792. /**
  15793. * Uniform buffer varible names that will be set in the shader.
  15794. */
  15795. uniformBuffersNames: string[];
  15796. /**
  15797. * Sampler texture variable names that will be set in the shader.
  15798. */
  15799. samplers: string[];
  15800. /**
  15801. * Define statements that will be set in the shader.
  15802. */
  15803. defines: any;
  15804. /**
  15805. * Possible fallbacks for this effect to improve performance when needed.
  15806. */
  15807. fallbacks: Nullable<EffectFallbacks>;
  15808. /**
  15809. * Callback that will be called when the shader is compiled.
  15810. */
  15811. onCompiled: Nullable<(effect: Effect) => void>;
  15812. /**
  15813. * Callback that will be called if an error occurs during shader compilation.
  15814. */
  15815. onError: Nullable<(effect: Effect, errors: string) => void>;
  15816. /**
  15817. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15818. */
  15819. indexParameters: any;
  15820. /**
  15821. * Max number of lights that can be used in the shader.
  15822. */
  15823. maxSimultaneousLights: number;
  15824. /**
  15825. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  15826. */
  15827. transformFeedbackVaryings: Nullable<string[]>;
  15828. }
  15829. /**
  15830. * Effect containing vertex and fragment shader that can be executed on an object.
  15831. */
  15832. class Effect {
  15833. /**
  15834. * Name of the effect.
  15835. */
  15836. name: any;
  15837. /**
  15838. * String container all the define statements that should be set on the shader.
  15839. */
  15840. defines: string;
  15841. /**
  15842. * Callback that will be called when the shader is compiled.
  15843. */
  15844. onCompiled: Nullable<(effect: Effect) => void>;
  15845. /**
  15846. * Callback that will be called if an error occurs during shader compilation.
  15847. */
  15848. onError: Nullable<(effect: Effect, errors: string) => void>;
  15849. /**
  15850. * Callback that will be called when effect is bound.
  15851. */
  15852. onBind: Nullable<(effect: Effect) => void>;
  15853. /**
  15854. * Unique ID of the effect.
  15855. */
  15856. uniqueId: number;
  15857. /**
  15858. * Observable that will be called when the shader is compiled.
  15859. */
  15860. onCompileObservable: Observable<Effect>;
  15861. /**
  15862. * Observable that will be called if an error occurs during shader compilation.
  15863. */
  15864. onErrorObservable: Observable<Effect>;
  15865. /**
  15866. * Observable that will be called when effect is bound.
  15867. */
  15868. onBindObservable: Observable<Effect>;
  15869. /** @hidden */
  15870. private static _uniqueIdSeed;
  15871. private _engine;
  15872. private _uniformBuffersNames;
  15873. private _uniformsNames;
  15874. private _samplers;
  15875. private _isReady;
  15876. private _compilationError;
  15877. private _attributesNames;
  15878. private _attributes;
  15879. private _uniforms;
  15880. /**
  15881. * Key for the effect.
  15882. */
  15883. private _indexParameters;
  15884. private _fallbacks;
  15885. private _vertexSourceCode;
  15886. private _fragmentSourceCode;
  15887. private _vertexSourceCodeOverride;
  15888. private _fragmentSourceCodeOverride;
  15889. private _transformFeedbackVaryings;
  15890. /**
  15891. * Compiled shader to webGL program.
  15892. */
  15893. private _valueCache;
  15894. private static _baseCache;
  15895. /**
  15896. * Instantiates an effect.
  15897. * An effect can be used to create/manage/execute vertex and fragment shaders.
  15898. * @param baseName Name of the effect.
  15899. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  15900. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  15901. * @param samplers List of sampler variables that will be passed to the shader.
  15902. * @param engine Engine to be used to render the effect
  15903. * @param defines Define statements to be added to the shader.
  15904. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  15905. * @param onCompiled Callback that will be called when the shader is compiled.
  15906. * @param onError Callback that will be called if an error occurs during shader compilation.
  15907. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15908. */
  15909. 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);
  15910. /**
  15911. * Unique key for this effect
  15912. */
  15913. readonly key: string;
  15914. /**
  15915. * If the effect has been compiled and prepared.
  15916. * @returns if the effect is compiled and prepared.
  15917. */
  15918. isReady(): boolean;
  15919. /**
  15920. * The engine the effect was initialized with.
  15921. * @returns the engine.
  15922. */
  15923. getEngine(): Engine;
  15924. /**
  15925. * The compiled webGL program for the effect
  15926. * @returns the webGL program.
  15927. */
  15928. getProgram(): WebGLProgram;
  15929. /**
  15930. * The set of names of attribute variables for the shader.
  15931. * @returns An array of attribute names.
  15932. */
  15933. getAttributesNames(): string[];
  15934. /**
  15935. * Returns the attribute at the given index.
  15936. * @param index The index of the attribute.
  15937. * @returns The location of the attribute.
  15938. */
  15939. getAttributeLocation(index: number): number;
  15940. /**
  15941. * Returns the attribute based on the name of the variable.
  15942. * @param name of the attribute to look up.
  15943. * @returns the attribute location.
  15944. */
  15945. getAttributeLocationByName(name: string): number;
  15946. /**
  15947. * The number of attributes.
  15948. * @returns the numnber of attributes.
  15949. */
  15950. getAttributesCount(): number;
  15951. /**
  15952. * Gets the index of a uniform variable.
  15953. * @param uniformName of the uniform to look up.
  15954. * @returns the index.
  15955. */
  15956. getUniformIndex(uniformName: string): number;
  15957. /**
  15958. * Returns the attribute based on the name of the variable.
  15959. * @param uniformName of the uniform to look up.
  15960. * @returns the location of the uniform.
  15961. */
  15962. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  15963. /**
  15964. * Returns an array of sampler variable names
  15965. * @returns The array of sampler variable neames.
  15966. */
  15967. getSamplers(): string[];
  15968. /**
  15969. * The error from the last compilation.
  15970. * @returns the error string.
  15971. */
  15972. getCompilationError(): string;
  15973. /**
  15974. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  15975. * @param func The callback to be used.
  15976. */
  15977. executeWhenCompiled(func: (effect: Effect) => void): void;
  15978. /** @hidden */
  15979. /** @hidden */
  15980. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  15981. private _processShaderConversion(sourceCode, isFragment, callback);
  15982. private _processIncludes(sourceCode, callback);
  15983. private _processPrecision(source);
  15984. /**
  15985. * Recompiles the webGL program
  15986. * @param vertexSourceCode The source code for the vertex shader.
  15987. * @param fragmentSourceCode The source code for the fragment shader.
  15988. * @param onCompiled Callback called when completed.
  15989. * @param onError Callback called on error.
  15990. */
  15991. /**
  15992. * Gets the uniform locations of the the specified variable names
  15993. * @param names THe names of the variables to lookup.
  15994. * @returns Array of locations in the same order as variable names.
  15995. */
  15996. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  15997. /**
  15998. * Prepares the effect
  15999. */
  16000. /**
  16001. * Checks if the effect is supported. (Must be called after compilation)
  16002. */
  16003. readonly isSupported: boolean;
  16004. /**
  16005. * Binds a texture to the engine to be used as output of the shader.
  16006. * @param channel Name of the output variable.
  16007. * @param texture Texture to bind.
  16008. */
  16009. /**
  16010. * Sets a texture on the engine to be used in the shader.
  16011. * @param channel Name of the sampler variable.
  16012. * @param texture Texture to set.
  16013. */
  16014. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16015. /**
  16016. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16017. * @param channel Name of the sampler variable.
  16018. * @param texture Texture to set.
  16019. */
  16020. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16021. /**
  16022. * Sets an array of textures on the engine to be used in the shader.
  16023. * @param channel Name of the variable.
  16024. * @param textures Textures to set.
  16025. */
  16026. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16027. /**
  16028. * 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)
  16029. * @param channel Name of the sampler variable.
  16030. * @param postProcess Post process to get the input texture from.
  16031. */
  16032. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16033. /**
  16034. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16035. * 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)
  16036. * @param channel Name of the sampler variable.
  16037. * @param postProcess Post process to get the output texture from.
  16038. */
  16039. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16040. /** @hidden */
  16041. /** @hidden */
  16042. /** @hidden */
  16043. /** @hidden */
  16044. /**
  16045. * Binds a buffer to a uniform.
  16046. * @param buffer Buffer to bind.
  16047. * @param name Name of the uniform variable to bind to.
  16048. */
  16049. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16050. /**
  16051. * Binds block to a uniform.
  16052. * @param blockName Name of the block to bind.
  16053. * @param index Index to bind.
  16054. */
  16055. bindUniformBlock(blockName: string, index: number): void;
  16056. /**
  16057. * Sets an interger value on a uniform variable.
  16058. * @param uniformName Name of the variable.
  16059. * @param value Value to be set.
  16060. * @returns this effect.
  16061. */
  16062. setInt(uniformName: string, value: number): Effect;
  16063. /**
  16064. * Sets an int array on a uniform variable.
  16065. * @param uniformName Name of the variable.
  16066. * @param array array to be set.
  16067. * @returns this effect.
  16068. */
  16069. setIntArray(uniformName: string, array: Int32Array): Effect;
  16070. /**
  16071. * 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)
  16072. * @param uniformName Name of the variable.
  16073. * @param array array to be set.
  16074. * @returns this effect.
  16075. */
  16076. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16077. /**
  16078. * 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)
  16079. * @param uniformName Name of the variable.
  16080. * @param array array to be set.
  16081. * @returns this effect.
  16082. */
  16083. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16084. /**
  16085. * 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)
  16086. * @param uniformName Name of the variable.
  16087. * @param array array to be set.
  16088. * @returns this effect.
  16089. */
  16090. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16091. /**
  16092. * Sets an float array on a uniform variable.
  16093. * @param uniformName Name of the variable.
  16094. * @param array array to be set.
  16095. * @returns this effect.
  16096. */
  16097. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16098. /**
  16099. * 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)
  16100. * @param uniformName Name of the variable.
  16101. * @param array array to be set.
  16102. * @returns this effect.
  16103. */
  16104. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16105. /**
  16106. * 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)
  16107. * @param uniformName Name of the variable.
  16108. * @param array array to be set.
  16109. * @returns this effect.
  16110. */
  16111. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16112. /**
  16113. * 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)
  16114. * @param uniformName Name of the variable.
  16115. * @param array array to be set.
  16116. * @returns this effect.
  16117. */
  16118. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16119. /**
  16120. * Sets an array on a uniform variable.
  16121. * @param uniformName Name of the variable.
  16122. * @param array array to be set.
  16123. * @returns this effect.
  16124. */
  16125. setArray(uniformName: string, array: number[]): Effect;
  16126. /**
  16127. * 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)
  16128. * @param uniformName Name of the variable.
  16129. * @param array array to be set.
  16130. * @returns this effect.
  16131. */
  16132. setArray2(uniformName: string, array: number[]): Effect;
  16133. /**
  16134. * 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)
  16135. * @param uniformName Name of the variable.
  16136. * @param array array to be set.
  16137. * @returns this effect.
  16138. */
  16139. setArray3(uniformName: string, array: number[]): Effect;
  16140. /**
  16141. * 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)
  16142. * @param uniformName Name of the variable.
  16143. * @param array array to be set.
  16144. * @returns this effect.
  16145. */
  16146. setArray4(uniformName: string, array: number[]): Effect;
  16147. /**
  16148. * Sets matrices on a uniform variable.
  16149. * @param uniformName Name of the variable.
  16150. * @param matrices matrices to be set.
  16151. * @returns this effect.
  16152. */
  16153. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16154. /**
  16155. * Sets matrix on a uniform variable.
  16156. * @param uniformName Name of the variable.
  16157. * @param matrix matrix to be set.
  16158. * @returns this effect.
  16159. */
  16160. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16161. /**
  16162. * 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)
  16163. * @param uniformName Name of the variable.
  16164. * @param matrix matrix to be set.
  16165. * @returns this effect.
  16166. */
  16167. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16168. /**
  16169. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16170. * @param uniformName Name of the variable.
  16171. * @param matrix matrix to be set.
  16172. * @returns this effect.
  16173. */
  16174. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16175. /**
  16176. * Sets a float on a uniform variable.
  16177. * @param uniformName Name of the variable.
  16178. * @param value value to be set.
  16179. * @returns this effect.
  16180. */
  16181. setFloat(uniformName: string, value: number): Effect;
  16182. /**
  16183. * Sets a boolean on a uniform variable.
  16184. * @param uniformName Name of the variable.
  16185. * @param bool value to be set.
  16186. * @returns this effect.
  16187. */
  16188. setBool(uniformName: string, bool: boolean): Effect;
  16189. /**
  16190. * Sets a Vector2 on a uniform variable.
  16191. * @param uniformName Name of the variable.
  16192. * @param vector2 vector2 to be set.
  16193. * @returns this effect.
  16194. */
  16195. setVector2(uniformName: string, vector2: Vector2): Effect;
  16196. /**
  16197. * Sets a float2 on a uniform variable.
  16198. * @param uniformName Name of the variable.
  16199. * @param x First float in float2.
  16200. * @param y Second float in float2.
  16201. * @returns this effect.
  16202. */
  16203. setFloat2(uniformName: string, x: number, y: number): Effect;
  16204. /**
  16205. * Sets a Vector3 on a uniform variable.
  16206. * @param uniformName Name of the variable.
  16207. * @param vector3 Value to be set.
  16208. * @returns this effect.
  16209. */
  16210. setVector3(uniformName: string, vector3: Vector3): Effect;
  16211. /**
  16212. * Sets a float3 on a uniform variable.
  16213. * @param uniformName Name of the variable.
  16214. * @param x First float in float3.
  16215. * @param y Second float in float3.
  16216. * @param z Third float in float3.
  16217. * @returns this effect.
  16218. */
  16219. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16220. /**
  16221. * Sets a Vector4 on a uniform variable.
  16222. * @param uniformName Name of the variable.
  16223. * @param vector4 Value to be set.
  16224. * @returns this effect.
  16225. */
  16226. setVector4(uniformName: string, vector4: Vector4): Effect;
  16227. /**
  16228. * Sets a float4 on a uniform variable.
  16229. * @param uniformName Name of the variable.
  16230. * @param x First float in float4.
  16231. * @param y Second float in float4.
  16232. * @param z Third float in float4.
  16233. * @param w Fourth float in float4.
  16234. * @returns this effect.
  16235. */
  16236. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16237. /**
  16238. * Sets a Color3 on a uniform variable.
  16239. * @param uniformName Name of the variable.
  16240. * @param color3 Value to be set.
  16241. * @returns this effect.
  16242. */
  16243. setColor3(uniformName: string, color3: Color3): Effect;
  16244. /**
  16245. * Sets a Color4 on a uniform variable.
  16246. * @param uniformName Name of the variable.
  16247. * @param color3 Value to be set.
  16248. * @param alpha Alpha value to be set.
  16249. * @returns this effect.
  16250. */
  16251. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16252. /**
  16253. * Sets a Color4 on a uniform variable
  16254. * @param uniformName defines the name of the variable
  16255. * @param color4 defines the value to be set
  16256. * @returns this effect.
  16257. */
  16258. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16259. /**
  16260. * Store of each shader (The can be looked up using effect.key)
  16261. */
  16262. static ShadersStore: {
  16263. [key: string]: string;
  16264. };
  16265. /**
  16266. * Store of each included file for a shader (The can be looked up using effect.key)
  16267. */
  16268. static IncludesShadersStore: {
  16269. [key: string]: string;
  16270. };
  16271. /**
  16272. * Resets the cache of effects.
  16273. */
  16274. static ResetCache(): void;
  16275. }
  16276. }
  16277. declare module BABYLON {
  16278. class FresnelParameters {
  16279. private _isEnabled;
  16280. isEnabled: boolean;
  16281. leftColor: Color3;
  16282. rightColor: Color3;
  16283. bias: number;
  16284. power: number;
  16285. clone(): FresnelParameters;
  16286. serialize(): any;
  16287. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16288. }
  16289. }
  16290. declare module BABYLON {
  16291. /**
  16292. * Interface to follow in your material defines to integrate easily the
  16293. * Image proccessing functions.
  16294. * @hidden
  16295. */
  16296. interface IImageProcessingConfigurationDefines {
  16297. IMAGEPROCESSING: boolean;
  16298. VIGNETTE: boolean;
  16299. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16300. VIGNETTEBLENDMODEOPAQUE: boolean;
  16301. TONEMAPPING: boolean;
  16302. CONTRAST: boolean;
  16303. EXPOSURE: boolean;
  16304. COLORCURVES: boolean;
  16305. COLORGRADING: boolean;
  16306. COLORGRADING3D: boolean;
  16307. SAMPLER3DGREENDEPTH: boolean;
  16308. SAMPLER3DBGRMAP: boolean;
  16309. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16310. }
  16311. /**
  16312. * This groups together the common properties used for image processing either in direct forward pass
  16313. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16314. * or not.
  16315. */
  16316. class ImageProcessingConfiguration {
  16317. /**
  16318. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16319. */
  16320. colorCurves: Nullable<ColorCurves>;
  16321. private _colorCurvesEnabled;
  16322. /**
  16323. * Gets wether the color curves effect is enabled.
  16324. */
  16325. /**
  16326. * Sets wether the color curves effect is enabled.
  16327. */
  16328. colorCurvesEnabled: boolean;
  16329. /**
  16330. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16331. */
  16332. colorGradingTexture: Nullable<BaseTexture>;
  16333. private _colorGradingEnabled;
  16334. /**
  16335. * Gets wether the color grading effect is enabled.
  16336. */
  16337. /**
  16338. * Sets wether the color grading effect is enabled.
  16339. */
  16340. colorGradingEnabled: boolean;
  16341. private _colorGradingWithGreenDepth;
  16342. /**
  16343. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16344. */
  16345. /**
  16346. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16347. */
  16348. colorGradingWithGreenDepth: boolean;
  16349. private _colorGradingBGR;
  16350. /**
  16351. * Gets wether the color grading texture contains BGR values.
  16352. */
  16353. /**
  16354. * Sets wether the color grading texture contains BGR values.
  16355. */
  16356. colorGradingBGR: boolean;
  16357. /**
  16358. * Gets the Exposure used in the effect.
  16359. */
  16360. /**
  16361. * Sets the Exposure used in the effect.
  16362. */
  16363. exposure: number;
  16364. private _toneMappingEnabled;
  16365. /**
  16366. * Gets wether the tone mapping effect is enabled.
  16367. */
  16368. /**
  16369. * Sets wether the tone mapping effect is enabled.
  16370. */
  16371. toneMappingEnabled: boolean;
  16372. protected _contrast: number;
  16373. /**
  16374. * Gets the contrast used in the effect.
  16375. */
  16376. /**
  16377. * Sets the contrast used in the effect.
  16378. */
  16379. contrast: number;
  16380. /**
  16381. * Vignette stretch size.
  16382. */
  16383. vignetteStretch: number;
  16384. /**
  16385. * Vignette centre X Offset.
  16386. */
  16387. vignetteCentreX: number;
  16388. /**
  16389. * Vignette centre Y Offset.
  16390. */
  16391. vignetteCentreY: number;
  16392. /**
  16393. * Vignette weight or intensity of the vignette effect.
  16394. */
  16395. vignetteWeight: number;
  16396. /**
  16397. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16398. * if vignetteEnabled is set to true.
  16399. */
  16400. vignetteColor: Color4;
  16401. /**
  16402. * Camera field of view used by the Vignette effect.
  16403. */
  16404. vignetteCameraFov: number;
  16405. private _vignetteBlendMode;
  16406. /**
  16407. * Gets the vignette blend mode allowing different kind of effect.
  16408. */
  16409. /**
  16410. * Sets the vignette blend mode allowing different kind of effect.
  16411. */
  16412. vignetteBlendMode: number;
  16413. private _vignetteEnabled;
  16414. /**
  16415. * Gets wether the vignette effect is enabled.
  16416. */
  16417. /**
  16418. * Sets wether the vignette effect is enabled.
  16419. */
  16420. vignetteEnabled: boolean;
  16421. private _applyByPostProcess;
  16422. /**
  16423. * Gets wether the image processing is applied through a post process or not.
  16424. */
  16425. /**
  16426. * Sets wether the image processing is applied through a post process or not.
  16427. */
  16428. applyByPostProcess: boolean;
  16429. private _isEnabled;
  16430. /**
  16431. * Gets wether the image processing is enabled or not.
  16432. */
  16433. /**
  16434. * Sets wether the image processing is enabled or not.
  16435. */
  16436. isEnabled: boolean;
  16437. /**
  16438. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16439. */
  16440. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16441. /**
  16442. * Method called each time the image processing information changes requires to recompile the effect.
  16443. */
  16444. protected _updateParameters(): void;
  16445. getClassName(): string;
  16446. /**
  16447. * Prepare the list of uniforms associated with the Image Processing effects.
  16448. * @param uniformsList The list of uniforms used in the effect
  16449. * @param defines the list of defines currently in use
  16450. */
  16451. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16452. /**
  16453. * Prepare the list of samplers associated with the Image Processing effects.
  16454. * @param uniformsList The list of uniforms used in the effect
  16455. * @param defines the list of defines currently in use
  16456. */
  16457. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16458. /**
  16459. * Prepare the list of defines associated to the shader.
  16460. * @param defines the list of defines to complete
  16461. */
  16462. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16463. /**
  16464. * Returns true if all the image processing information are ready.
  16465. */
  16466. isReady(): boolean;
  16467. /**
  16468. * Binds the image processing to the shader.
  16469. * @param effect The effect to bind to
  16470. */
  16471. bind(effect: Effect, aspectRatio?: number): void;
  16472. /**
  16473. * Clones the current image processing instance.
  16474. * @return The cloned image processing
  16475. */
  16476. clone(): ImageProcessingConfiguration;
  16477. /**
  16478. * Serializes the current image processing instance to a json representation.
  16479. * @return a JSON representation
  16480. */
  16481. serialize(): any;
  16482. /**
  16483. * Parses the image processing from a json representation.
  16484. * @param source the JSON source to parse
  16485. * @return The parsed image processing
  16486. */
  16487. static Parse(source: any): ImageProcessingConfiguration;
  16488. private static _VIGNETTEMODE_MULTIPLY;
  16489. private static _VIGNETTEMODE_OPAQUE;
  16490. /**
  16491. * Used to apply the vignette as a mix with the pixel color.
  16492. */
  16493. static readonly VIGNETTEMODE_MULTIPLY: number;
  16494. /**
  16495. * Used to apply the vignette as a replacement of the pixel color.
  16496. */
  16497. static readonly VIGNETTEMODE_OPAQUE: number;
  16498. }
  16499. }
  16500. declare module BABYLON {
  16501. /**
  16502. * Manages the defines for the Material
  16503. */
  16504. class MaterialDefines {
  16505. private _keys;
  16506. private _isDirty;
  16507. /** @hidden */
  16508. /** @hidden */
  16509. /** @hidden */
  16510. /** @hidden */
  16511. /** @hidden */
  16512. /** @hidden */
  16513. /** @hidden */
  16514. /** @hidden */
  16515. /** @hidden */
  16516. /** @hidden */
  16517. /** @hidden */
  16518. /**
  16519. * Specifies if the material needs to be re-calculated
  16520. */
  16521. readonly isDirty: boolean;
  16522. /**
  16523. * Marks the material to indicate that it has been re-calculated
  16524. */
  16525. markAsProcessed(): void;
  16526. /**
  16527. * Marks the material to indicate that it needs to be re-calculated
  16528. */
  16529. markAsUnprocessed(): void;
  16530. /**
  16531. * Marks the material to indicate all of its defines need to be re-calculated
  16532. */
  16533. markAllAsDirty(): void;
  16534. /**
  16535. * Marks the material to indicate that image processing needs to be re-calculated
  16536. */
  16537. markAsImageProcessingDirty(): void;
  16538. /**
  16539. * Marks the material to indicate the lights need to be re-calculated
  16540. */
  16541. markAsLightDirty(): void;
  16542. /**
  16543. * Marks the attribute state as changed
  16544. */
  16545. markAsAttributesDirty(): void;
  16546. /**
  16547. * Marks the texture state as changed
  16548. */
  16549. markAsTexturesDirty(): void;
  16550. /**
  16551. * Marks the fresnel state as changed
  16552. */
  16553. markAsFresnelDirty(): void;
  16554. /**
  16555. * Marks the misc state as changed
  16556. */
  16557. markAsMiscDirty(): void;
  16558. /**
  16559. * Rebuilds the material defines
  16560. */
  16561. rebuild(): void;
  16562. /**
  16563. * Specifies if two material defines are equal
  16564. * @param other - A material define instance to compare to
  16565. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16566. */
  16567. isEqual(other: MaterialDefines): boolean;
  16568. /**
  16569. * Clones this instance's defines to another instance
  16570. * @param other - material defines to clone values to
  16571. */
  16572. cloneTo(other: MaterialDefines): void;
  16573. /**
  16574. * Resets the material define values
  16575. */
  16576. reset(): void;
  16577. /**
  16578. * Converts the material define values to a string
  16579. * @returns - String of material define information
  16580. */
  16581. toString(): string;
  16582. }
  16583. /**
  16584. * Base class for the main features of a material in Babylon.js
  16585. */
  16586. class Material implements IAnimatable {
  16587. private static _TriangleFillMode;
  16588. private static _WireFrameFillMode;
  16589. private static _PointFillMode;
  16590. private static _PointListDrawMode;
  16591. private static _LineListDrawMode;
  16592. private static _LineLoopDrawMode;
  16593. private static _LineStripDrawMode;
  16594. private static _TriangleStripDrawMode;
  16595. private static _TriangleFanDrawMode;
  16596. /**
  16597. * Returns the triangle fill mode
  16598. */
  16599. static readonly TriangleFillMode: number;
  16600. /**
  16601. * Returns the wireframe mode
  16602. */
  16603. static readonly WireFrameFillMode: number;
  16604. /**
  16605. * Returns the point fill mode
  16606. */
  16607. static readonly PointFillMode: number;
  16608. /**
  16609. * Returns the point list draw mode
  16610. */
  16611. static readonly PointListDrawMode: number;
  16612. /**
  16613. * Returns the line list draw mode
  16614. */
  16615. static readonly LineListDrawMode: number;
  16616. /**
  16617. * Returns the line loop draw mode
  16618. */
  16619. static readonly LineLoopDrawMode: number;
  16620. /**
  16621. * Returns the line strip draw mode
  16622. */
  16623. static readonly LineStripDrawMode: number;
  16624. /**
  16625. * Returns the triangle strip draw mode
  16626. */
  16627. static readonly TriangleStripDrawMode: number;
  16628. /**
  16629. * Returns the triangle fan draw mode
  16630. */
  16631. static readonly TriangleFanDrawMode: number;
  16632. /**
  16633. * Stores the clock-wise side orientation
  16634. */
  16635. private static _ClockWiseSideOrientation;
  16636. /**
  16637. * Stores the counter clock-wise side orientation
  16638. */
  16639. private static _CounterClockWiseSideOrientation;
  16640. /**
  16641. * Returns the clock-wise side orientation
  16642. */
  16643. static readonly ClockWiseSideOrientation: number;
  16644. /**
  16645. * Returns the counter clock-wise side orientation
  16646. */
  16647. static readonly CounterClockWiseSideOrientation: number;
  16648. /**
  16649. * The dirty texture flag value
  16650. */
  16651. private static _TextureDirtyFlag;
  16652. /**
  16653. * The dirty light flag value
  16654. */
  16655. private static _LightDirtyFlag;
  16656. /**
  16657. * The dirty fresnel flag value
  16658. */
  16659. private static _FresnelDirtyFlag;
  16660. /**
  16661. * The dirty attribute flag value
  16662. */
  16663. private static _AttributesDirtyFlag;
  16664. /**
  16665. * The dirty misc flag value
  16666. */
  16667. private static _MiscDirtyFlag;
  16668. /**
  16669. * Returns the dirty texture flag value
  16670. */
  16671. static readonly TextureDirtyFlag: number;
  16672. /**
  16673. * Returns the dirty light flag value
  16674. */
  16675. static readonly LightDirtyFlag: number;
  16676. /**
  16677. * Returns the dirty fresnel flag value
  16678. */
  16679. static readonly FresnelDirtyFlag: number;
  16680. /**
  16681. * Returns the dirty attributes flag value
  16682. */
  16683. static readonly AttributesDirtyFlag: number;
  16684. /**
  16685. * Returns the dirty misc flag value
  16686. */
  16687. static readonly MiscDirtyFlag: number;
  16688. /**
  16689. * The ID of the material
  16690. */
  16691. id: string;
  16692. /**
  16693. * Gets or sets the unique id of the material
  16694. */
  16695. uniqueId: number;
  16696. /**
  16697. * The name of the material
  16698. */
  16699. name: string;
  16700. /**
  16701. * Specifies if the ready state should be checked on each call
  16702. */
  16703. checkReadyOnEveryCall: boolean;
  16704. /**
  16705. * Specifies if the ready state should be checked once
  16706. */
  16707. checkReadyOnlyOnce: boolean;
  16708. /**
  16709. * The state of the material
  16710. */
  16711. state: string;
  16712. /**
  16713. * The alpha value of the material
  16714. */
  16715. protected _alpha: number;
  16716. /**
  16717. * Gets the alpha value of the material
  16718. */
  16719. /**
  16720. * Sets the alpha value of the material
  16721. */
  16722. alpha: number;
  16723. /**
  16724. * Specifies if back face culling is enabled
  16725. */
  16726. protected _backFaceCulling: boolean;
  16727. /**
  16728. * Gets the back-face culling state
  16729. */
  16730. /**
  16731. * Sets the back-face culling state
  16732. */
  16733. backFaceCulling: boolean;
  16734. /**
  16735. * Stores the value for side orientation
  16736. */
  16737. sideOrientation: number;
  16738. /**
  16739. * Callback triggered when the material is compiled
  16740. */
  16741. onCompiled: (effect: Effect) => void;
  16742. /**
  16743. * Callback triggered when an error occurs
  16744. */
  16745. onError: (effect: Effect, errors: string) => void;
  16746. /**
  16747. * Callback triggered to get the render target textures
  16748. */
  16749. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16750. /**
  16751. * Specifies if the material should be serialized
  16752. */
  16753. doNotSerialize: boolean;
  16754. /**
  16755. * Specifies if the effect should be stored on sub meshes
  16756. */
  16757. storeEffectOnSubMeshes: boolean;
  16758. /**
  16759. * Stores the animations for the material
  16760. */
  16761. animations: Array<Animation>;
  16762. /**
  16763. * An event triggered when the material is disposed
  16764. */
  16765. onDisposeObservable: Observable<Material>;
  16766. /**
  16767. * An observer which watches for dispose events
  16768. */
  16769. private _onDisposeObserver;
  16770. /**
  16771. * Called during a dispose event
  16772. */
  16773. onDispose: () => void;
  16774. /**
  16775. * An event triggered when the material is bound
  16776. */
  16777. onBindObservable: Observable<AbstractMesh>;
  16778. /**
  16779. * An observer which watches for bind events
  16780. */
  16781. private _onBindObserver;
  16782. /**
  16783. * Called during a bind event
  16784. */
  16785. onBind: (Mesh: AbstractMesh) => void;
  16786. /**
  16787. * An event triggered when the material is unbound
  16788. */
  16789. onUnBindObservable: Observable<Material>;
  16790. /**
  16791. * Stores the value of the alpha mode
  16792. */
  16793. private _alphaMode;
  16794. /**
  16795. * Gets the value of the alpha mode
  16796. */
  16797. /**
  16798. * Sets the value of the alpha mode.
  16799. *
  16800. * | Value | Type | Description |
  16801. * | --- | --- | --- |
  16802. * | 0 | ALPHA_DISABLE | |
  16803. * | 1 | ALPHA_ADD | |
  16804. * | 2 | ALPHA_COMBINE | |
  16805. * | 3 | ALPHA_SUBTRACT | |
  16806. * | 4 | ALPHA_MULTIPLY | |
  16807. * | 5 | ALPHA_MAXIMIZED | |
  16808. * | 6 | ALPHA_ONEONE | |
  16809. * | 7 | ALPHA_PREMULTIPLIED | |
  16810. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  16811. * | 9 | ALPHA_INTERPOLATE | |
  16812. * | 10 | ALPHA_SCREENMODE | |
  16813. *
  16814. */
  16815. alphaMode: number;
  16816. /**
  16817. * Stores the state of the need depth pre-pass value
  16818. */
  16819. private _needDepthPrePass;
  16820. /**
  16821. * Gets the depth pre-pass value
  16822. */
  16823. /**
  16824. * Sets the need depth pre-pass value
  16825. */
  16826. needDepthPrePass: boolean;
  16827. /**
  16828. * Specifies if depth writing should be disabled
  16829. */
  16830. disableDepthWrite: boolean;
  16831. /**
  16832. * Specifies if depth writing should be forced
  16833. */
  16834. forceDepthWrite: boolean;
  16835. /**
  16836. * Specifies if there should be a separate pass for culling
  16837. */
  16838. separateCullingPass: boolean;
  16839. /**
  16840. * Stores the state specifing if fog should be enabled
  16841. */
  16842. private _fogEnabled;
  16843. /**
  16844. * Gets the value of the fog enabled state
  16845. */
  16846. /**
  16847. * Sets the state for enabling fog
  16848. */
  16849. fogEnabled: boolean;
  16850. /**
  16851. * Stores the size of points
  16852. */
  16853. pointSize: number;
  16854. /**
  16855. * Stores the z offset value
  16856. */
  16857. zOffset: number;
  16858. /**
  16859. * Gets a value specifying if wireframe mode is enabled
  16860. */
  16861. /**
  16862. * Sets the state of wireframe mode
  16863. */
  16864. wireframe: boolean;
  16865. /**
  16866. * Gets the value specifying if point clouds are enabled
  16867. */
  16868. /**
  16869. * Sets the state of point cloud mode
  16870. */
  16871. pointsCloud: boolean;
  16872. /**
  16873. * Gets the material fill mode
  16874. */
  16875. /**
  16876. * Sets the material fill mode
  16877. */
  16878. fillMode: number;
  16879. /**
  16880. * Stores the effects for the material
  16881. */
  16882. /**
  16883. * Specifies if the material was previously ready
  16884. */
  16885. /**
  16886. * Specifies if uniform buffers should be used
  16887. */
  16888. private _useUBO;
  16889. /**
  16890. * Stores a reference to the scene
  16891. */
  16892. private _scene;
  16893. /**
  16894. * Stores the fill mode state
  16895. */
  16896. private _fillMode;
  16897. /**
  16898. * Specifies if the depth write state should be cached
  16899. */
  16900. private _cachedDepthWriteState;
  16901. /**
  16902. * Stores the uniform buffer
  16903. */
  16904. protected _uniformBuffer: UniformBuffer;
  16905. /**
  16906. * Creates a material instance
  16907. * @param name defines the name of the material
  16908. * @param scene defines the scene to reference
  16909. * @param doNotAdd specifies if the material should be added to the scene
  16910. */
  16911. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  16912. /**
  16913. * Returns a string representation of the current material
  16914. * @param fullDetails defines a boolean indicating which levels of logging is desired
  16915. * @returns a string with material information
  16916. */
  16917. toString(fullDetails?: boolean): string;
  16918. /**
  16919. * Gets the class name of the material
  16920. * @returns a string with the class name of the material
  16921. */
  16922. getClassName(): string;
  16923. /**
  16924. * Specifies if updates for the material been locked
  16925. */
  16926. readonly isFrozen: boolean;
  16927. /**
  16928. * Locks updates for the material
  16929. */
  16930. freeze(): void;
  16931. /**
  16932. * Unlocks updates for the material
  16933. */
  16934. unfreeze(): void;
  16935. /**
  16936. * Specifies if the material is ready to be used
  16937. * @param mesh defines the mesh to check
  16938. * @param useInstances specifies if instances should be used
  16939. * @returns a boolean indicating if the material is ready to be used
  16940. */
  16941. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16942. /**
  16943. * Specifies that the submesh is ready to be used
  16944. * @param mesh defines the mesh to check
  16945. * @param subMesh defines which submesh to check
  16946. * @param useInstances specifies that instances should be used
  16947. * @returns a boolean indicating that the submesh is ready or not
  16948. */
  16949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16950. /**
  16951. * Returns the material effect
  16952. * @returns the effect associated with the material
  16953. */
  16954. getEffect(): Nullable<Effect>;
  16955. /**
  16956. * Returns the current scene
  16957. * @returns a Scene
  16958. */
  16959. getScene(): Scene;
  16960. /**
  16961. * Specifies if the material will require alpha blending
  16962. * @returns a boolean specifying if alpha blending is needed
  16963. */
  16964. needAlphaBlending(): boolean;
  16965. /**
  16966. * Specifies if the mesh will require alpha blending
  16967. * @param mesh defines the mesh to check
  16968. * @returns a boolean specifying if alpha blending is needed for the mesh
  16969. */
  16970. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  16971. /**
  16972. * Specifies if this material should be rendered in alpha test mode
  16973. * @returns a boolean specifying if an alpha test is needed.
  16974. */
  16975. needAlphaTesting(): boolean;
  16976. /**
  16977. * Gets the texture used for the alpha test
  16978. * @returns the texture to use for alpha testing
  16979. */
  16980. getAlphaTestTexture(): Nullable<BaseTexture>;
  16981. /**
  16982. * Marks the material to indicate that it needs to be re-calculated
  16983. */
  16984. markDirty(): void;
  16985. /** @hidden */
  16986. /**
  16987. * Binds the material to the mesh
  16988. * @param world defines the world transformation matrix
  16989. * @param mesh defines the mesh to bind the material to
  16990. */
  16991. bind(world: Matrix, mesh?: Mesh): void;
  16992. /**
  16993. * Binds the submesh to the material
  16994. * @param world defines the world transformation matrix
  16995. * @param mesh defines the mesh containing the submesh
  16996. * @param subMesh defines the submesh to bind the material to
  16997. */
  16998. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16999. /**
  17000. * Binds the world matrix to the material
  17001. * @param world defines the world transformation matrix
  17002. */
  17003. bindOnlyWorldMatrix(world: Matrix): void;
  17004. /**
  17005. * Binds the scene's uniform buffer to the effect.
  17006. * @param effect defines the effect to bind to the scene uniform buffer
  17007. * @param sceneUbo defines the uniform buffer storing scene data
  17008. */
  17009. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17010. /**
  17011. * Binds the view matrix to the effect
  17012. * @param effect defines the effect to bind the view matrix to
  17013. */
  17014. bindView(effect: Effect): void;
  17015. /**
  17016. * Binds the view projection matrix to the effect
  17017. * @param effect defines the effect to bind the view projection matrix to
  17018. */
  17019. bindViewProjection(effect: Effect): void;
  17020. /**
  17021. * Specifies if material alpha testing should be turned on for the mesh
  17022. * @param mesh defines the mesh to check
  17023. */
  17024. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17025. /**
  17026. * Processes to execute after binding the material to a mesh
  17027. * @param mesh defines the rendered mesh
  17028. */
  17029. protected _afterBind(mesh?: Mesh): void;
  17030. /**
  17031. * Unbinds the material from the mesh
  17032. */
  17033. unbind(): void;
  17034. /**
  17035. * Gets the active textures from the material
  17036. * @returns an array of textures
  17037. */
  17038. getActiveTextures(): BaseTexture[];
  17039. /**
  17040. * Specifies if the material uses a texture
  17041. * @param texture defines the texture to check against the material
  17042. * @returns a boolean specifying if the material uses the texture
  17043. */
  17044. hasTexture(texture: BaseTexture): boolean;
  17045. /**
  17046. * Makes a duplicate of the material, and gives it a new name
  17047. * @param name defines the new name for the duplicated material
  17048. * @returns the cloned material
  17049. */
  17050. clone(name: string): Nullable<Material>;
  17051. /**
  17052. * Gets the meshes bound to the material
  17053. * @returns an array of meshes bound to the material
  17054. */
  17055. getBindedMeshes(): AbstractMesh[];
  17056. /**
  17057. * Force shader compilation
  17058. * @param mesh defines the mesh associated with this material
  17059. * @param onCompiled defines a function to execute once the material is compiled
  17060. * @param options defines the options to configure the compilation
  17061. */
  17062. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17063. clipPlane: boolean;
  17064. }>): void;
  17065. /**
  17066. * Force shader compilation
  17067. * @param mesh defines the mesh that will use this material
  17068. * @param options defines additional options for compiling the shaders
  17069. * @returns a promise that resolves when the compilation completes
  17070. */
  17071. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17072. clipPlane: boolean;
  17073. }>): Promise<void>;
  17074. /**
  17075. * Marks a define in the material to indicate that it needs to be re-computed
  17076. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17077. */
  17078. markAsDirty(flag: number): void;
  17079. /**
  17080. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17081. * @param func defines a function which checks material defines against the submeshes
  17082. */
  17083. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17084. /**
  17085. * Indicates that image processing needs to be re-calculated for all submeshes
  17086. */
  17087. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17088. /**
  17089. * Indicates that textures need to be re-calculated for all submeshes
  17090. */
  17091. protected _markAllSubMeshesAsTexturesDirty(): void;
  17092. /**
  17093. * Indicates that fresnel needs to be re-calculated for all submeshes
  17094. */
  17095. protected _markAllSubMeshesAsFresnelDirty(): void;
  17096. /**
  17097. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17098. */
  17099. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17100. /**
  17101. * Indicates that lights need to be re-calculated for all submeshes
  17102. */
  17103. protected _markAllSubMeshesAsLightsDirty(): void;
  17104. /**
  17105. * Indicates that attributes need to be re-calculated for all submeshes
  17106. */
  17107. protected _markAllSubMeshesAsAttributesDirty(): void;
  17108. /**
  17109. * Indicates that misc needs to be re-calculated for all submeshes
  17110. */
  17111. protected _markAllSubMeshesAsMiscDirty(): void;
  17112. /**
  17113. * Indicates that textures and misc need to be re-calculated for all submeshes
  17114. */
  17115. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17116. /**
  17117. * Disposes the material
  17118. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17119. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17120. */
  17121. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17122. /**
  17123. * Serializes this material
  17124. * @returns the serialized material object
  17125. */
  17126. serialize(): any;
  17127. /**
  17128. * Creates a MultiMaterial from parsed MultiMaterial data.
  17129. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17130. * @param scene defines the hosting scene
  17131. * @returns a new MultiMaterial
  17132. */
  17133. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17134. /**
  17135. * Creates a material from parsed material data
  17136. * @param parsedMaterial defines parsed material data
  17137. * @param scene defines the hosting scene
  17138. * @param rootUrl defines the root URL to use to load textures
  17139. * @returns a new material
  17140. */
  17141. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17142. }
  17143. }
  17144. declare module BABYLON {
  17145. /**
  17146. * "Static Class" containing the most commonly used helper while dealing with material for
  17147. * rendering purpose.
  17148. *
  17149. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17150. *
  17151. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17152. */
  17153. class MaterialHelper {
  17154. /**
  17155. * Bind the current view position to an effect.
  17156. * @param effect The effect to be bound
  17157. * @param scene The scene the eyes position is used from
  17158. */
  17159. static BindEyePosition(effect: Effect, scene: Scene): void;
  17160. /**
  17161. * Helps preparing the defines values about the UVs in used in the effect.
  17162. * UVs are shared as much as we can accross chanels in the shaders.
  17163. * @param texture The texture we are preparing the UVs for
  17164. * @param defines The defines to update
  17165. * @param key The chanel key "diffuse", "specular"... used in the shader
  17166. */
  17167. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17168. /**
  17169. * Binds a texture matrix value to its corrsponding uniform
  17170. * @param texture The texture to bind the matrix for
  17171. * @param uniformBuffer The uniform buffer receivin the data
  17172. * @param key The chanel key "diffuse", "specular"... used in the shader
  17173. */
  17174. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17175. /**
  17176. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17177. * @param mesh defines the current mesh
  17178. * @param scene defines the current scene
  17179. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17180. * @param pointsCloud defines if point cloud rendering has to be turned on
  17181. * @param fogEnabled defines if fog has to be turned on
  17182. * @param alphaTest defines if alpha testing has to be turned on
  17183. * @param defines defines the current list of defines
  17184. */
  17185. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17186. /**
  17187. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17188. * @param scene defines the current scene
  17189. * @param engine defines the current engine
  17190. * @param defines specifies the list of active defines
  17191. * @param useInstances defines if instances have to be turned on
  17192. * @param useClipPlane defines if clip plane have to be turned on
  17193. */
  17194. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17195. /**
  17196. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17197. * @param mesh The mesh containing the geometry data we will draw
  17198. * @param defines The defines to update
  17199. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17200. * @param useBones Precise whether bones should be used or not (override mesh info)
  17201. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17202. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17203. * @returns false if defines are considered not dirty and have not been checked
  17204. */
  17205. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17206. /**
  17207. * Prepares the defines related to the light information passed in parameter
  17208. * @param scene The scene we are intending to draw
  17209. * @param mesh The mesh the effect is compiling for
  17210. * @param defines The defines to update
  17211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17212. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17213. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17214. * @returns true if normals will be required for the rest of the effect
  17215. */
  17216. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17217. /**
  17218. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17219. * that won t be acctive due to defines being turned off.
  17220. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17221. * @param samplersList The samplers list
  17222. * @param defines The defines helping in the list generation
  17223. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17224. */
  17225. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17226. /**
  17227. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17228. * @param defines The defines to update while falling back
  17229. * @param fallbacks The authorized effect fallbacks
  17230. * @param maxSimultaneousLights The maximum number of lights allowed
  17231. * @param rank the current rank of the Effect
  17232. * @returns The newly affected rank
  17233. */
  17234. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17235. /**
  17236. * Prepares the list of attributes required for morph targets according to the effect defines.
  17237. * @param attribs The current list of supported attribs
  17238. * @param mesh The mesh to prepare the morph targets attributes for
  17239. * @param defines The current Defines of the effect
  17240. */
  17241. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17242. /**
  17243. * Prepares the list of attributes required for bones according to the effect defines.
  17244. * @param attribs The current list of supported attribs
  17245. * @param mesh The mesh to prepare the bones attributes for
  17246. * @param defines The current Defines of the effect
  17247. * @param fallbacks The current efffect fallback strategy
  17248. */
  17249. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17250. /**
  17251. * Prepares the list of attributes required for instances according to the effect defines.
  17252. * @param attribs The current list of supported attribs
  17253. * @param defines The current Defines of the effect
  17254. */
  17255. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17256. /**
  17257. * Binds the light shadow information to the effect for the given mesh.
  17258. * @param light The light containing the generator
  17259. * @param scene The scene the lights belongs to
  17260. * @param mesh The mesh we are binding the information to render
  17261. * @param lightIndex The light index in the effect used to render the mesh
  17262. * @param effect The effect we are binding the data to
  17263. */
  17264. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17265. /**
  17266. * Binds the light information to the effect.
  17267. * @param light The light containing the generator
  17268. * @param effect The effect we are binding the data to
  17269. * @param lightIndex The light index in the effect used to render
  17270. */
  17271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17272. /**
  17273. * Binds the lights information from the scene to the effect for the given mesh.
  17274. * @param scene The scene the lights belongs to
  17275. * @param mesh The mesh we are binding the information to render
  17276. * @param effect The effect we are binding the data to
  17277. * @param defines The generated defines for the effect
  17278. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17279. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17280. */
  17281. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17282. /**
  17283. * Binds the fog information from the scene to the effect for the given mesh.
  17284. * @param scene The scene the lights belongs to
  17285. * @param mesh The mesh we are binding the information to render
  17286. * @param effect The effect we are binding the data to
  17287. */
  17288. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  17289. /**
  17290. * Binds the bones information from the mesh to the effect.
  17291. * @param mesh The mesh we are binding the information to render
  17292. * @param effect The effect we are binding the data to
  17293. */
  17294. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17295. /**
  17296. * Binds the morph targets information from the mesh to the effect.
  17297. * @param abstractMesh The mesh we are binding the information to render
  17298. * @param effect The effect we are binding the data to
  17299. */
  17300. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17301. /**
  17302. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17303. * @param defines The generated defines used in the effect
  17304. * @param effect The effect we are binding the data to
  17305. * @param scene The scene we are willing to render with logarithmic scale for
  17306. */
  17307. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17308. /**
  17309. * Binds the clip plane information from the scene to the effect.
  17310. * @param scene The scene the clip plane information are extracted from
  17311. * @param effect The effect we are binding the data to
  17312. */
  17313. static BindClipPlane(effect: Effect, scene: Scene): void;
  17314. }
  17315. }
  17316. declare module BABYLON {
  17317. class MultiMaterial extends Material {
  17318. private _subMaterials;
  17319. subMaterials: Nullable<Material>[];
  17320. constructor(name: string, scene: Scene);
  17321. private _hookArray(array);
  17322. getSubMaterial(index: number): Nullable<Material>;
  17323. getActiveTextures(): BaseTexture[];
  17324. getClassName(): string;
  17325. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17326. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17327. serialize(): any;
  17328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17329. }
  17330. }
  17331. declare module BABYLON {
  17332. class PushMaterial extends Material {
  17333. protected _activeEffect: Effect;
  17334. protected _normalMatrix: Matrix;
  17335. constructor(name: string, scene: Scene);
  17336. getEffect(): Effect;
  17337. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17338. /**
  17339. * Binds the given world matrix to the active effect
  17340. *
  17341. * @param world the matrix to bind
  17342. */
  17343. bindOnlyWorldMatrix(world: Matrix): void;
  17344. /**
  17345. * Binds the given normal matrix to the active effect
  17346. *
  17347. * @param normalMatrix the matrix to bind
  17348. */
  17349. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17350. bind(world: Matrix, mesh?: Mesh): void;
  17351. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17352. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17353. }
  17354. }
  17355. declare module BABYLON {
  17356. class ShaderMaterial extends Material {
  17357. private _shaderPath;
  17358. private _options;
  17359. private _textures;
  17360. private _textureArrays;
  17361. private _floats;
  17362. private _ints;
  17363. private _floatsArrays;
  17364. private _colors3;
  17365. private _colors3Arrays;
  17366. private _colors4;
  17367. private _vectors2;
  17368. private _vectors3;
  17369. private _vectors4;
  17370. private _matrices;
  17371. private _matrices3x3;
  17372. private _matrices2x2;
  17373. private _vectors2Arrays;
  17374. private _vectors3Arrays;
  17375. private _cachedWorldViewMatrix;
  17376. private _renderId;
  17377. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17378. getClassName(): string;
  17379. needAlphaBlending(): boolean;
  17380. needAlphaTesting(): boolean;
  17381. private _checkUniform(uniformName);
  17382. setTexture(name: string, texture: Texture): ShaderMaterial;
  17383. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17384. setFloat(name: string, value: number): ShaderMaterial;
  17385. setInt(name: string, value: number): ShaderMaterial;
  17386. setFloats(name: string, value: number[]): ShaderMaterial;
  17387. setColor3(name: string, value: Color3): ShaderMaterial;
  17388. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17389. setColor4(name: string, value: Color4): ShaderMaterial;
  17390. setVector2(name: string, value: Vector2): ShaderMaterial;
  17391. setVector3(name: string, value: Vector3): ShaderMaterial;
  17392. setVector4(name: string, value: Vector4): ShaderMaterial;
  17393. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17394. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17395. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17396. setArray2(name: string, value: number[]): ShaderMaterial;
  17397. setArray3(name: string, value: number[]): ShaderMaterial;
  17398. private _checkCache(scene, mesh?, useInstances?);
  17399. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17400. bindOnlyWorldMatrix(world: Matrix): void;
  17401. bind(world: Matrix, mesh?: Mesh): void;
  17402. getActiveTextures(): BaseTexture[];
  17403. hasTexture(texture: BaseTexture): boolean;
  17404. clone(name: string): ShaderMaterial;
  17405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17406. serialize(): any;
  17407. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17408. }
  17409. }
  17410. declare module BABYLON {
  17411. /** @hidden */
  17412. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17413. MAINUV1: boolean;
  17414. MAINUV2: boolean;
  17415. DIFFUSE: boolean;
  17416. DIFFUSEDIRECTUV: number;
  17417. AMBIENT: boolean;
  17418. AMBIENTDIRECTUV: number;
  17419. OPACITY: boolean;
  17420. OPACITYDIRECTUV: number;
  17421. OPACITYRGB: boolean;
  17422. REFLECTION: boolean;
  17423. EMISSIVE: boolean;
  17424. EMISSIVEDIRECTUV: number;
  17425. SPECULAR: boolean;
  17426. SPECULARDIRECTUV: number;
  17427. BUMP: boolean;
  17428. BUMPDIRECTUV: number;
  17429. PARALLAX: boolean;
  17430. PARALLAXOCCLUSION: boolean;
  17431. SPECULAROVERALPHA: boolean;
  17432. CLIPPLANE: boolean;
  17433. ALPHATEST: boolean;
  17434. DEPTHPREPASS: boolean;
  17435. ALPHAFROMDIFFUSE: boolean;
  17436. POINTSIZE: boolean;
  17437. FOG: boolean;
  17438. SPECULARTERM: boolean;
  17439. DIFFUSEFRESNEL: boolean;
  17440. OPACITYFRESNEL: boolean;
  17441. REFLECTIONFRESNEL: boolean;
  17442. REFRACTIONFRESNEL: boolean;
  17443. EMISSIVEFRESNEL: boolean;
  17444. FRESNEL: boolean;
  17445. NORMAL: boolean;
  17446. UV1: boolean;
  17447. UV2: boolean;
  17448. VERTEXCOLOR: boolean;
  17449. VERTEXALPHA: boolean;
  17450. NUM_BONE_INFLUENCERS: number;
  17451. BonesPerMesh: number;
  17452. INSTANCES: boolean;
  17453. GLOSSINESS: boolean;
  17454. ROUGHNESS: boolean;
  17455. EMISSIVEASILLUMINATION: boolean;
  17456. LINKEMISSIVEWITHDIFFUSE: boolean;
  17457. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17458. LIGHTMAP: boolean;
  17459. LIGHTMAPDIRECTUV: number;
  17460. OBJECTSPACE_NORMALMAP: boolean;
  17461. USELIGHTMAPASSHADOWMAP: boolean;
  17462. REFLECTIONMAP_3D: boolean;
  17463. REFLECTIONMAP_SPHERICAL: boolean;
  17464. REFLECTIONMAP_PLANAR: boolean;
  17465. REFLECTIONMAP_CUBIC: boolean;
  17466. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17467. REFLECTIONMAP_PROJECTION: boolean;
  17468. REFLECTIONMAP_SKYBOX: boolean;
  17469. REFLECTIONMAP_EXPLICIT: boolean;
  17470. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17471. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17472. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17473. INVERTCUBICMAP: boolean;
  17474. LOGARITHMICDEPTH: boolean;
  17475. REFRACTION: boolean;
  17476. REFRACTIONMAP_3D: boolean;
  17477. REFLECTIONOVERALPHA: boolean;
  17478. TWOSIDEDLIGHTING: boolean;
  17479. SHADOWFLOAT: boolean;
  17480. MORPHTARGETS: boolean;
  17481. MORPHTARGETS_NORMAL: boolean;
  17482. MORPHTARGETS_TANGENT: boolean;
  17483. NUM_MORPH_INFLUENCERS: number;
  17484. NONUNIFORMSCALING: boolean;
  17485. PREMULTIPLYALPHA: boolean;
  17486. IMAGEPROCESSING: boolean;
  17487. VIGNETTE: boolean;
  17488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17489. VIGNETTEBLENDMODEOPAQUE: boolean;
  17490. TONEMAPPING: boolean;
  17491. CONTRAST: boolean;
  17492. COLORCURVES: boolean;
  17493. COLORGRADING: boolean;
  17494. COLORGRADING3D: boolean;
  17495. SAMPLER3DGREENDEPTH: boolean;
  17496. SAMPLER3DBGRMAP: boolean;
  17497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17498. /**
  17499. * If the reflection texture on this material is in linear color space
  17500. * @hidden
  17501. */
  17502. IS_REFLECTION_LINEAR: boolean;
  17503. /**
  17504. * If the refraction texture on this material is in linear color space
  17505. * @hidden
  17506. */
  17507. IS_REFRACTION_LINEAR: boolean;
  17508. EXPOSURE: boolean;
  17509. constructor();
  17510. setReflectionMode(modeToEnable: string): void;
  17511. }
  17512. class StandardMaterial extends PushMaterial {
  17513. private _diffuseTexture;
  17514. diffuseTexture: Nullable<BaseTexture>;
  17515. private _ambientTexture;
  17516. ambientTexture: Nullable<BaseTexture>;
  17517. private _opacityTexture;
  17518. opacityTexture: Nullable<BaseTexture>;
  17519. private _reflectionTexture;
  17520. reflectionTexture: Nullable<BaseTexture>;
  17521. private _emissiveTexture;
  17522. emissiveTexture: Nullable<BaseTexture>;
  17523. private _specularTexture;
  17524. specularTexture: Nullable<BaseTexture>;
  17525. private _bumpTexture;
  17526. bumpTexture: Nullable<BaseTexture>;
  17527. private _lightmapTexture;
  17528. lightmapTexture: Nullable<BaseTexture>;
  17529. private _refractionTexture;
  17530. refractionTexture: Nullable<BaseTexture>;
  17531. ambientColor: Color3;
  17532. diffuseColor: Color3;
  17533. specularColor: Color3;
  17534. emissiveColor: Color3;
  17535. specularPower: number;
  17536. private _useAlphaFromDiffuseTexture;
  17537. useAlphaFromDiffuseTexture: boolean;
  17538. private _useEmissiveAsIllumination;
  17539. useEmissiveAsIllumination: boolean;
  17540. private _linkEmissiveWithDiffuse;
  17541. linkEmissiveWithDiffuse: boolean;
  17542. private _useSpecularOverAlpha;
  17543. useSpecularOverAlpha: boolean;
  17544. private _useReflectionOverAlpha;
  17545. useReflectionOverAlpha: boolean;
  17546. private _disableLighting;
  17547. disableLighting: boolean;
  17548. private _useObjectSpaceNormalMap;
  17549. /**
  17550. * Allows using an object space normal map (instead of tangent space).
  17551. */
  17552. useObjectSpaceNormalMap: boolean;
  17553. private _useParallax;
  17554. useParallax: boolean;
  17555. private _useParallaxOcclusion;
  17556. useParallaxOcclusion: boolean;
  17557. parallaxScaleBias: number;
  17558. private _roughness;
  17559. roughness: number;
  17560. indexOfRefraction: number;
  17561. invertRefractionY: boolean;
  17562. /**
  17563. * Defines the alpha limits in alpha test mode
  17564. */
  17565. alphaCutOff: number;
  17566. private _useLightmapAsShadowmap;
  17567. useLightmapAsShadowmap: boolean;
  17568. private _diffuseFresnelParameters;
  17569. diffuseFresnelParameters: FresnelParameters;
  17570. private _opacityFresnelParameters;
  17571. opacityFresnelParameters: FresnelParameters;
  17572. private _reflectionFresnelParameters;
  17573. reflectionFresnelParameters: FresnelParameters;
  17574. private _refractionFresnelParameters;
  17575. refractionFresnelParameters: FresnelParameters;
  17576. private _emissiveFresnelParameters;
  17577. emissiveFresnelParameters: FresnelParameters;
  17578. private _useReflectionFresnelFromSpecular;
  17579. useReflectionFresnelFromSpecular: boolean;
  17580. private _useGlossinessFromSpecularMapAlpha;
  17581. useGlossinessFromSpecularMapAlpha: boolean;
  17582. private _maxSimultaneousLights;
  17583. maxSimultaneousLights: number;
  17584. /**
  17585. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17586. */
  17587. private _invertNormalMapX;
  17588. invertNormalMapX: boolean;
  17589. /**
  17590. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17591. */
  17592. private _invertNormalMapY;
  17593. invertNormalMapY: boolean;
  17594. /**
  17595. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17596. */
  17597. private _twoSidedLighting;
  17598. twoSidedLighting: boolean;
  17599. /**
  17600. * Default configuration related to image processing available in the standard Material.
  17601. */
  17602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17603. /**
  17604. * Gets the image processing configuration used either in this material.
  17605. */
  17606. /**
  17607. * Sets the Default image processing configuration used either in the this material.
  17608. *
  17609. * If sets to null, the scene one is in use.
  17610. */
  17611. imageProcessingConfiguration: ImageProcessingConfiguration;
  17612. /**
  17613. * Keep track of the image processing observer to allow dispose and replace.
  17614. */
  17615. private _imageProcessingObserver;
  17616. /**
  17617. * Attaches a new image processing configuration to the Standard Material.
  17618. * @param configuration
  17619. */
  17620. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17621. /**
  17622. * Gets wether the color curves effect is enabled.
  17623. */
  17624. /**
  17625. * Sets wether the color curves effect is enabled.
  17626. */
  17627. cameraColorCurvesEnabled: boolean;
  17628. /**
  17629. * Gets wether the color grading effect is enabled.
  17630. */
  17631. /**
  17632. * Gets wether the color grading effect is enabled.
  17633. */
  17634. cameraColorGradingEnabled: boolean;
  17635. /**
  17636. * Gets wether tonemapping is enabled or not.
  17637. */
  17638. /**
  17639. * Sets wether tonemapping is enabled or not
  17640. */
  17641. cameraToneMappingEnabled: boolean;
  17642. /**
  17643. * The camera exposure used on this material.
  17644. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17645. * This corresponds to a photographic exposure.
  17646. */
  17647. /**
  17648. * The camera exposure used on this material.
  17649. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17650. * This corresponds to a photographic exposure.
  17651. */
  17652. cameraExposure: number;
  17653. /**
  17654. * Gets The camera contrast used on this material.
  17655. */
  17656. /**
  17657. * Sets The camera contrast used on this material.
  17658. */
  17659. cameraContrast: number;
  17660. /**
  17661. * Gets the Color Grading 2D Lookup Texture.
  17662. */
  17663. /**
  17664. * Sets the Color Grading 2D Lookup Texture.
  17665. */
  17666. cameraColorGradingTexture: Nullable<BaseTexture>;
  17667. /**
  17668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17670. * 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;
  17671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17672. */
  17673. /**
  17674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17676. * 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;
  17677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17678. */
  17679. cameraColorCurves: Nullable<ColorCurves>;
  17680. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17681. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17682. protected _worldViewProjectionMatrix: Matrix;
  17683. protected _globalAmbientColor: Color3;
  17684. protected _useLogarithmicDepth: boolean;
  17685. constructor(name: string, scene: Scene);
  17686. getClassName(): string;
  17687. useLogarithmicDepth: boolean;
  17688. needAlphaBlending(): boolean;
  17689. needAlphaTesting(): boolean;
  17690. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17691. getAlphaTestTexture(): Nullable<BaseTexture>;
  17692. /**
  17693. * Child classes can use it to update shaders
  17694. */
  17695. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17696. buildUniformLayout(): void;
  17697. unbind(): void;
  17698. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17699. getAnimatables(): IAnimatable[];
  17700. getActiveTextures(): BaseTexture[];
  17701. hasTexture(texture: BaseTexture): boolean;
  17702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17703. clone(name: string): StandardMaterial;
  17704. serialize(): any;
  17705. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17706. private static _DiffuseTextureEnabled: boolean;
  17707. static DiffuseTextureEnabled: boolean;
  17708. private static _AmbientTextureEnabled: boolean;
  17709. static AmbientTextureEnabled: boolean;
  17710. private static _OpacityTextureEnabled: boolean;
  17711. static OpacityTextureEnabled: boolean;
  17712. private static _ReflectionTextureEnabled: boolean;
  17713. static ReflectionTextureEnabled: boolean;
  17714. private static _EmissiveTextureEnabled: boolean;
  17715. static EmissiveTextureEnabled: boolean;
  17716. private static _SpecularTextureEnabled: boolean;
  17717. static SpecularTextureEnabled: boolean;
  17718. private static _BumpTextureEnabled: boolean;
  17719. static BumpTextureEnabled: boolean;
  17720. private static _LightmapTextureEnabled: boolean;
  17721. static LightmapTextureEnabled: boolean;
  17722. private static _RefractionTextureEnabled: boolean;
  17723. static RefractionTextureEnabled: boolean;
  17724. private static _ColorGradingTextureEnabled: boolean;
  17725. static ColorGradingTextureEnabled: boolean;
  17726. private static _FresnelEnabled: boolean;
  17727. static FresnelEnabled: boolean;
  17728. }
  17729. }
  17730. declare module BABYLON {
  17731. class UniformBuffer {
  17732. private _engine;
  17733. private _buffer;
  17734. private _data;
  17735. private _bufferData;
  17736. private _dynamic?;
  17737. private _uniformLocations;
  17738. private _uniformSizes;
  17739. private _uniformLocationPointer;
  17740. private _needSync;
  17741. private _noUBO;
  17742. private _currentEffect;
  17743. private static _MAX_UNIFORM_SIZE;
  17744. private static _tempBuffer;
  17745. /**
  17746. * Wrapper for updateUniform.
  17747. * @method updateMatrix3x3
  17748. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17749. * @param {Float32Array} matrix
  17750. */
  17751. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17752. /**
  17753. * Wrapper for updateUniform.
  17754. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17755. * @param {Float32Array} matrix
  17756. */
  17757. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17758. /**
  17759. * Wrapper for updateUniform.
  17760. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17761. * @param {number} x
  17762. */
  17763. updateFloat: (name: string, x: number) => void;
  17764. /**
  17765. * Wrapper for updateUniform.
  17766. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17767. * @param {number} x
  17768. * @param {number} y
  17769. * @param {string} [suffix] Suffix to add to the uniform name.
  17770. */
  17771. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17772. /**
  17773. * Wrapper for updateUniform.
  17774. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17775. * @param {number} x
  17776. * @param {number} y
  17777. * @param {number} z
  17778. * @param {string} [suffix] Suffix to add to the uniform name.
  17779. */
  17780. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17781. /**
  17782. * Wrapper for updateUniform.
  17783. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17784. * @param {number} x
  17785. * @param {number} y
  17786. * @param {number} z
  17787. * @param {number} w
  17788. * @param {string} [suffix] Suffix to add to the uniform name.
  17789. */
  17790. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  17791. /**
  17792. * Wrapper for updateUniform.
  17793. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17794. * @param {Matrix} A 4x4 matrix.
  17795. */
  17796. updateMatrix: (name: string, mat: Matrix) => void;
  17797. /**
  17798. * Wrapper for updateUniform.
  17799. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17800. * @param {Vector3} vector
  17801. */
  17802. updateVector3: (name: string, vector: Vector3) => void;
  17803. /**
  17804. * Wrapper for updateUniform.
  17805. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17806. * @param {Vector4} vector
  17807. */
  17808. updateVector4: (name: string, vector: Vector4) => void;
  17809. /**
  17810. * Wrapper for updateUniform.
  17811. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17812. * @param {Color3} color
  17813. * @param {string} [suffix] Suffix to add to the uniform name.
  17814. */
  17815. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  17816. /**
  17817. * Wrapper for updateUniform.
  17818. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17819. * @param {Color3} color
  17820. * @param {number} alpha
  17821. * @param {string} [suffix] Suffix to add to the uniform name.
  17822. */
  17823. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  17824. /**
  17825. * Uniform buffer objects.
  17826. *
  17827. * Handles blocks of uniform on the GPU.
  17828. *
  17829. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  17830. *
  17831. * For more information, please refer to :
  17832. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  17833. */
  17834. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  17835. /**
  17836. * Indicates if the buffer is using the WebGL2 UBO implementation,
  17837. * or just falling back on setUniformXXX calls.
  17838. */
  17839. readonly useUbo: boolean;
  17840. /**
  17841. * Indicates if the WebGL underlying uniform buffer is in sync
  17842. * with the javascript cache data.
  17843. */
  17844. readonly isSync: boolean;
  17845. /**
  17846. * Indicates if the WebGL underlying uniform buffer is dynamic.
  17847. * Also, a dynamic UniformBuffer will disable cache verification and always
  17848. * update the underlying WebGL uniform buffer to the GPU.
  17849. */
  17850. isDynamic(): boolean;
  17851. /**
  17852. * The data cache on JS side.
  17853. */
  17854. getData(): Float32Array;
  17855. /**
  17856. * The underlying WebGL Uniform buffer.
  17857. */
  17858. getBuffer(): Nullable<WebGLBuffer>;
  17859. /**
  17860. * std140 layout specifies how to align data within an UBO structure.
  17861. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  17862. * for specs.
  17863. */
  17864. private _fillAlignment(size);
  17865. /**
  17866. * Adds an uniform in the buffer.
  17867. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  17868. * for the layout to be correct !
  17869. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17870. * @param {number|number[]} size Data size, or data directly.
  17871. */
  17872. addUniform(name: string, size: number | number[]): void;
  17873. /**
  17874. * Wrapper for addUniform.
  17875. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17876. * @param {Matrix} mat A 4x4 matrix.
  17877. */
  17878. addMatrix(name: string, mat: Matrix): void;
  17879. /**
  17880. * Wrapper for addUniform.
  17881. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17882. * @param {number} x
  17883. * @param {number} y
  17884. */
  17885. addFloat2(name: string, x: number, y: number): void;
  17886. /**
  17887. * Wrapper for addUniform.
  17888. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17889. * @param {number} x
  17890. * @param {number} y
  17891. * @param {number} z
  17892. */
  17893. addFloat3(name: string, x: number, y: number, z: number): void;
  17894. /**
  17895. * Wrapper for addUniform.
  17896. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17897. * @param {Color3} color
  17898. */
  17899. addColor3(name: string, color: Color3): void;
  17900. /**
  17901. * Wrapper for addUniform.
  17902. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17903. * @param {Color3} color
  17904. * @param {number} alpha
  17905. */
  17906. addColor4(name: string, color: Color3, alpha: number): void;
  17907. /**
  17908. * Wrapper for addUniform.
  17909. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17910. * @param {Vector3} vector
  17911. */
  17912. addVector3(name: string, vector: Vector3): void;
  17913. /**
  17914. * Wrapper for addUniform.
  17915. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17916. */
  17917. addMatrix3x3(name: string): void;
  17918. /**
  17919. * Wrapper for addUniform.
  17920. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17921. */
  17922. addMatrix2x2(name: string): void;
  17923. /**
  17924. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  17925. */
  17926. create(): void;
  17927. /**
  17928. * Updates the WebGL Uniform Buffer on the GPU.
  17929. * If the `dynamic` flag is set to true, no cache comparison is done.
  17930. * Otherwise, the buffer will be updated only if the cache differs.
  17931. */
  17932. update(): void;
  17933. /**
  17934. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  17935. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17936. * @param {number[]|Float32Array} data Flattened data
  17937. * @param {number} size Size of the data.
  17938. */
  17939. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  17940. private _updateMatrix3x3ForUniform(name, matrix);
  17941. private _updateMatrix3x3ForEffect(name, matrix);
  17942. private _updateMatrix2x2ForEffect(name, matrix);
  17943. private _updateMatrix2x2ForUniform(name, matrix);
  17944. private _updateFloatForEffect(name, x);
  17945. private _updateFloatForUniform(name, x);
  17946. private _updateFloat2ForEffect(name, x, y, suffix?);
  17947. private _updateFloat2ForUniform(name, x, y, suffix?);
  17948. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  17949. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  17950. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  17951. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  17952. private _updateMatrixForEffect(name, mat);
  17953. private _updateMatrixForUniform(name, mat);
  17954. private _updateVector3ForEffect(name, vector);
  17955. private _updateVector3ForUniform(name, vector);
  17956. private _updateVector4ForEffect(name, vector);
  17957. private _updateVector4ForUniform(name, vector);
  17958. private _updateColor3ForEffect(name, color, suffix?);
  17959. private _updateColor3ForUniform(name, color, suffix?);
  17960. private _updateColor4ForEffect(name, color, alpha, suffix?);
  17961. private _updateColor4ForUniform(name, color, alpha, suffix?);
  17962. /**
  17963. * Sets a sampler uniform on the effect.
  17964. * @param {string} name Name of the sampler.
  17965. * @param {Texture} texture
  17966. */
  17967. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  17968. /**
  17969. * Directly updates the value of the uniform in the cache AND on the GPU.
  17970. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17971. * @param {number[]|Float32Array} data Flattened data
  17972. */
  17973. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  17974. /**
  17975. * Binds this uniform buffer to an effect.
  17976. * @param {Effect} effect
  17977. * @param {string} name Name of the uniform block in the shader.
  17978. */
  17979. bindToEffect(effect: Effect, name: string): void;
  17980. /**
  17981. * Disposes the uniform buffer.
  17982. */
  17983. dispose(): void;
  17984. }
  17985. }
  17986. declare module BABYLON {
  17987. /**
  17988. * Defines a target to use with MorphTargetManager
  17989. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17990. */
  17991. class MorphTarget implements IAnimatable {
  17992. /** defines the name of the target */
  17993. name: string;
  17994. /**
  17995. * Gets or sets the list of animations
  17996. */
  17997. animations: Animation[];
  17998. private _scene;
  17999. private _positions;
  18000. private _normals;
  18001. private _tangents;
  18002. private _influence;
  18003. /**
  18004. * Observable raised when the influence changes
  18005. */
  18006. onInfluenceChanged: Observable<boolean>;
  18007. /**
  18008. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18009. */
  18010. influence: number;
  18011. private _animationPropertiesOverride;
  18012. /**
  18013. * Gets or sets the animation properties override
  18014. */
  18015. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18016. /**
  18017. * Creates a new MorphTarget
  18018. * @param name defines the name of the target
  18019. * @param influence defines the influence to use
  18020. */
  18021. constructor(
  18022. /** defines the name of the target */
  18023. name: string, influence?: number, scene?: Nullable<Scene>);
  18024. /**
  18025. * Gets a boolean defining if the target contains position data
  18026. */
  18027. readonly hasPositions: boolean;
  18028. /**
  18029. * Gets a boolean defining if the target contains normal data
  18030. */
  18031. readonly hasNormals: boolean;
  18032. /**
  18033. * Gets a boolean defining if the target contains tangent data
  18034. */
  18035. readonly hasTangents: boolean;
  18036. /**
  18037. * Affects position data to this target
  18038. * @param data defines the position data to use
  18039. */
  18040. setPositions(data: Nullable<FloatArray>): void;
  18041. /**
  18042. * Gets the position data stored in this target
  18043. * @returns a FloatArray containing the position data (or null if not present)
  18044. */
  18045. getPositions(): Nullable<FloatArray>;
  18046. /**
  18047. * Affects normal data to this target
  18048. * @param data defines the normal data to use
  18049. */
  18050. setNormals(data: Nullable<FloatArray>): void;
  18051. /**
  18052. * Gets the normal data stored in this target
  18053. * @returns a FloatArray containing the normal data (or null if not present)
  18054. */
  18055. getNormals(): Nullable<FloatArray>;
  18056. /**
  18057. * Affects tangent data to this target
  18058. * @param data defines the tangent data to use
  18059. */
  18060. setTangents(data: Nullable<FloatArray>): void;
  18061. /**
  18062. * Gets the tangent data stored in this target
  18063. * @returns a FloatArray containing the tangent data (or null if not present)
  18064. */
  18065. getTangents(): Nullable<FloatArray>;
  18066. /**
  18067. * Serializes the current target into a Serialization object
  18068. * @returns the serialized object
  18069. */
  18070. serialize(): any;
  18071. /**
  18072. * Creates a new target from serialized data
  18073. * @param serializationObject defines the serialized data to use
  18074. * @returns a new MorphTarget
  18075. */
  18076. static Parse(serializationObject: any): MorphTarget;
  18077. /**
  18078. * Creates a MorphTarget from mesh data
  18079. * @param mesh defines the source mesh
  18080. * @param name defines the name to use for the new target
  18081. * @param influence defines the influence to attach to the target
  18082. * @returns a new MorphTarget
  18083. */
  18084. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18085. }
  18086. }
  18087. declare module BABYLON {
  18088. /**
  18089. * This class is used to deform meshes using morphing between different targets
  18090. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18091. */
  18092. class MorphTargetManager {
  18093. private _targets;
  18094. private _targetObservable;
  18095. private _activeTargets;
  18096. private _scene;
  18097. private _influences;
  18098. private _supportsNormals;
  18099. private _supportsTangents;
  18100. private _vertexCount;
  18101. private _uniqueId;
  18102. private _tempInfluences;
  18103. /**
  18104. * Creates a new MorphTargetManager
  18105. * @param scene defines the current scene
  18106. */
  18107. constructor(scene?: Nullable<Scene>);
  18108. /**
  18109. * Gets the unique ID of this manager
  18110. */
  18111. readonly uniqueId: number;
  18112. /**
  18113. * Gets the number of vertices handled by this manager
  18114. */
  18115. readonly vertexCount: number;
  18116. /**
  18117. * Gets a boolean indicating if this manager supports morphing of normals
  18118. */
  18119. readonly supportsNormals: boolean;
  18120. /**
  18121. * Gets a boolean indicating if this manager supports morphing of tangents
  18122. */
  18123. readonly supportsTangents: boolean;
  18124. /**
  18125. * Gets the number of targets stored in this manager
  18126. */
  18127. readonly numTargets: number;
  18128. /**
  18129. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18130. */
  18131. readonly numInfluencers: number;
  18132. /**
  18133. * Gets the list of influences (one per target)
  18134. */
  18135. readonly influences: Float32Array;
  18136. /**
  18137. * Gets the active target at specified index. An active target is a target with an influence > 0
  18138. * @param index defines the index to check
  18139. * @returns the requested target
  18140. */
  18141. getActiveTarget(index: number): MorphTarget;
  18142. /**
  18143. * Gets the target at specified index
  18144. * @param index defines the index to check
  18145. * @returns the requested target
  18146. */
  18147. getTarget(index: number): MorphTarget;
  18148. /**
  18149. * Add a new target to this manager
  18150. * @param target defines the target to add
  18151. */
  18152. addTarget(target: MorphTarget): void;
  18153. /**
  18154. * Removes a target from the manager
  18155. * @param target defines the target to remove
  18156. */
  18157. removeTarget(target: MorphTarget): void;
  18158. /**
  18159. * Serializes the current manager into a Serialization object
  18160. * @returns the serialized object
  18161. */
  18162. serialize(): any;
  18163. private _syncActiveTargets(needUpdate);
  18164. /**
  18165. * Syncrhonize the targets with all the meshes using this morph target manager
  18166. */
  18167. synchronize(): void;
  18168. /**
  18169. * Creates a new MorphTargetManager from serialized data
  18170. * @param serializationObject defines the serialized data
  18171. * @param scene defines the hosting scene
  18172. * @returns the new MorphTargetManager
  18173. */
  18174. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18175. }
  18176. }
  18177. declare module BABYLON {
  18178. /**
  18179. * This represents a GPU particle system in Babylon
  18180. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  18181. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  18182. */
  18183. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  18184. /**
  18185. * The id of the Particle system.
  18186. */
  18187. id: string;
  18188. /**
  18189. * The friendly name of the Particle system.
  18190. */
  18191. name: string;
  18192. /**
  18193. * The emitter represents the Mesh or position we are attaching the particle system to.
  18194. */
  18195. emitter: Nullable<AbstractMesh | Vector3>;
  18196. /**
  18197. * The rendering group used by the Particle system to chose when to render.
  18198. */
  18199. renderingGroupId: number;
  18200. /**
  18201. * The layer mask we are rendering the particles through.
  18202. */
  18203. layerMask: number;
  18204. private _capacity;
  18205. private _activeCount;
  18206. private _currentActiveCount;
  18207. private _renderEffect;
  18208. private _updateEffect;
  18209. private _buffer0;
  18210. private _buffer1;
  18211. private _spriteBuffer;
  18212. private _updateVAO;
  18213. private _renderVAO;
  18214. private _targetIndex;
  18215. private _sourceBuffer;
  18216. private _targetBuffer;
  18217. private _scene;
  18218. private _engine;
  18219. private _currentRenderId;
  18220. private _started;
  18221. private _stopped;
  18222. private _timeDelta;
  18223. private _randomTexture;
  18224. private readonly _attributesStrideSize;
  18225. private _updateEffectOptions;
  18226. private _randomTextureSize;
  18227. private _actualFrame;
  18228. /**
  18229. * List of animations used by the particle system.
  18230. */
  18231. animations: Animation[];
  18232. /**
  18233. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  18234. */
  18235. static readonly IsSupported: boolean;
  18236. /**
  18237. * An event triggered when the system is disposed.
  18238. */
  18239. onDisposeObservable: Observable<GPUParticleSystem>;
  18240. /**
  18241. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18242. */
  18243. updateSpeed: number;
  18244. /**
  18245. * The amount of time the particle system is running (depends of the overall update speed).
  18246. */
  18247. targetStopDuration: number;
  18248. /**
  18249. * The texture used to render each particle. (this can be a spritesheet)
  18250. */
  18251. particleTexture: Nullable<Texture>;
  18252. /**
  18253. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18254. */
  18255. blendMode: number;
  18256. /**
  18257. * Minimum life time of emitting particles.
  18258. */
  18259. minLifeTime: number;
  18260. /**
  18261. * Maximum life time of emitting particles.
  18262. */
  18263. maxLifeTime: number;
  18264. /**
  18265. * Minimum Size of emitting particles.
  18266. */
  18267. minSize: number;
  18268. /**
  18269. * Maximum Size of emitting particles.
  18270. */
  18271. maxSize: number;
  18272. /**
  18273. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18274. */
  18275. color1: Color4;
  18276. /**
  18277. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18278. */
  18279. color2: Color4;
  18280. /**
  18281. * Color the particle will have at the end of its lifetime.
  18282. */
  18283. colorDead: Color4;
  18284. /**
  18285. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18286. */
  18287. emitRate: number;
  18288. /**
  18289. * You can use gravity if you want to give an orientation to your particles.
  18290. */
  18291. gravity: Vector3;
  18292. /**
  18293. * Minimum power of emitting particles.
  18294. */
  18295. minEmitPower: number;
  18296. /**
  18297. * Maximum power of emitting particles.
  18298. */
  18299. maxEmitPower: number;
  18300. /**
  18301. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18302. */
  18303. minAngularSpeed: number;
  18304. /**
  18305. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18306. */
  18307. maxAngularSpeed: number;
  18308. /**
  18309. * The particle emitter type defines the emitter used by the particle system.
  18310. * It can be for example box, sphere, or cone...
  18311. */
  18312. particleEmitterType: Nullable<IParticleEmitterType>;
  18313. /**
  18314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18315. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18316. */
  18317. direction1: Vector3;
  18318. /**
  18319. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18320. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18321. */
  18322. direction2: Vector3;
  18323. /**
  18324. * 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.
  18325. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18326. */
  18327. minEmitBox: Vector3;
  18328. /**
  18329. * 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.
  18330. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18331. */
  18332. maxEmitBox: Vector3;
  18333. /**
  18334. * Gets the maximum number of particles active at the same time.
  18335. * @returns The max number of active particles.
  18336. */
  18337. getCapacity(): number;
  18338. /**
  18339. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18340. * to override the particles.
  18341. */
  18342. forceDepthWrite: boolean;
  18343. /**
  18344. * Gets or set the number of active particles
  18345. */
  18346. activeParticleCount: number;
  18347. /**
  18348. * Is this system ready to be used/rendered
  18349. * @return true if the system is ready
  18350. */
  18351. isReady(): boolean;
  18352. /**
  18353. * Gets Wether the system has been started.
  18354. * @returns True if it has been started, otherwise false.
  18355. */
  18356. isStarted(): boolean;
  18357. /**
  18358. * Starts the particle system and begins to emit.
  18359. */
  18360. start(): void;
  18361. /**
  18362. * Stops the particle system.
  18363. */
  18364. stop(): void;
  18365. /**
  18366. * Remove all active particles
  18367. */
  18368. reset(): void;
  18369. /**
  18370. * Returns the string "GPUParticleSystem"
  18371. * @returns a string containing the class name
  18372. */
  18373. getClassName(): string;
  18374. /**
  18375. * Instantiates a GPU particle system.
  18376. * 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.
  18377. * @param name The name of the particle system
  18378. * @param capacity The max number of particles alive at the same time
  18379. * @param scene The scene the particle system belongs to
  18380. */
  18381. constructor(name: string, options: Partial<{
  18382. capacity: number;
  18383. randomTextureSize: number;
  18384. }>, scene: Scene);
  18385. private _createUpdateVAO(source);
  18386. private _createRenderVAO(source, spriteSource);
  18387. private _initialize(force?);
  18388. /** @hidden */
  18389. /** @hidden */
  18390. /**
  18391. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18392. */
  18393. animate(): void;
  18394. /**
  18395. * Renders the particle system in its current state.
  18396. * @returns the current number of particles
  18397. */
  18398. render(): number;
  18399. /**
  18400. * Rebuilds the particle system
  18401. */
  18402. rebuild(): void;
  18403. private _releaseBuffers();
  18404. private _releaseVAOs();
  18405. /**
  18406. * Disposes the particle system and free the associated resources
  18407. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18408. */
  18409. dispose(disposeTexture?: boolean): void;
  18410. /**
  18411. * Clones the particle system.
  18412. * @param name The name of the cloned object
  18413. * @param newEmitter The new emitter to use
  18414. * @returns the cloned particle system
  18415. */
  18416. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  18417. /**
  18418. * Serializes the particle system to a JSON object.
  18419. * @returns the JSON object
  18420. */
  18421. serialize(): any;
  18422. /**
  18423. * Parses a JSON object to create a GPU particle system.
  18424. * @param parsedParticleSystem The JSON object to parse
  18425. * @param scene The scene to create the particle system in
  18426. * @param rootUrl The root url to use to load external dependencies like texture
  18427. * @returns the parsed GPU particle system
  18428. */
  18429. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  18430. }
  18431. }
  18432. declare module BABYLON {
  18433. /**
  18434. * Interface representing a particle system in Babylon.
  18435. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18436. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18437. */
  18438. interface IParticleSystem {
  18439. /**
  18440. * The id of the Particle system.
  18441. */
  18442. id: string;
  18443. /**
  18444. * The name of the Particle system.
  18445. */
  18446. name: string;
  18447. /**
  18448. * The emitter represents the Mesh or position we are attaching the particle system to.
  18449. */
  18450. emitter: Nullable<AbstractMesh | Vector3>;
  18451. /**
  18452. * The rendering group used by the Particle system to chose when to render.
  18453. */
  18454. renderingGroupId: number;
  18455. /**
  18456. * The layer mask we are rendering the particles through.
  18457. */
  18458. layerMask: number;
  18459. /**
  18460. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18461. */
  18462. updateSpeed: number;
  18463. /**
  18464. * The amount of time the particle system is running (depends of the overall update speed).
  18465. */
  18466. targetStopDuration: number;
  18467. /**
  18468. * The texture used to render each particle. (this can be a spritesheet)
  18469. */
  18470. particleTexture: Nullable<Texture>;
  18471. /**
  18472. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18473. */
  18474. blendMode: number;
  18475. /**
  18476. * Minimum life time of emitting particles.
  18477. */
  18478. minLifeTime: number;
  18479. /**
  18480. * Maximum life time of emitting particles.
  18481. */
  18482. maxLifeTime: number;
  18483. /**
  18484. * Minimum Size of emitting particles.
  18485. */
  18486. minSize: number;
  18487. /**
  18488. * Maximum Size of emitting particles.
  18489. */
  18490. maxSize: number;
  18491. /**
  18492. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18493. */
  18494. color1: Color4;
  18495. /**
  18496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18497. */
  18498. color2: Color4;
  18499. /**
  18500. * Color the particle will have at the end of its lifetime.
  18501. */
  18502. colorDead: Color4;
  18503. /**
  18504. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18505. */
  18506. emitRate: number;
  18507. /**
  18508. * You can use gravity if you want to give an orientation to your particles.
  18509. */
  18510. gravity: Vector3;
  18511. /**
  18512. * Minimum power of emitting particles.
  18513. */
  18514. minEmitPower: number;
  18515. /**
  18516. * Maximum power of emitting particles.
  18517. */
  18518. maxEmitPower: number;
  18519. /**
  18520. * The particle emitter type defines the emitter used by the particle system.
  18521. * It can be for example box, sphere, or cone...
  18522. */
  18523. particleEmitterType: Nullable<IParticleEmitterType>;
  18524. /**
  18525. * Gets the maximum number of particles active at the same time.
  18526. * @returns The max number of active particles.
  18527. */
  18528. getCapacity(): number;
  18529. /**
  18530. * Gets Wether the system has been started.
  18531. * @returns True if it has been started, otherwise false.
  18532. */
  18533. isStarted(): boolean;
  18534. /**
  18535. * Gets if the particle system has been started.
  18536. * @return true if the system has been started, otherwise false.
  18537. */
  18538. isStarted(): boolean;
  18539. /**
  18540. * Animates the particle system for this frame.
  18541. */
  18542. animate(): void;
  18543. /**
  18544. * Renders the particle system in its current state.
  18545. * @returns the current number of particles
  18546. */
  18547. render(): number;
  18548. /**
  18549. * Dispose the particle system and frees its associated resources.
  18550. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18551. */
  18552. dispose(disposeTexture?: boolean): void;
  18553. /**
  18554. * Clones the particle system.
  18555. * @param name The name of the cloned object
  18556. * @param newEmitter The new emitter to use
  18557. * @returns the cloned particle system
  18558. */
  18559. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18560. /**
  18561. * Serializes the particle system to a JSON object.
  18562. * @returns the JSON object
  18563. */
  18564. serialize(): any;
  18565. /**
  18566. * Rebuild the particle system
  18567. */
  18568. rebuild(): void;
  18569. /**
  18570. * Starts the particle system and begins to emit.
  18571. */
  18572. start(): void;
  18573. /**
  18574. * Stops the particle system.
  18575. */
  18576. stop(): void;
  18577. /**
  18578. * Remove all active particles
  18579. */
  18580. reset(): void;
  18581. /**
  18582. * Is this system ready to be used/rendered
  18583. * @return true if the system is ready
  18584. */
  18585. isReady(): boolean;
  18586. }
  18587. }
  18588. declare module BABYLON {
  18589. /**
  18590. * A particle represents one of the element emitted by a particle system.
  18591. * This is mainly define by its coordinates, direction, velocity and age.
  18592. */
  18593. class Particle {
  18594. /**
  18595. * particleSystem the particle system the particle belongs to.
  18596. */
  18597. particleSystem: ParticleSystem;
  18598. /**
  18599. * The world position of the particle in the scene.
  18600. */
  18601. position: Vector3;
  18602. /**
  18603. * The world direction of the particle in the scene.
  18604. */
  18605. direction: Vector3;
  18606. /**
  18607. * The color of the particle.
  18608. */
  18609. color: Color4;
  18610. /**
  18611. * The color change of the particle per step.
  18612. */
  18613. colorStep: Color4;
  18614. /**
  18615. * Defines how long will the life of the particle be.
  18616. */
  18617. lifeTime: number;
  18618. /**
  18619. * The current age of the particle.
  18620. */
  18621. age: number;
  18622. /**
  18623. * The current size of the particle.
  18624. */
  18625. size: number;
  18626. /**
  18627. * The current angle of the particle.
  18628. */
  18629. angle: number;
  18630. /**
  18631. * Defines how fast is the angle changing.
  18632. */
  18633. angularSpeed: number;
  18634. /**
  18635. * Defines the cell index used by the particle to be rendered from a sprite.
  18636. */
  18637. cellIndex: number;
  18638. private _currentFrameCounter;
  18639. /**
  18640. * Creates a new instance Particle
  18641. * @param particleSystem the particle system the particle belongs to
  18642. */
  18643. constructor(
  18644. /**
  18645. * particleSystem the particle system the particle belongs to.
  18646. */
  18647. particleSystem: ParticleSystem);
  18648. private updateCellInfoFromSystem();
  18649. /**
  18650. * Defines how the sprite cell index is updated for the particle. This is
  18651. * defined as a callback.
  18652. */
  18653. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18654. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18655. private _updateCellIndexWithCustomSpeed();
  18656. /**
  18657. * Copy the properties of particle to another one.
  18658. * @param other the particle to copy the information to.
  18659. */
  18660. copyTo(other: Particle): void;
  18661. }
  18662. }
  18663. declare module BABYLON {
  18664. /**
  18665. * This represents a particle system in Babylon.
  18666. * 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.
  18667. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18668. * @example https://doc.babylonjs.com/babylon101/particles
  18669. */
  18670. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18671. /**
  18672. * Source color is added to the destination color without alpha affecting the result.
  18673. */
  18674. static BLENDMODE_ONEONE: number;
  18675. /**
  18676. * Blend current color and particle color using particle’s alpha.
  18677. */
  18678. static BLENDMODE_STANDARD: number;
  18679. /**
  18680. * List of animations used by the particle system.
  18681. */
  18682. animations: Animation[];
  18683. /**
  18684. * The id of the Particle system.
  18685. */
  18686. id: string;
  18687. /**
  18688. * The friendly name of the Particle system.
  18689. */
  18690. name: string;
  18691. /**
  18692. * The rendering group used by the Particle system to chose when to render.
  18693. */
  18694. renderingGroupId: number;
  18695. /**
  18696. * The emitter represents the Mesh or position we are attaching the particle system to.
  18697. */
  18698. emitter: Nullable<AbstractMesh | Vector3>;
  18699. /**
  18700. * The maximum number of particles to emit per frame
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * If you want to launch only a few particles at once, that can be done, as well.
  18705. */
  18706. manualEmitCount: number;
  18707. /**
  18708. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18709. */
  18710. updateSpeed: number;
  18711. /**
  18712. * The amount of time the particle system is running (depends of the overall update speed).
  18713. */
  18714. targetStopDuration: number;
  18715. /**
  18716. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18717. */
  18718. disposeOnStop: boolean;
  18719. /**
  18720. * Minimum power of emitting particles.
  18721. */
  18722. minEmitPower: number;
  18723. /**
  18724. * Maximum power of emitting particles.
  18725. */
  18726. maxEmitPower: number;
  18727. /**
  18728. * Minimum life time of emitting particles.
  18729. */
  18730. minLifeTime: number;
  18731. /**
  18732. * Maximum life time of emitting particles.
  18733. */
  18734. maxLifeTime: number;
  18735. /**
  18736. * Minimum Size of emitting particles.
  18737. */
  18738. minSize: number;
  18739. /**
  18740. * Maximum Size of emitting particles.
  18741. */
  18742. maxSize: number;
  18743. /**
  18744. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18745. */
  18746. minAngularSpeed: number;
  18747. /**
  18748. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18749. */
  18750. maxAngularSpeed: number;
  18751. /**
  18752. * The texture used to render each particle. (this can be a spritesheet)
  18753. */
  18754. particleTexture: Nullable<Texture>;
  18755. /**
  18756. * The layer mask we are rendering the particles through.
  18757. */
  18758. layerMask: number;
  18759. /**
  18760. * This can help using your own shader to render the particle system.
  18761. * The according effect will be created
  18762. */
  18763. customShader: any;
  18764. /**
  18765. * By default particle system starts as soon as they are created. This prevents the
  18766. * automatic start to happen and let you decide when to start emitting particles.
  18767. */
  18768. preventAutoStart: boolean;
  18769. /**
  18770. * This function can be defined to provide custom update for active particles.
  18771. * This function will be called instead of regular update (age, position, color, etc.).
  18772. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18773. */
  18774. updateFunction: (particles: Particle[]) => void;
  18775. /**
  18776. * Callback triggered when the particle animation is ending.
  18777. */
  18778. onAnimationEnd: Nullable<() => void>;
  18779. /**
  18780. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18781. */
  18782. blendMode: number;
  18783. /**
  18784. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18785. * to override the particles.
  18786. */
  18787. forceDepthWrite: boolean;
  18788. /**
  18789. * You can use gravity if you want to give an orientation to your particles.
  18790. */
  18791. gravity: Vector3;
  18792. /**
  18793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18794. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18795. */
  18796. direction1: Vector3;
  18797. /**
  18798. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18799. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18800. */
  18801. direction2: Vector3;
  18802. /**
  18803. * 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.
  18804. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18805. */
  18806. minEmitBox: Vector3;
  18807. /**
  18808. * 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.
  18809. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18810. */
  18811. maxEmitBox: Vector3;
  18812. /**
  18813. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18814. */
  18815. color1: Color4;
  18816. /**
  18817. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18818. */
  18819. color2: Color4;
  18820. /**
  18821. * Color the particle will have at the end of its lifetime.
  18822. */
  18823. colorDead: Color4;
  18824. /**
  18825. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18826. */
  18827. textureMask: Color4;
  18828. /**
  18829. * The particle emitter type defines the emitter used by the particle system.
  18830. * It can be for example box, sphere, or cone...
  18831. */
  18832. particleEmitterType: IParticleEmitterType;
  18833. /**
  18834. * This function can be defined to specify initial direction for every new particle.
  18835. * It by default use the emitterType defined function.
  18836. */
  18837. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18838. /**
  18839. * This function can be defined to specify initial position for every new particle.
  18840. * It by default use the emitterType defined function.
  18841. */
  18842. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18843. /**
  18844. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18845. */
  18846. spriteCellLoop: boolean;
  18847. /**
  18848. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18849. */
  18850. spriteCellChangeSpeed: number;
  18851. /**
  18852. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18853. */
  18854. startSpriteCellID: number;
  18855. /**
  18856. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18857. */
  18858. endSpriteCellID: number;
  18859. /**
  18860. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18861. */
  18862. spriteCellWidth: number;
  18863. /**
  18864. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18865. */
  18866. spriteCellHeight: number;
  18867. /**
  18868. * An event triggered when the system is disposed.
  18869. */
  18870. onDisposeObservable: Observable<ParticleSystem>;
  18871. private _onDisposeObserver;
  18872. /**
  18873. * Sets a callback that will be triggered when the system is disposed.
  18874. */
  18875. onDispose: () => void;
  18876. /**
  18877. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18878. */
  18879. readonly isAnimationSheetEnabled: Boolean;
  18880. private _particles;
  18881. private _epsilon;
  18882. private _capacity;
  18883. private _scene;
  18884. private _stockParticles;
  18885. private _newPartsExcess;
  18886. private _vertexData;
  18887. private _vertexBuffer;
  18888. private _vertexBuffers;
  18889. private _indexBuffer;
  18890. private _effect;
  18891. private _customEffect;
  18892. private _cachedDefines;
  18893. private _scaledColorStep;
  18894. private _colorDiff;
  18895. private _scaledDirection;
  18896. private _scaledGravity;
  18897. private _currentRenderId;
  18898. private _alive;
  18899. private _started;
  18900. private _stopped;
  18901. private _actualFrame;
  18902. private _scaledUpdateSpeed;
  18903. private _vertexBufferSize;
  18904. private _isAnimationSheetEnabled;
  18905. /**
  18906. * 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.
  18907. */
  18908. subEmitters: ParticleSystem[];
  18909. /**
  18910. * The current active Sub-systems, this property is used by the root particle system only.
  18911. */
  18912. activeSubSystems: Array<ParticleSystem>;
  18913. private _rootParticleSystem;
  18914. /**
  18915. * Gets the current list of active particles
  18916. */
  18917. readonly particles: Particle[];
  18918. /**
  18919. * Returns the string "ParticleSystem"
  18920. * @returns a string containing the class name
  18921. */
  18922. getClassName(): string;
  18923. /**
  18924. * Instantiates a particle system.
  18925. * 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.
  18926. * @param name The name of the particle system
  18927. * @param capacity The max number of particles alive at the same time
  18928. * @param scene The scene the particle system belongs to
  18929. * @param customEffect a custom effect used to change the way particles are rendered by default
  18930. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18931. * @param epsilon Offset used to render the particles
  18932. */
  18933. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18934. private _createIndexBuffer();
  18935. /**
  18936. * Gets the maximum number of particles active at the same time.
  18937. * @returns The max number of active particles.
  18938. */
  18939. getCapacity(): number;
  18940. /**
  18941. * Gets Wether there are still active particles in the system.
  18942. * @returns True if it is alive, otherwise false.
  18943. */
  18944. isAlive(): boolean;
  18945. /**
  18946. * Gets Wether the system has been started.
  18947. * @returns True if it has been started, otherwise false.
  18948. */
  18949. isStarted(): boolean;
  18950. /**
  18951. * Starts the particle system and begins to emit.
  18952. */
  18953. start(): void;
  18954. /**
  18955. * Stops the particle system.
  18956. * @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.
  18957. */
  18958. stop(stopSubEmitters?: boolean): void;
  18959. /**
  18960. * Remove all active particles
  18961. */
  18962. reset(): void;
  18963. /**
  18964. * @hidden (for internal use only)
  18965. */
  18966. /**
  18967. * @hidden (for internal use only)
  18968. */
  18969. /**
  18970. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18971. * Its lifetime will start back at 0.
  18972. */
  18973. recycleParticle: (particle: Particle) => void;
  18974. private _stopSubEmitters();
  18975. private _createParticle;
  18976. private _removeFromRoot();
  18977. private _emitFromParticle;
  18978. private _update(newParticles);
  18979. private _getEffect();
  18980. /**
  18981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18982. */
  18983. animate(): void;
  18984. private _appendParticleVertexes;
  18985. private _appenedParticleVertexesWithSheet(offset, particle);
  18986. private _appenedParticleVertexesNoSheet(offset, particle);
  18987. /**
  18988. * Rebuilds the particle system.
  18989. */
  18990. rebuild(): void;
  18991. /**
  18992. * Is this system ready to be used/rendered
  18993. * @return true if the system is ready
  18994. */
  18995. isReady(): boolean;
  18996. /**
  18997. * Renders the particle system in its current state.
  18998. * @returns the current number of particles
  18999. */
  19000. render(): number;
  19001. /**
  19002. * Disposes the particle system and free the associated resources
  19003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19004. */
  19005. dispose(disposeTexture?: boolean): void;
  19006. /**
  19007. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  19008. * @param radius The radius of the sphere to emit from
  19009. * @returns the emitter
  19010. */
  19011. createSphereEmitter(radius?: number): SphereParticleEmitter;
  19012. /**
  19013. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  19014. * @param radius The radius of the sphere to emit from
  19015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19017. * @returns the emitter
  19018. */
  19019. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19020. /**
  19021. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  19022. * @param radius The radius of the cone to emit from
  19023. * @param angle The base angle of the cone
  19024. * @returns the emitter
  19025. */
  19026. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19027. /**
  19028. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19031. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19032. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19033. * @returns the emitter
  19034. */
  19035. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19036. /**
  19037. * Clones the particle system.
  19038. * @param name The name of the cloned object
  19039. * @param newEmitter The new emitter to use
  19040. * @returns the cloned particle system
  19041. */
  19042. clone(name: string, newEmitter: any): ParticleSystem;
  19043. /**
  19044. * Serializes the particle system to a JSON object.
  19045. * @returns the JSON object
  19046. */
  19047. serialize(): any;
  19048. /**
  19049. * Parses a JSON object to create a particle system.
  19050. * @param parsedParticleSystem The JSON object to parse
  19051. * @param scene The scene to create the particle system in
  19052. * @param rootUrl The root url to use to load external dependencies like texture
  19053. * @returns the Parsed particle system
  19054. */
  19055. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  19056. }
  19057. }
  19058. declare module BABYLON {
  19059. /**
  19060. * Represents one particle of a solid particle system.
  19061. */
  19062. class SolidParticle {
  19063. /**
  19064. * particle global index
  19065. */
  19066. idx: number;
  19067. /**
  19068. * The color of the particle
  19069. */
  19070. color: Nullable<Color4>;
  19071. /**
  19072. * The world space position of the particle.
  19073. */
  19074. position: Vector3;
  19075. /**
  19076. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  19077. */
  19078. rotation: Vector3;
  19079. /**
  19080. * The world space rotation quaternion of the particle.
  19081. */
  19082. rotationQuaternion: Nullable<Quaternion>;
  19083. /**
  19084. * The scaling of the particle.
  19085. */
  19086. scaling: Vector3;
  19087. /**
  19088. * The uvs of the particle.
  19089. */
  19090. uvs: Vector4;
  19091. /**
  19092. * The current speed of the particle.
  19093. */
  19094. velocity: Vector3;
  19095. /**
  19096. * The pivot point in the particle local space.
  19097. */
  19098. pivot: Vector3;
  19099. /**
  19100. * Must the particle be translated from its pivot point in its local space ?
  19101. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  19102. * Default : false
  19103. */
  19104. translateFromPivot: boolean;
  19105. /**
  19106. * Is the particle active or not ?
  19107. */
  19108. alive: boolean;
  19109. /**
  19110. * Is the particle visible or not ?
  19111. */
  19112. isVisible: boolean;
  19113. /**
  19114. * Index of this particle in the global "positions" array (Internal use)
  19115. */
  19116. /**
  19117. * Index of this particle in the global "indices" array (Internal use)
  19118. */
  19119. /**
  19120. * ModelShape of this particle (Internal use)
  19121. */
  19122. /**
  19123. * ModelShape id of this particle
  19124. */
  19125. shapeId: number;
  19126. /**
  19127. * Index of the particle in its shape id (Internal use)
  19128. */
  19129. idxInShape: number;
  19130. /**
  19131. * Reference to the shape model BoundingInfo object (Internal use)
  19132. */
  19133. /**
  19134. * Particle BoundingInfo object (Internal use)
  19135. */
  19136. /**
  19137. * Reference to the SPS what the particle belongs to (Internal use)
  19138. */
  19139. /**
  19140. * Still set as invisible in order to skip useless computations (Internal use)
  19141. */
  19142. /**
  19143. * Last computed particle rotation matrix
  19144. */
  19145. /**
  19146. * Parent particle Id, if any.
  19147. * Default null.
  19148. */
  19149. parentId: Nullable<number>;
  19150. /**
  19151. * Internal global position in the SPS.
  19152. */
  19153. /**
  19154. * Creates a Solid Particle object.
  19155. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  19156. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  19157. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  19158. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  19159. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  19160. * @param shapeId (integer) is the model shape identifier in the SPS.
  19161. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  19162. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  19163. */
  19164. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  19165. /**
  19166. * Legacy support, changed scale to scaling
  19167. */
  19168. /**
  19169. * Legacy support, changed scale to scaling
  19170. */
  19171. scale: Vector3;
  19172. /**
  19173. * Legacy support, changed quaternion to rotationQuaternion
  19174. */
  19175. /**
  19176. * Legacy support, changed quaternion to rotationQuaternion
  19177. */
  19178. quaternion: Nullable<Quaternion>;
  19179. /**
  19180. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  19181. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  19182. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  19183. * @returns true if it intersects
  19184. */
  19185. intersectsMesh(target: Mesh | SolidParticle): boolean;
  19186. }
  19187. /**
  19188. * Represents the shape of the model used by one particle of a solid particle system.
  19189. * SPS internal tool, don't use it manually.
  19190. */
  19191. class ModelShape {
  19192. /**
  19193. * The shape id.
  19194. */
  19195. shapeID: number;
  19196. /**
  19197. * flat array of model positions (internal use)
  19198. */
  19199. /**
  19200. * flat array of model UVs (internal use)
  19201. */
  19202. /**
  19203. * length of the shape in the model indices array (internal use)
  19204. */
  19205. /**
  19206. * Custom position function (internal use)
  19207. */
  19208. /**
  19209. * Custom vertex function (internal use)
  19210. */
  19211. /**
  19212. * 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.
  19213. * SPS internal tool, don't use it manually.
  19214. * @hidden
  19215. */
  19216. 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>);
  19217. }
  19218. /**
  19219. * Represents a Depth Sorted Particle in the solid particle system.
  19220. */
  19221. class DepthSortedParticle {
  19222. /**
  19223. * Index of the particle in the "indices" array
  19224. */
  19225. ind: number;
  19226. /**
  19227. * Length of the particle shape in the "indices" array
  19228. */
  19229. indicesLength: number;
  19230. /**
  19231. * Squared distance from the particle to the camera
  19232. */
  19233. sqDistance: number;
  19234. }
  19235. }
  19236. declare module BABYLON {
  19237. /**
  19238. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  19239. *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.
  19240. * The SPS is also a particle system. It provides some methods to manage the particles.
  19241. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  19242. *
  19243. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  19244. */
  19245. class SolidParticleSystem implements IDisposable {
  19246. /**
  19247. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  19248. * Example : var p = SPS.particles[i];
  19249. */
  19250. particles: SolidParticle[];
  19251. /**
  19252. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  19253. */
  19254. nbParticles: number;
  19255. /**
  19256. * If the particles must ever face the camera (default false). Useful for planar particles.
  19257. */
  19258. billboard: boolean;
  19259. /**
  19260. * Recompute normals when adding a shape
  19261. */
  19262. recomputeNormals: boolean;
  19263. /**
  19264. * This a counter ofr your own usage. It's not set by any SPS functions.
  19265. */
  19266. counter: number;
  19267. /**
  19268. * The SPS name. This name is also given to the underlying mesh.
  19269. */
  19270. name: string;
  19271. /**
  19272. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  19273. */
  19274. mesh: Mesh;
  19275. /**
  19276. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  19277. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  19278. */
  19279. vars: any;
  19280. /**
  19281. * This array is populated when the SPS is set as 'pickable'.
  19282. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  19283. * Each element of this array is an object `{idx: int, faceId: int}`.
  19284. * `idx` is the picked particle index in the `SPS.particles` array
  19285. * `faceId` is the picked face index counted within this particle.
  19286. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  19287. */
  19288. pickedParticles: {
  19289. idx: number;
  19290. faceId: number;
  19291. }[];
  19292. /**
  19293. * This array is populated when `enableDepthSort` is set to true.
  19294. * Each element of this array is an instance of the class DepthSortedParticle.
  19295. */
  19296. depthSortedParticles: DepthSortedParticle[];
  19297. /**
  19298. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  19299. */
  19300. /**
  19301. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  19302. */
  19303. private _scene;
  19304. private _positions;
  19305. private _indices;
  19306. private _normals;
  19307. private _colors;
  19308. private _uvs;
  19309. private _indices32;
  19310. private _positions32;
  19311. private _normals32;
  19312. private _fixedNormal32;
  19313. private _colors32;
  19314. private _uvs32;
  19315. private _index;
  19316. private _updatable;
  19317. private _pickable;
  19318. private _isVisibilityBoxLocked;
  19319. private _alwaysVisible;
  19320. private _depthSort;
  19321. private _shapeCounter;
  19322. private _copy;
  19323. private _shape;
  19324. private _shapeUV;
  19325. private _color;
  19326. private _computeParticleColor;
  19327. private _computeParticleTexture;
  19328. private _computeParticleRotation;
  19329. private _computeParticleVertex;
  19330. private _computeBoundingBox;
  19331. private _depthSortParticles;
  19332. private _cam_axisZ;
  19333. private _cam_axisY;
  19334. private _cam_axisX;
  19335. private _axisZ;
  19336. private _camera;
  19337. private _particle;
  19338. private _camDir;
  19339. private _camInvertedPosition;
  19340. private _rotMatrix;
  19341. private _invertMatrix;
  19342. private _rotated;
  19343. private _quaternion;
  19344. private _vertex;
  19345. private _normal;
  19346. private _yaw;
  19347. private _pitch;
  19348. private _roll;
  19349. private _halfroll;
  19350. private _halfpitch;
  19351. private _halfyaw;
  19352. private _sinRoll;
  19353. private _cosRoll;
  19354. private _sinPitch;
  19355. private _cosPitch;
  19356. private _sinYaw;
  19357. private _cosYaw;
  19358. private _mustUnrotateFixedNormals;
  19359. private _minimum;
  19360. private _maximum;
  19361. private _minBbox;
  19362. private _maxBbox;
  19363. private _particlesIntersect;
  19364. private _depthSortFunction;
  19365. private _needs32Bits;
  19366. private _pivotBackTranslation;
  19367. private _scaledPivot;
  19368. private _particleHasParent;
  19369. private _parent;
  19370. /**
  19371. * Creates a SPS (Solid Particle System) object.
  19372. * @param name (String) is the SPS name, this will be the underlying mesh name.
  19373. * @param scene (Scene) is the scene in which the SPS is added.
  19374. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  19375. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  19376. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  19377. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  19378. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  19379. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  19380. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  19381. */
  19382. constructor(name: string, scene: Scene, options?: {
  19383. updatable?: boolean;
  19384. isPickable?: boolean;
  19385. enableDepthSort?: boolean;
  19386. particleIntersection?: boolean;
  19387. boundingSphereOnly?: boolean;
  19388. bSphereRadiusFactor?: number;
  19389. });
  19390. /**
  19391. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19392. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19393. * @returns the created mesh
  19394. */
  19395. buildMesh(): Mesh;
  19396. /**
  19397. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19398. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19399. * Thus the particles generated from `digest()` have their property `position` set yet.
  19400. * @param mesh ( Mesh ) is the mesh to be digested
  19401. * @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
  19402. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19403. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19404. * @returns the current SPS
  19405. */
  19406. digest(mesh: Mesh, options?: {
  19407. facetNb?: number;
  19408. number?: number;
  19409. delta?: number;
  19410. }): SolidParticleSystem;
  19411. private _unrotateFixedNormals();
  19412. private _resetCopy();
  19413. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  19414. private _posToShape(positions);
  19415. private _uvsToShapeUV(uvs);
  19416. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  19417. /**
  19418. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19419. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19420. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19421. * @param nb (positive integer) the number of particles to be created from this model
  19422. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19423. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19424. * @returns the number of shapes in the system
  19425. */
  19426. addShape(mesh: Mesh, nb: number, options?: {
  19427. positionFunction?: any;
  19428. vertexFunction?: any;
  19429. }): number;
  19430. private _rebuildParticle(particle);
  19431. /**
  19432. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19433. * @returns the SPS.
  19434. */
  19435. rebuildMesh(): SolidParticleSystem;
  19436. /**
  19437. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19438. * This method calls `updateParticle()` for each particle of the SPS.
  19439. * For an animated SPS, it is usually called within the render loop.
  19440. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19441. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19442. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19443. * @returns the SPS.
  19444. */
  19445. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19446. private _quaternionRotationYPR();
  19447. private _quaternionToRotationMatrix();
  19448. /**
  19449. * Disposes the SPS.
  19450. */
  19451. dispose(): void;
  19452. /**
  19453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19454. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19455. * @returns the SPS.
  19456. */
  19457. refreshVisibleSize(): SolidParticleSystem;
  19458. /**
  19459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19460. * @param size the size (float) of the visibility box
  19461. * note : this doesn't lock the SPS mesh bounding box.
  19462. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19463. */
  19464. setVisibilityBox(size: number): void;
  19465. /**
  19466. * Gets whether the SPS as always visible or not
  19467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19468. */
  19469. /**
  19470. * Sets the SPS as always visible or not
  19471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19472. */
  19473. isAlwaysVisible: boolean;
  19474. /**
  19475. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19476. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19477. */
  19478. /**
  19479. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19481. */
  19482. isVisibilityBoxLocked: boolean;
  19483. /**
  19484. * Gets if `setParticles()` computes the particle rotations or not.
  19485. * Default value : true. The SPS is faster when it's set to false.
  19486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19487. */
  19488. /**
  19489. * Tells to `setParticles()` to compute the particle rotations or not.
  19490. * Default value : true. The SPS is faster when it's set to false.
  19491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19492. */
  19493. computeParticleRotation: boolean;
  19494. /**
  19495. * Gets if `setParticles()` computes the particle colors or not.
  19496. * Default value : true. The SPS is faster when it's set to false.
  19497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19498. */
  19499. /**
  19500. * Tells to `setParticles()` to compute the particle colors or not.
  19501. * Default value : true. The SPS is faster when it's set to false.
  19502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19503. */
  19504. computeParticleColor: boolean;
  19505. /**
  19506. * Gets if `setParticles()` computes the particle textures or not.
  19507. * Default value : true. The SPS is faster when it's set to false.
  19508. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19509. */
  19510. computeParticleTexture: boolean;
  19511. /**
  19512. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19513. * Default value : false. The SPS is faster when it's set to false.
  19514. * Note : the particle custom vertex positions aren't stored values.
  19515. */
  19516. /**
  19517. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19518. * Default value : false. The SPS is faster when it's set to false.
  19519. * Note : the particle custom vertex positions aren't stored values.
  19520. */
  19521. computeParticleVertex: boolean;
  19522. /**
  19523. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19524. */
  19525. /**
  19526. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19527. */
  19528. computeBoundingBox: boolean;
  19529. /**
  19530. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19532. * Default : `true`
  19533. */
  19534. /**
  19535. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19536. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19537. * Default : `true`
  19538. */
  19539. depthSortParticles: boolean;
  19540. /**
  19541. * This function does nothing. It may be overwritten to set all the particle first values.
  19542. * The SPS doesn't call this function, you may have to call it by your own.
  19543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19544. */
  19545. initParticles(): void;
  19546. /**
  19547. * This function does nothing. It may be overwritten to recycle a particle.
  19548. * The SPS doesn't call this function, you may have to call it by your own.
  19549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19550. * @param particle The particle to recycle
  19551. * @returns the recycled particle
  19552. */
  19553. recycleParticle(particle: SolidParticle): SolidParticle;
  19554. /**
  19555. * Updates a particle : this function should be overwritten by the user.
  19556. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19557. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19558. * @example : just set a particle position or velocity and recycle conditions
  19559. * @param particle The particle to update
  19560. * @returns the updated particle
  19561. */
  19562. updateParticle(particle: SolidParticle): SolidParticle;
  19563. /**
  19564. * Updates a vertex of a particle : it can be overwritten by the user.
  19565. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19566. * @param particle the current particle
  19567. * @param vertex the current index of the current particle
  19568. * @param pt the index of the current vertex in the particle shape
  19569. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19570. * @example : just set a vertex particle position
  19571. * @returns the updated vertex
  19572. */
  19573. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19574. /**
  19575. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19576. * This does nothing and may be overwritten by the user.
  19577. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19579. * @param update the boolean update value actually passed to setParticles()
  19580. */
  19581. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19582. /**
  19583. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19584. * This will be passed three parameters.
  19585. * This does nothing and may be overwritten by the user.
  19586. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19587. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19588. * @param update the boolean update value actually passed to setParticles()
  19589. */
  19590. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19591. }
  19592. }
  19593. declare module BABYLON {
  19594. /**
  19595. * Class used to store all common mesh properties
  19596. */
  19597. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19598. /** No occlusion */
  19599. static OCCLUSION_TYPE_NONE: number;
  19600. /** Occlusion set to optimisitic */
  19601. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19602. /** Occlusion set to strict */
  19603. static OCCLUSION_TYPE_STRICT: number;
  19604. /** Use an accurante occlusion algorithm */
  19605. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19606. /** Use a conservative occlusion algorithm */
  19607. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19608. /**
  19609. * No billboard
  19610. */
  19611. static readonly BILLBOARDMODE_NONE: number;
  19612. /** Billboard on X axis */
  19613. static readonly BILLBOARDMODE_X: number;
  19614. /** Billboard on Y axis */
  19615. static readonly BILLBOARDMODE_Y: number;
  19616. /** Billboard on Z axis */
  19617. static readonly BILLBOARDMODE_Z: number;
  19618. /** Billboard on all axes */
  19619. static readonly BILLBOARDMODE_ALL: number;
  19620. private _facetPositions;
  19621. private _facetNormals;
  19622. private _facetPartitioning;
  19623. private _facetNb;
  19624. private _partitioningSubdivisions;
  19625. private _partitioningBBoxRatio;
  19626. private _facetDataEnabled;
  19627. private _facetParameters;
  19628. private _bbSize;
  19629. private _subDiv;
  19630. private _facetDepthSort;
  19631. private _facetDepthSortEnabled;
  19632. private _depthSortedIndices;
  19633. private _depthSortedFacets;
  19634. private _facetDepthSortFunction;
  19635. private _facetDepthSortFrom;
  19636. private _facetDepthSortOrigin;
  19637. private _invertedMatrix;
  19638. /**
  19639. * Gets the number of facets in the mesh
  19640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19641. */
  19642. readonly facetNb: number;
  19643. /**
  19644. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19646. */
  19647. partitioningSubdivisions: number;
  19648. /**
  19649. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19650. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19652. */
  19653. partitioningBBoxRatio: number;
  19654. /**
  19655. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19656. * Works only for updatable meshes.
  19657. * Doesn't work with multi-materials
  19658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19659. */
  19660. mustDepthSortFacets: boolean;
  19661. /**
  19662. * The location (Vector3) where the facet depth sort must be computed from.
  19663. * By default, the active camera position.
  19664. * Used only when facet depth sort is enabled
  19665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19666. */
  19667. facetDepthSortFrom: Vector3;
  19668. /**
  19669. * gets a boolean indicating if facetData is enabled
  19670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19671. */
  19672. readonly isFacetDataEnabled: boolean;
  19673. /** @hidden */
  19674. /**
  19675. * An event triggered when this mesh collides with another one
  19676. */
  19677. onCollideObservable: Observable<AbstractMesh>;
  19678. private _onCollideObserver;
  19679. /** Set a function to call when this mesh collides with another one */
  19680. onCollide: () => void;
  19681. /**
  19682. * An event triggered when the collision's position changes
  19683. */
  19684. onCollisionPositionChangeObservable: Observable<Vector3>;
  19685. private _onCollisionPositionChangeObserver;
  19686. /** Set a function to call when the collision's position changes */
  19687. onCollisionPositionChange: () => void;
  19688. /**
  19689. * An event triggered when material is changed
  19690. */
  19691. onMaterialChangedObservable: Observable<AbstractMesh>;
  19692. /**
  19693. * Gets or sets the orientation for POV movement & rotation
  19694. */
  19695. definedFacingForward: boolean;
  19696. /**
  19697. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19698. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19699. * * 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.
  19700. * @see http://doc.babylonjs.com/features/occlusionquery
  19701. */
  19702. occlusionQueryAlgorithmType: number;
  19703. /**
  19704. * 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:
  19705. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19706. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19707. * * 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.
  19708. * @see http://doc.babylonjs.com/features/occlusionquery
  19709. */
  19710. occlusionType: number;
  19711. /**
  19712. * 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.
  19713. * The default value is -1 which means don't break the query and wait till the result
  19714. * @see http://doc.babylonjs.com/features/occlusionquery
  19715. */
  19716. occlusionRetryCount: number;
  19717. private _occlusionInternalRetryCounter;
  19718. protected _isOccluded: boolean;
  19719. /**
  19720. * 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
  19721. * @see http://doc.babylonjs.com/features/occlusionquery
  19722. */
  19723. isOccluded: boolean;
  19724. private _isOcclusionQueryInProgress;
  19725. /**
  19726. * Flag to check the progress status of the query
  19727. * @see http://doc.babylonjs.com/features/occlusionquery
  19728. */
  19729. readonly isOcclusionQueryInProgress: boolean;
  19730. private _occlusionQuery;
  19731. private _visibility;
  19732. /**
  19733. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19734. */
  19735. /**
  19736. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19737. */
  19738. visibility: number;
  19739. /** Gets or sets the alpha index used to sort transparent meshes
  19740. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19741. */
  19742. alphaIndex: number;
  19743. /**
  19744. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19745. */
  19746. isVisible: boolean;
  19747. /**
  19748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19749. */
  19750. isPickable: boolean;
  19751. /**
  19752. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  19753. */
  19754. showBoundingBox: boolean;
  19755. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19756. showSubMeshesBoundingBox: boolean;
  19757. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19758. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19759. */
  19760. isBlocker: boolean;
  19761. /**
  19762. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19763. */
  19764. enablePointerMoveEvents: boolean;
  19765. /**
  19766. * Specifies the rendering group id for this mesh (0 by default)
  19767. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19768. */
  19769. renderingGroupId: number;
  19770. private _material;
  19771. /** Gets or sets current material */
  19772. material: Nullable<Material>;
  19773. private _receiveShadows;
  19774. /**
  19775. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19776. * @see http://doc.babylonjs.com/babylon101/shadows
  19777. */
  19778. receiveShadows: boolean;
  19779. /**
  19780. * Gets or sets a boolean indicating if the outline must be rendered as well
  19781. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19782. */
  19783. renderOutline: boolean;
  19784. /** Defines color to use when rendering outline */
  19785. outlineColor: Color3;
  19786. /** Define width to use when rendering outline */
  19787. outlineWidth: number;
  19788. /**
  19789. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19790. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19791. */
  19792. renderOverlay: boolean;
  19793. /** Defines color to use when rendering overlay */
  19794. overlayColor: Color3;
  19795. /** Defines alpha to use when rendering overlay */
  19796. overlayAlpha: number;
  19797. private _hasVertexAlpha;
  19798. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19799. hasVertexAlpha: boolean;
  19800. private _useVertexColors;
  19801. /** 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) */
  19802. useVertexColors: boolean;
  19803. private _computeBonesUsingShaders;
  19804. /**
  19805. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19806. */
  19807. computeBonesUsingShaders: boolean;
  19808. private _numBoneInfluencers;
  19809. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19810. numBoneInfluencers: number;
  19811. private _applyFog;
  19812. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19813. applyFog: boolean;
  19814. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19815. useOctreeForRenderingSelection: boolean;
  19816. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19817. useOctreeForPicking: boolean;
  19818. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19819. useOctreeForCollisions: boolean;
  19820. private _layerMask;
  19821. /**
  19822. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19823. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19824. */
  19825. layerMask: number;
  19826. /**
  19827. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19828. */
  19829. alwaysSelectAsActiveMesh: boolean;
  19830. /**
  19831. * Gets or sets the current action manager
  19832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19833. */
  19834. actionManager: Nullable<ActionManager>;
  19835. /**
  19836. * Gets or sets impostor used for physic simulation
  19837. * @see http://doc.babylonjs.com/features/physics_engine
  19838. */
  19839. physicsImpostor: Nullable<PhysicsImpostor>;
  19840. private _checkCollisions;
  19841. private _collisionMask;
  19842. private _collisionGroup;
  19843. /**
  19844. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19846. */
  19847. ellipsoid: Vector3;
  19848. /**
  19849. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19850. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19851. */
  19852. ellipsoidOffset: Vector3;
  19853. private _collider;
  19854. private _oldPositionForCollisions;
  19855. private _diffPositionForCollisions;
  19856. /**
  19857. * Gets or sets a collision mask used to mask collisions (default is -1).
  19858. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19859. */
  19860. collisionMask: number;
  19861. /**
  19862. * Gets or sets the current collision group mask (-1 by default).
  19863. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19864. */
  19865. collisionGroup: number;
  19866. /**
  19867. * Defines edge width used when edgesRenderer is enabled
  19868. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19869. */
  19870. edgesWidth: number;
  19871. /**
  19872. * Defines edge color used when edgesRenderer is enabled
  19873. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19874. */
  19875. edgesColor: Color4;
  19876. /** @hidden */
  19877. private _collisionsTransformMatrix;
  19878. private _collisionsScalingMatrix;
  19879. /** @hidden */
  19880. /** @hidden */
  19881. /** @hidden */
  19882. /**
  19883. * Gets or sets the list of subMeshes
  19884. * @see http://doc.babylonjs.com/how_to/multi_materials
  19885. */
  19886. subMeshes: SubMesh[];
  19887. /** @hidden */
  19888. /** @hidden */
  19889. /** @hidden */
  19890. /** @hidden */
  19891. /** @hidden */
  19892. protected readonly _positions: Nullable<Vector3[]>;
  19893. /** @hidden */
  19894. /** @hidden */
  19895. private _skeleton;
  19896. /** @hidden */
  19897. /**
  19898. * Gets or sets a skeleton to apply skining transformations
  19899. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19900. */
  19901. skeleton: Nullable<Skeleton>;
  19902. /**
  19903. * Creates a new AbstractMesh
  19904. * @param name defines the name of the mesh
  19905. * @param scene defines the hosting scene
  19906. */
  19907. constructor(name: string, scene?: Nullable<Scene>);
  19908. /**
  19909. * Returns the string "AbstractMesh"
  19910. * @returns "AbstractMesh"
  19911. */
  19912. getClassName(): string;
  19913. /**
  19914. * Gets a string representation of the current mesh
  19915. * @param fullDetails defines a boolean indicating if full details must be included
  19916. * @returns a string representation of the current mesh
  19917. */
  19918. toString(fullDetails?: boolean): string;
  19919. /** @hidden */
  19920. /** @hidden */
  19921. /** @hidden */
  19922. /** @hidden */
  19923. /** @hidden */
  19924. private _markSubMeshesAsDirty(func);
  19925. /** @hidden */
  19926. /** @hidden */
  19927. /** @hidden */
  19928. /**
  19929. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19930. */
  19931. scaling: Vector3;
  19932. /**
  19933. * Disables the mesh edge rendering mode
  19934. * @returns the currentAbstractMesh
  19935. */
  19936. disableEdgesRendering(): AbstractMesh;
  19937. /**
  19938. * Enables the edge rendering mode on the mesh.
  19939. * This mode makes the mesh edges visible
  19940. * @param epsilon defines the maximal distance between two angles to detect a face
  19941. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19942. * @returns the currentAbstractMesh
  19943. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19944. */
  19945. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19946. /**
  19947. * Gets the edgesRenderer associated with the mesh
  19948. */
  19949. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19950. /**
  19951. * Returns true if the mesh is blocked. Implemented by child classes
  19952. */
  19953. readonly isBlocked: boolean;
  19954. /**
  19955. * Returns the mesh itself by default. Implemented by child classes
  19956. * @param camera defines the camera to use to pick the right LOD level
  19957. * @returns the currentAbstractMesh
  19958. */
  19959. getLOD(camera: Camera): AbstractMesh;
  19960. /**
  19961. * Returns 0 by default. Implemented by child classes
  19962. * @returns an integer
  19963. */
  19964. getTotalVertices(): number;
  19965. /**
  19966. * Returns null by default. Implemented by child classes
  19967. * @returns null
  19968. */
  19969. getIndices(): Nullable<IndicesArray>;
  19970. /**
  19971. * Returns the array of the requested vertex data kind. Implemented by child classes
  19972. * @param kind defines the vertex data kind to use
  19973. * @returns null
  19974. */
  19975. getVerticesData(kind: string): Nullable<FloatArray>;
  19976. /**
  19977. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19978. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19979. * Note that a new underlying VertexBuffer object is created each call.
  19980. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19981. * @param kind defines vertex data kind:
  19982. * * BABYLON.VertexBuffer.PositionKind
  19983. * * BABYLON.VertexBuffer.UVKind
  19984. * * BABYLON.VertexBuffer.UV2Kind
  19985. * * BABYLON.VertexBuffer.UV3Kind
  19986. * * BABYLON.VertexBuffer.UV4Kind
  19987. * * BABYLON.VertexBuffer.UV5Kind
  19988. * * BABYLON.VertexBuffer.UV6Kind
  19989. * * BABYLON.VertexBuffer.ColorKind
  19990. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19991. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19992. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19993. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19994. * @param data defines the data source
  19995. * @param updatable defines if the data must be flagged as updatable (or static)
  19996. * @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
  19997. * @returns the current mesh
  19998. */
  19999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20000. /**
  20001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20002. * If the mesh has no geometry, it is simply returned as it is.
  20003. * @param kind defines vertex data kind:
  20004. * * BABYLON.VertexBuffer.PositionKind
  20005. * * BABYLON.VertexBuffer.UVKind
  20006. * * BABYLON.VertexBuffer.UV2Kind
  20007. * * BABYLON.VertexBuffer.UV3Kind
  20008. * * BABYLON.VertexBuffer.UV4Kind
  20009. * * BABYLON.VertexBuffer.UV5Kind
  20010. * * BABYLON.VertexBuffer.UV6Kind
  20011. * * BABYLON.VertexBuffer.ColorKind
  20012. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20013. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20014. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20015. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20016. * @param data defines the data source
  20017. * @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
  20018. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  20019. * @returns the current mesh
  20020. */
  20021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  20022. /**
  20023. * Sets the mesh indices,
  20024. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20025. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20026. * @param totalVertices Defines the total number of vertices
  20027. * @returns the current mesh
  20028. */
  20029. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  20030. /**
  20031. * Gets a boolean indicating if specific vertex data is present
  20032. * @param kind defines the vertex data kind to use
  20033. * @returns true is data kind is present
  20034. */
  20035. isVerticesDataPresent(kind: string): boolean;
  20036. /**
  20037. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  20038. * @returns a BoundingInfo
  20039. */
  20040. getBoundingInfo(): BoundingInfo;
  20041. /**
  20042. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  20043. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  20044. * @returns the current mesh
  20045. */
  20046. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  20047. /**
  20048. * Overwrite the current bounding info
  20049. * @param boundingInfo defines the new bounding info
  20050. * @returns the current mesh
  20051. */
  20052. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  20053. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  20054. readonly useBones: boolean;
  20055. /** @hidden */
  20056. /** @hidden */
  20057. /** @hidden */
  20058. /**
  20059. * Gets the current world matrix
  20060. * @returns a Matrix
  20061. */
  20062. getWorldMatrix(): Matrix;
  20063. /** @hidden */
  20064. /**
  20065. * Perform relative position change from the point of view of behind the front of the mesh.
  20066. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20067. * Supports definition of mesh facing forward or backward
  20068. * @param amountRight defines the distance on the right axis
  20069. * @param amountUp defines the distance on the up axis
  20070. * @param amountForward defines the distance on the forward axis
  20071. * @returns the current mesh
  20072. */
  20073. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20074. /**
  20075. * Calculate relative position change from the point of view of behind the front of the mesh.
  20076. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20077. * Supports definition of mesh facing forward or backward
  20078. * @param amountRight defines the distance on the right axis
  20079. * @param amountUp defines the distance on the up axis
  20080. * @param amountForward defines the distance on the forward axis
  20081. * @returns the new displacement vector
  20082. */
  20083. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20084. /**
  20085. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20086. * Supports definition of mesh facing forward or backward
  20087. * @param flipBack defines the flip
  20088. * @param twirlClockwise defines the twirl
  20089. * @param tiltRight defines the tilt
  20090. * @returns the current mesh
  20091. */
  20092. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20093. /**
  20094. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20095. * Supports definition of mesh facing forward or backward.
  20096. * @param flipBack defines the flip
  20097. * @param twirlClockwise defines the twirl
  20098. * @param tiltRight defines the tilt
  20099. * @returns the new rotation vector
  20100. */
  20101. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20102. /**
  20103. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20104. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20105. * @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
  20106. * @returns the new bounding vectors
  20107. */
  20108. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20109. min: Vector3;
  20110. max: Vector3;
  20111. };
  20112. /** @hidden */
  20113. /** @hidden */
  20114. /** @hidden */
  20115. protected _afterComputeWorldMatrix(): void;
  20116. /**
  20117. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20118. * A mesh is in the frustum if its bounding box intersects the frustum
  20119. * @param frustumPlanes defines the frustum to test
  20120. * @returns true if the mesh is in the frustum planes
  20121. */
  20122. isInFrustum(frustumPlanes: Plane[]): boolean;
  20123. /**
  20124. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20125. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20126. * @param frustumPlanes defines the frustum to test
  20127. * @returns true if the mesh is completely in the frustum planes
  20128. */
  20129. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20130. /**
  20131. * True if the mesh intersects another mesh or a SolidParticle object
  20132. * @param mesh defines a target mesh or SolidParticle to test
  20133. * @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)
  20134. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20135. * @returns true if there is an intersection
  20136. */
  20137. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20138. /**
  20139. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20140. * @param point defines the point to test
  20141. * @returns true if there is an intersection
  20142. */
  20143. intersectsPoint(point: Vector3): boolean;
  20144. /**
  20145. * Gets the current physics impostor
  20146. * @see http://doc.babylonjs.com/features/physics_engine
  20147. * @returns a physics impostor or null
  20148. */
  20149. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20150. /**
  20151. * Gets the position of the current mesh in camera space
  20152. * @param camera defines the camera to use
  20153. * @returns a position
  20154. */
  20155. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20156. /**
  20157. * Returns the distance from the mesh to the active camera
  20158. * @param camera defines the camera to use
  20159. * @returns the distance
  20160. */
  20161. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20162. /**
  20163. * Apply a physic impulse to the mesh
  20164. * @param force defines the force to apply
  20165. * @param contactPoint defines where to apply the force
  20166. * @returns the current mesh
  20167. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20168. */
  20169. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20170. /**
  20171. * Creates a physic joint between two meshes
  20172. * @param otherMesh defines the other mesh to use
  20173. * @param pivot1 defines the pivot to use on this mesh
  20174. * @param pivot2 defines the pivot to use on the other mesh
  20175. * @param options defines additional options (can be plugin dependent)
  20176. * @returns the current mesh
  20177. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20178. */
  20179. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20180. /**
  20181. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20183. */
  20184. checkCollisions: boolean;
  20185. /**
  20186. * Gets Collider object used to compute collisions (not physics)
  20187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20188. */
  20189. readonly collider: Collider;
  20190. /**
  20191. * Move the mesh using collision engine
  20192. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20193. * @param displacement defines the requested displacement vector
  20194. * @returns the current mesh
  20195. */
  20196. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20197. private _onCollisionPositionChange;
  20198. /**
  20199. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  20200. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20201. * @param maxCapacity defines the maximum size of each block (64 by default)
  20202. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  20203. * @returns the new octree
  20204. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  20205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  20206. */
  20207. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  20208. /** @hidden */
  20209. /** @hidden */
  20210. /** @hidden */
  20211. /** @hidden */
  20212. /**
  20213. * Checks if the passed Ray intersects with the mesh
  20214. * @param ray defines the ray to use
  20215. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20216. * @returns the picking info
  20217. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20218. */
  20219. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20220. /**
  20221. * Clones the current mesh
  20222. * @param name defines the mesh name
  20223. * @param newParent defines the new mesh parent
  20224. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20225. * @returns the new mesh
  20226. */
  20227. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20228. /**
  20229. * Disposes all the submeshes of the current meshnp
  20230. * @returns the current mesh
  20231. */
  20232. releaseSubMeshes(): AbstractMesh;
  20233. /**
  20234. * Releases resources associated with this abstract mesh.
  20235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20237. */
  20238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20239. /**
  20240. * Adds the passed mesh as a child to the current mesh
  20241. * @param mesh defines the child mesh
  20242. * @returns the current mesh
  20243. */
  20244. addChild(mesh: AbstractMesh): AbstractMesh;
  20245. /**
  20246. * Removes the passed mesh from the current mesh children list
  20247. * @param mesh defines the child mesh
  20248. * @returns the current mesh
  20249. */
  20250. removeChild(mesh: AbstractMesh): AbstractMesh;
  20251. /** @hidden */
  20252. private _initFacetData();
  20253. /**
  20254. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20255. * This method can be called within the render loop.
  20256. * 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
  20257. * @returns the current mesh
  20258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20259. */
  20260. updateFacetData(): AbstractMesh;
  20261. /**
  20262. * Returns the facetLocalNormals array.
  20263. * The normals are expressed in the mesh local spac
  20264. * @returns an array of Vector3
  20265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20266. */
  20267. getFacetLocalNormals(): Vector3[];
  20268. /**
  20269. * Returns the facetLocalPositions array.
  20270. * The facet positions are expressed in the mesh local space
  20271. * @returns an array of Vector3
  20272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20273. */
  20274. getFacetLocalPositions(): Vector3[];
  20275. /**
  20276. * Returns the facetLocalPartioning array
  20277. * @returns an array of array of numbers
  20278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20279. */
  20280. getFacetLocalPartitioning(): number[][];
  20281. /**
  20282. * Returns the i-th facet position in the world system.
  20283. * This method allocates a new Vector3 per call
  20284. * @param i defines the facet index
  20285. * @returns a new Vector3
  20286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20287. */
  20288. getFacetPosition(i: number): Vector3;
  20289. /**
  20290. * Sets the reference Vector3 with the i-th facet position in the world system
  20291. * @param i defines the facet index
  20292. * @param ref defines the target vector
  20293. * @returns the current mesh
  20294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20295. */
  20296. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20297. /**
  20298. * Returns the i-th facet normal in the world system.
  20299. * This method allocates a new Vector3 per call
  20300. * @param i defines the facet index
  20301. * @returns a new Vector3
  20302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20303. */
  20304. getFacetNormal(i: number): Vector3;
  20305. /**
  20306. * Sets the reference Vector3 with the i-th facet normal in the world system
  20307. * @param i defines the facet index
  20308. * @param ref defines the target vector
  20309. * @returns the current mesh
  20310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20311. */
  20312. getFacetNormalToRef(i: number, ref: Vector3): this;
  20313. /**
  20314. * 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)
  20315. * @param x defines x coordinate
  20316. * @param y defines y coordinate
  20317. * @param z defines z coordinate
  20318. * @returns the array of facet indexes
  20319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20320. */
  20321. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20322. /**
  20323. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20324. * @param projected sets as the (x,y,z) world projection on the facet
  20325. * @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
  20326. * @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
  20327. * @param x defines x coordinate
  20328. * @param y defines y coordinate
  20329. * @param z defines z coordinate
  20330. * @returns the face index if found (or null instead)
  20331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20332. */
  20333. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20334. /**
  20335. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20336. * @param projected sets as the (x,y,z) local projection on the facet
  20337. * @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
  20338. * @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
  20339. * @param x defines x coordinate
  20340. * @param y defines y coordinate
  20341. * @param z defines z coordinate
  20342. * @returns the face index if found (or null instead)
  20343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20344. */
  20345. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20346. /**
  20347. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20348. * @returns the parameters
  20349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20350. */
  20351. getFacetDataParameters(): any;
  20352. /**
  20353. * Disables the feature FacetData and frees the related memory
  20354. * @returns the current mesh
  20355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20356. */
  20357. disableFacetData(): AbstractMesh;
  20358. /**
  20359. * Updates the AbstractMesh indices array
  20360. * @param indices defines the data source
  20361. * @returns the current mesh
  20362. */
  20363. updateIndices(indices: IndicesArray): AbstractMesh;
  20364. /**
  20365. * Creates new normals data for the mesh
  20366. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20367. * @returns the current mesh
  20368. */
  20369. createNormals(updatable: boolean): AbstractMesh;
  20370. /**
  20371. * Align the mesh with a normal
  20372. * @param normal defines the normal to use
  20373. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20374. * @returns the current mesh
  20375. */
  20376. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20377. /** @hidden */
  20378. protected _checkOcclusionQuery(): void;
  20379. }
  20380. }
  20381. declare module BABYLON {
  20382. class Buffer {
  20383. private _engine;
  20384. private _buffer;
  20385. /** @hidden */
  20386. private _updatable;
  20387. private _instanced;
  20388. /**
  20389. * Gets the byte stride.
  20390. */
  20391. readonly byteStride: number;
  20392. /**
  20393. * Constructor
  20394. * @param engine the engine
  20395. * @param data the data to use for this buffer
  20396. * @param updatable whether the data is updatable
  20397. * @param stride the stride (optional)
  20398. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20399. * @param instanced whether the buffer is instanced (optional)
  20400. * @param useBytes set to true if the stride in in bytes (optional)
  20401. */
  20402. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20403. /**
  20404. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20405. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20406. * @param offset defines offset in the buffer (0 by default)
  20407. * @param size defines the size in floats of attributes (position is 3 for instance)
  20408. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20409. * @param instanced defines if the vertex buffer contains indexed data
  20410. * @param useBytes defines if the offset and stride are in bytes
  20411. * @returns the new vertex buffer
  20412. */
  20413. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20414. isUpdatable(): boolean;
  20415. getData(): Nullable<DataArray>;
  20416. getBuffer(): Nullable<WebGLBuffer>;
  20417. /**
  20418. * Gets the stride in float32 units (i.e. byte stride / 4).
  20419. * May not be an integer if the byte stride is not divisible by 4.
  20420. * DEPRECATED. Use byteStride instead.
  20421. * @returns the stride in float32 units
  20422. */
  20423. getStrideSize(): number;
  20424. create(data?: Nullable<DataArray>): void;
  20425. update(data: DataArray): void;
  20426. /**
  20427. * Updates the data directly.
  20428. * @param data the new data
  20429. * @param offset the new offset
  20430. * @param vertexCount the vertex count (optional)
  20431. * @param useBytes set to true if the offset is in bytes
  20432. */
  20433. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20434. dispose(): void;
  20435. }
  20436. }
  20437. declare module BABYLON {
  20438. class CSG {
  20439. private polygons;
  20440. matrix: Matrix;
  20441. position: Vector3;
  20442. rotation: Vector3;
  20443. rotationQuaternion: Nullable<Quaternion>;
  20444. scaling: Vector3;
  20445. static FromMesh(mesh: Mesh): CSG;
  20446. private static FromPolygons(polygons);
  20447. clone(): CSG;
  20448. union(csg: CSG): CSG;
  20449. unionInPlace(csg: CSG): void;
  20450. subtract(csg: CSG): CSG;
  20451. subtractInPlace(csg: CSG): void;
  20452. intersect(csg: CSG): CSG;
  20453. intersectInPlace(csg: CSG): void;
  20454. inverse(): CSG;
  20455. inverseInPlace(): void;
  20456. copyTransformAttributes(csg: CSG): CSG;
  20457. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20458. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20459. }
  20460. }
  20461. declare module BABYLON {
  20462. /**
  20463. * Class used to store geometry data (vertex buffers + index buffer)
  20464. */
  20465. class Geometry implements IGetSetVerticesData {
  20466. /**
  20467. * Gets or sets the unique ID of the geometry
  20468. */
  20469. id: string;
  20470. /**
  20471. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20472. */
  20473. delayLoadState: number;
  20474. /**
  20475. * Gets the file containing the data to load when running in delay load state
  20476. */
  20477. delayLoadingFile: Nullable<string>;
  20478. /**
  20479. * Callback called when the geometry is updated
  20480. */
  20481. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20482. private _scene;
  20483. private _engine;
  20484. private _meshes;
  20485. private _totalVertices;
  20486. /** @hidden */
  20487. /** @hidden */
  20488. ;
  20489. private _isDisposed;
  20490. private _extend;
  20491. private _boundingBias;
  20492. /** @hidden */
  20493. private _indexBuffer;
  20494. private _indexBufferIsUpdatable;
  20495. /** @hidden */
  20496. /** @hidden */
  20497. /** @hidden */
  20498. private _vertexArrayObjects;
  20499. private _updatable;
  20500. /** @hidden */
  20501. /**
  20502. * 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
  20503. */
  20504. /**
  20505. * 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
  20506. */
  20507. boundingBias: Vector2;
  20508. /**
  20509. * Static function used to attach a new empty geometry to a mesh
  20510. * @param mesh defines the mesh to attach the geometry to
  20511. * @returns the new {BABYLON.Geometry}
  20512. */
  20513. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20514. /**
  20515. * Creates a new geometry
  20516. * @param id defines the unique ID
  20517. * @param scene defines the hosting scene
  20518. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20519. * @param updatable defines if geometry must be updatable (false by default)
  20520. * @param mesh defines the mesh that will be associated with the geometry
  20521. */
  20522. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20523. /**
  20524. * Gets the current extend of the geometry
  20525. */
  20526. readonly extend: {
  20527. minimum: Vector3;
  20528. maximum: Vector3;
  20529. };
  20530. /**
  20531. * Gets the hosting scene
  20532. * @returns the hosting {BABYLON.Scene}
  20533. */
  20534. getScene(): Scene;
  20535. /**
  20536. * Gets the hosting engine
  20537. * @returns the hosting {BABYLON.Engine}
  20538. */
  20539. getEngine(): Engine;
  20540. /**
  20541. * Defines if the geometry is ready to use
  20542. * @returns true if the geometry is ready to be used
  20543. */
  20544. isReady(): boolean;
  20545. /**
  20546. * Gets a value indicating that the geometry should not be serialized
  20547. */
  20548. readonly doNotSerialize: boolean;
  20549. /** @hidden */
  20550. /**
  20551. * Affects all gemetry data in one call
  20552. * @param vertexData defines the geometry data
  20553. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20554. */
  20555. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20556. /**
  20557. * Set specific vertex data
  20558. * @param kind defines the data kind (Position, normal, etc...)
  20559. * @param data defines the vertex data to use
  20560. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20561. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20562. */
  20563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20564. /**
  20565. * Removes a specific vertex data
  20566. * @param kind defines the data kind (Position, normal, etc...)
  20567. */
  20568. removeVerticesData(kind: string): void;
  20569. /**
  20570. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20571. * @param buffer defines the vertex buffer to use
  20572. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20573. */
  20574. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20575. /**
  20576. * Update a specific vertex buffer
  20577. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20578. * It will do nothing if the buffer is not updatable
  20579. * @param kind defines the data kind (Position, normal, etc...)
  20580. * @param data defines the data to use
  20581. * @param offset defines the offset in the target buffer where to store the data
  20582. * @param useBytes set to true if the offset is in bytes
  20583. */
  20584. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20585. /**
  20586. * Update a specific vertex buffer
  20587. * This function will create a new buffer if the current one is not updatable
  20588. * @param kind defines the data kind (Position, normal, etc...)
  20589. * @param data defines the data to use
  20590. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20591. */
  20592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20593. private _updateBoundingInfo(updateExtends, data);
  20594. /** @hidden */
  20595. /**
  20596. * Gets total number of vertices
  20597. * @returns the total number of vertices
  20598. */
  20599. getTotalVertices(): number;
  20600. /**
  20601. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20602. * @param kind defines the data kind (Position, normal, etc...)
  20603. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20604. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20605. * @returns a float array containing vertex data
  20606. */
  20607. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20608. /**
  20609. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20610. * @param kind defines the data kind (Position, normal, etc...)
  20611. * @returns true if the vertex buffer with the specified kind is updatable
  20612. */
  20613. isVertexBufferUpdatable(kind: string): boolean;
  20614. /**
  20615. * Gets a specific vertex buffer
  20616. * @param kind defines the data kind (Position, normal, etc...)
  20617. * @returns a {BABYLON.VertexBuffer}
  20618. */
  20619. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20620. /**
  20621. * Returns all vertex buffers
  20622. * @return an object holding all vertex buffers indexed by kind
  20623. */
  20624. getVertexBuffers(): Nullable<{
  20625. [key: string]: VertexBuffer;
  20626. }>;
  20627. /**
  20628. * Gets a boolean indicating if specific vertex buffer is present
  20629. * @param kind defines the data kind (Position, normal, etc...)
  20630. * @returns true if data is present
  20631. */
  20632. isVerticesDataPresent(kind: string): boolean;
  20633. /**
  20634. * Gets a list of all attached data kinds (Position, normal, etc...)
  20635. * @returns a list of string containing all kinds
  20636. */
  20637. getVerticesDataKinds(): string[];
  20638. /**
  20639. * Update index buffer
  20640. * @param indices defines the indices to store in the index buffer
  20641. * @param offset defines the offset in the target buffer where to store the data
  20642. */
  20643. updateIndices(indices: IndicesArray, offset?: number): void;
  20644. /**
  20645. * Creates a new index buffer
  20646. * @param indices defines the indices to store in the index buffer
  20647. * @param totalVertices defines the total number of vertices (could be null)
  20648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20649. */
  20650. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20651. /**
  20652. * Return the total number of indices
  20653. * @returns the total number of indices
  20654. */
  20655. getTotalIndices(): number;
  20656. /**
  20657. * Gets the index buffer array
  20658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20659. * @returns the index buffer array
  20660. */
  20661. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20662. /**
  20663. * Gets the index buffer
  20664. * @return the index buffer
  20665. */
  20666. getIndexBuffer(): Nullable<WebGLBuffer>;
  20667. /** @hidden */
  20668. /**
  20669. * Release the associated resources for a specific mesh
  20670. * @param mesh defines the source mesh
  20671. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20672. */
  20673. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20674. /**
  20675. * Apply current geometry to a given mesh
  20676. * @param mesh defines the mesh to apply geometry to
  20677. */
  20678. applyToMesh(mesh: Mesh): void;
  20679. private _updateExtend(data?);
  20680. private _applyToMesh(mesh);
  20681. private notifyUpdate(kind?);
  20682. /**
  20683. * Load the geometry if it was flagged as delay loaded
  20684. * @param scene defines the hosting scene
  20685. * @param onLoaded defines a callback called when the geometry is loaded
  20686. */
  20687. load(scene: Scene, onLoaded?: () => void): void;
  20688. private _queueLoad(scene, onLoaded?);
  20689. /**
  20690. * Invert the geometry to move from a right handed system to a left handed one.
  20691. */
  20692. toLeftHanded(): void;
  20693. /** @hidden */
  20694. /** @hidden */
  20695. /**
  20696. * Gets a value indicating if the geometry is disposed
  20697. * @returns true if the geometry was disposed
  20698. */
  20699. isDisposed(): boolean;
  20700. private _disposeVertexArrayObjects();
  20701. /**
  20702. * Free all associated resources
  20703. */
  20704. dispose(): void;
  20705. /**
  20706. * Clone the current geometry into a new geometry
  20707. * @param id defines the unique ID of the new geometry
  20708. * @returns a new geometry object
  20709. */
  20710. copy(id: string): Geometry;
  20711. /**
  20712. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20713. * @return a JSON representation of the current geometry data (without the vertices data)
  20714. */
  20715. serialize(): any;
  20716. private toNumberArray(origin);
  20717. /**
  20718. * Serialize all vertices data into a JSON oject
  20719. * @returns a JSON representation of the current geometry data
  20720. */
  20721. serializeVerticeData(): any;
  20722. /**
  20723. * Extracts a clone of a mesh geometry
  20724. * @param mesh defines the source mesh
  20725. * @param id defines the unique ID of the new geometry object
  20726. * @returns the new geometry object
  20727. */
  20728. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20729. /**
  20730. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20731. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20732. * Be aware Math.random() could cause collisions, but:
  20733. * "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"
  20734. * @returns a string containing a new GUID
  20735. */
  20736. static RandomId(): string;
  20737. /** @hidden */
  20738. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20739. private static _CleanMatricesWeights(parsedGeometry, mesh);
  20740. /**
  20741. * Create a new geometry from persisted data (Using .babylon file format)
  20742. * @param parsedVertexData defines the persisted data
  20743. * @param scene defines the hosting scene
  20744. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20745. * @returns the new geometry object
  20746. */
  20747. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20748. }
  20749. /**
  20750. * Abstract class used to provide common services for all typed geometries
  20751. * @hidden
  20752. */
  20753. class _PrimitiveGeometry extends Geometry {
  20754. private _canBeRegenerated;
  20755. private _beingRegenerated;
  20756. /**
  20757. * Creates a new typed geometry
  20758. * @param id defines the unique ID of the geometry
  20759. * @param scene defines the hosting scene
  20760. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20761. * @param mesh defines the hosting mesh (can be null)
  20762. */
  20763. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20764. /**
  20765. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20766. * @returns true if the geometry can be regenerated
  20767. */
  20768. canBeRegenerated(): boolean;
  20769. /**
  20770. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20771. */
  20772. regenerate(): void;
  20773. /**
  20774. * Clone the geometry
  20775. * @param id defines the unique ID of the new geometry
  20776. * @returns the new geometry
  20777. */
  20778. asNewGeometry(id: string): Geometry;
  20779. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20780. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20781. /** @hidden */
  20782. copy(id: string): Geometry;
  20783. serialize(): any;
  20784. }
  20785. /**
  20786. * Creates a ribbon geometry
  20787. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20788. */
  20789. class RibbonGeometry extends _PrimitiveGeometry {
  20790. /**
  20791. * Defines the array of paths to use
  20792. */
  20793. pathArray: Vector3[][];
  20794. /**
  20795. * Defines if the last and first points of each path in your pathArray must be joined
  20796. */
  20797. closeArray: boolean;
  20798. /**
  20799. * Defines if the last and first points of each path in your pathArray must be joined
  20800. */
  20801. closePath: boolean;
  20802. /**
  20803. * Defines the offset between points
  20804. */
  20805. offset: number;
  20806. /**
  20807. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20808. */
  20809. side: number;
  20810. /**
  20811. * Creates a ribbon geometry
  20812. * @param id defines the unique ID of the geometry
  20813. * @param scene defines the hosting scene
  20814. * @param pathArray defines the array of paths to use
  20815. * @param closeArray defines if the last path and the first path must be joined
  20816. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20817. * @param offset defines the offset between points
  20818. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20819. * @param mesh defines the hosting mesh (can be null)
  20820. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20821. */
  20822. constructor(id: string, scene: Scene,
  20823. /**
  20824. * Defines the array of paths to use
  20825. */
  20826. pathArray: Vector3[][],
  20827. /**
  20828. * Defines if the last and first points of each path in your pathArray must be joined
  20829. */
  20830. closeArray: boolean,
  20831. /**
  20832. * Defines if the last and first points of each path in your pathArray must be joined
  20833. */
  20834. closePath: boolean,
  20835. /**
  20836. * Defines the offset between points
  20837. */
  20838. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20839. /**
  20840. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20841. */
  20842. side?: number);
  20843. /** @hidden */
  20844. copy(id: string): Geometry;
  20845. }
  20846. /**
  20847. * Creates a box geometry
  20848. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20849. */
  20850. class BoxGeometry extends _PrimitiveGeometry {
  20851. /**
  20852. * Defines the zise of the box (width, height and depth are the same)
  20853. */
  20854. size: number;
  20855. /**
  20856. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20857. */
  20858. side: number;
  20859. /**
  20860. * Creates a box geometry
  20861. * @param id defines the unique ID of the geometry
  20862. * @param scene defines the hosting scene
  20863. * @param size defines the zise of the box (width, height and depth are the same)
  20864. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20865. * @param mesh defines the hosting mesh (can be null)
  20866. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20867. */
  20868. constructor(id: string, scene: Scene,
  20869. /**
  20870. * Defines the zise of the box (width, height and depth are the same)
  20871. */
  20872. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20873. /**
  20874. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20875. */
  20876. side?: number);
  20877. copy(id: string): Geometry;
  20878. serialize(): any;
  20879. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20880. }
  20881. /**
  20882. * Creates a sphere geometry
  20883. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20884. */
  20885. class SphereGeometry extends _PrimitiveGeometry {
  20886. /**
  20887. * Defines the number of segments to use to create the sphere
  20888. */
  20889. segments: number;
  20890. /**
  20891. * Defines the diameter of the sphere
  20892. */
  20893. diameter: number;
  20894. /**
  20895. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20896. */
  20897. side: number;
  20898. /**
  20899. * Create a new sphere geometry
  20900. * @param id defines the unique ID of the geometry
  20901. * @param scene defines the hosting scene
  20902. * @param segments defines the number of segments to use to create the sphere
  20903. * @param diameter defines the diameter of the sphere
  20904. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20905. * @param mesh defines the hosting mesh (can be null)
  20906. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20907. */
  20908. constructor(id: string, scene: Scene,
  20909. /**
  20910. * Defines the number of segments to use to create the sphere
  20911. */
  20912. segments: number,
  20913. /**
  20914. * Defines the diameter of the sphere
  20915. */
  20916. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20917. /**
  20918. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20919. */
  20920. side?: number);
  20921. copy(id: string): Geometry;
  20922. serialize(): any;
  20923. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20924. }
  20925. /**
  20926. * Creates a disc geometry
  20927. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20928. */
  20929. class DiscGeometry extends _PrimitiveGeometry {
  20930. /**
  20931. * Defines the radius of the disc
  20932. */
  20933. radius: number;
  20934. /**
  20935. * Defines the tesselation factor to apply to the disc
  20936. */
  20937. tessellation: number;
  20938. /**
  20939. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20940. */
  20941. side: number;
  20942. /**
  20943. * Creates a new disc geometry
  20944. * @param id defines the unique ID of the geometry
  20945. * @param scene defines the hosting scene
  20946. * @param radius defines the radius of the disc
  20947. * @param tessellation defines the tesselation factor to apply to the disc
  20948. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20949. * @param mesh defines the hosting mesh (can be null)
  20950. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20951. */
  20952. constructor(id: string, scene: Scene,
  20953. /**
  20954. * Defines the radius of the disc
  20955. */
  20956. radius: number,
  20957. /**
  20958. * Defines the tesselation factor to apply to the disc
  20959. */
  20960. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20961. /**
  20962. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20963. */
  20964. side?: number);
  20965. copy(id: string): Geometry;
  20966. }
  20967. /**
  20968. * Creates a new cylinder geometry
  20969. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20970. */
  20971. class CylinderGeometry extends _PrimitiveGeometry {
  20972. /**
  20973. * Defines the height of the cylinder
  20974. */
  20975. height: number;
  20976. /**
  20977. * Defines the diameter of the cylinder's top cap
  20978. */
  20979. diameterTop: number;
  20980. /**
  20981. * Defines the diameter of the cylinder's bottom cap
  20982. */
  20983. diameterBottom: number;
  20984. /**
  20985. * Defines the tessellation factor to apply to the cylinder
  20986. */
  20987. tessellation: number;
  20988. /**
  20989. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20990. */
  20991. subdivisions: number;
  20992. /**
  20993. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20994. */
  20995. side: number;
  20996. /**
  20997. * Creates a new cylinder geometry
  20998. * @param id defines the unique ID of the geometry
  20999. * @param scene defines the hosting scene
  21000. * @param height defines the height of the cylinder
  21001. * @param diameterTop defines the diameter of the cylinder's top cap
  21002. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  21003. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  21004. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  21005. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21006. * @param mesh defines the hosting mesh (can be null)
  21007. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21008. */
  21009. constructor(id: string, scene: Scene,
  21010. /**
  21011. * Defines the height of the cylinder
  21012. */
  21013. height: number,
  21014. /**
  21015. * Defines the diameter of the cylinder's top cap
  21016. */
  21017. diameterTop: number,
  21018. /**
  21019. * Defines the diameter of the cylinder's bottom cap
  21020. */
  21021. diameterBottom: number,
  21022. /**
  21023. * Defines the tessellation factor to apply to the cylinder
  21024. */
  21025. tessellation: number,
  21026. /**
  21027. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21028. */
  21029. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21030. /**
  21031. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21032. */
  21033. side?: number);
  21034. copy(id: string): Geometry;
  21035. serialize(): any;
  21036. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21037. }
  21038. /**
  21039. * Creates a new torus geometry
  21040. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21041. */
  21042. class TorusGeometry extends _PrimitiveGeometry {
  21043. /**
  21044. * Defines the diameter of the torus
  21045. */
  21046. diameter: number;
  21047. /**
  21048. * Defines the thickness of the torus (ie. internal diameter)
  21049. */
  21050. thickness: number;
  21051. /**
  21052. * Defines the tesselation factor to apply to the torus
  21053. */
  21054. tessellation: number;
  21055. /**
  21056. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21057. */
  21058. side: number;
  21059. /**
  21060. * Creates a new torus geometry
  21061. * @param id defines the unique ID of the geometry
  21062. * @param scene defines the hosting scene
  21063. * @param diameter defines the diameter of the torus
  21064. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21065. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21066. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21067. * @param mesh defines the hosting mesh (can be null)
  21068. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21069. */
  21070. constructor(id: string, scene: Scene,
  21071. /**
  21072. * Defines the diameter of the torus
  21073. */
  21074. diameter: number,
  21075. /**
  21076. * Defines the thickness of the torus (ie. internal diameter)
  21077. */
  21078. thickness: number,
  21079. /**
  21080. * Defines the tesselation factor to apply to the torus
  21081. */
  21082. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21083. /**
  21084. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21085. */
  21086. side?: number);
  21087. copy(id: string): Geometry;
  21088. serialize(): any;
  21089. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21090. }
  21091. /**
  21092. * Creates a new ground geometry
  21093. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21094. */
  21095. class GroundGeometry extends _PrimitiveGeometry {
  21096. /**
  21097. * Defines the width of the ground
  21098. */
  21099. width: number;
  21100. /**
  21101. * Defines the height of the ground
  21102. */
  21103. height: number;
  21104. /**
  21105. * Defines the subdivisions to apply to the ground
  21106. */
  21107. subdivisions: number;
  21108. /**
  21109. * Creates a new ground geometry
  21110. * @param id defines the unique ID of the geometry
  21111. * @param scene defines the hosting scene
  21112. * @param width defines the width of the ground
  21113. * @param height defines the height of the ground
  21114. * @param subdivisions defines the subdivisions to apply to the ground
  21115. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21116. * @param mesh defines the hosting mesh (can be null)
  21117. */
  21118. constructor(id: string, scene: Scene,
  21119. /**
  21120. * Defines the width of the ground
  21121. */
  21122. width: number,
  21123. /**
  21124. * Defines the height of the ground
  21125. */
  21126. height: number,
  21127. /**
  21128. * Defines the subdivisions to apply to the ground
  21129. */
  21130. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21131. copy(id: string): Geometry;
  21132. serialize(): any;
  21133. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21134. }
  21135. /**
  21136. * Creates a tiled ground geometry
  21137. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21138. */
  21139. class TiledGroundGeometry extends _PrimitiveGeometry {
  21140. /**
  21141. * Defines the minimum value on X axis
  21142. */
  21143. xmin: number;
  21144. /**
  21145. * Defines the minimum value on Z axis
  21146. */
  21147. zmin: number;
  21148. /**
  21149. * Defines the maximum value on X axis
  21150. */
  21151. xmax: number;
  21152. /**
  21153. * Defines the maximum value on Z axis
  21154. */
  21155. zmax: number;
  21156. /**
  21157. * Defines the subdivisions to apply to the ground
  21158. */
  21159. subdivisions: {
  21160. w: number;
  21161. h: number;
  21162. };
  21163. /**
  21164. * Defines the precision to use when computing the tiles
  21165. */
  21166. precision: {
  21167. w: number;
  21168. h: number;
  21169. };
  21170. /**
  21171. * Creates a tiled ground geometry
  21172. * @param id defines the unique ID of the geometry
  21173. * @param scene defines the hosting scene
  21174. * @param xmin defines the minimum value on X axis
  21175. * @param zmin defines the minimum value on Z axis
  21176. * @param xmax defines the maximum value on X axis
  21177. * @param zmax defines the maximum value on Z axis
  21178. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21179. * @param precision defines the precision to use when computing the tiles
  21180. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21181. * @param mesh defines the hosting mesh (can be null)
  21182. */
  21183. constructor(id: string, scene: Scene,
  21184. /**
  21185. * Defines the minimum value on X axis
  21186. */
  21187. xmin: number,
  21188. /**
  21189. * Defines the minimum value on Z axis
  21190. */
  21191. zmin: number,
  21192. /**
  21193. * Defines the maximum value on X axis
  21194. */
  21195. xmax: number,
  21196. /**
  21197. * Defines the maximum value on Z axis
  21198. */
  21199. zmax: number,
  21200. /**
  21201. * Defines the subdivisions to apply to the ground
  21202. */
  21203. subdivisions: {
  21204. w: number;
  21205. h: number;
  21206. },
  21207. /**
  21208. * Defines the precision to use when computing the tiles
  21209. */
  21210. precision: {
  21211. w: number;
  21212. h: number;
  21213. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21214. copy(id: string): Geometry;
  21215. }
  21216. /**
  21217. * Creates a plane geometry
  21218. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21219. */
  21220. class PlaneGeometry extends _PrimitiveGeometry {
  21221. /**
  21222. * Defines the size of the plane (width === height)
  21223. */
  21224. size: number;
  21225. /**
  21226. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21227. */
  21228. side: number;
  21229. /**
  21230. * Creates a plane geometry
  21231. * @param id defines the unique ID of the geometry
  21232. * @param scene defines the hosting scene
  21233. * @param size defines the size of the plane (width === height)
  21234. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21235. * @param mesh defines the hosting mesh (can be null)
  21236. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21237. */
  21238. constructor(id: string, scene: Scene,
  21239. /**
  21240. * Defines the size of the plane (width === height)
  21241. */
  21242. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21243. /**
  21244. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21245. */
  21246. side?: number);
  21247. copy(id: string): Geometry;
  21248. serialize(): any;
  21249. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21250. }
  21251. /**
  21252. * Creates a torus knot geometry
  21253. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21254. */
  21255. class TorusKnotGeometry extends _PrimitiveGeometry {
  21256. /**
  21257. * Defines the radius of the torus knot
  21258. */
  21259. radius: number;
  21260. /**
  21261. * Defines the thickness of the torus knot tube
  21262. */
  21263. tube: number;
  21264. /**
  21265. * Defines the number of radial segments
  21266. */
  21267. radialSegments: number;
  21268. /**
  21269. * Defines the number of tubular segments
  21270. */
  21271. tubularSegments: number;
  21272. /**
  21273. * Defines the first number of windings
  21274. */
  21275. p: number;
  21276. /**
  21277. * Defines the second number of windings
  21278. */
  21279. q: number;
  21280. /**
  21281. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21282. */
  21283. side: number;
  21284. /**
  21285. * Creates a torus knot geometry
  21286. * @param id defines the unique ID of the geometry
  21287. * @param scene defines the hosting scene
  21288. * @param radius defines the radius of the torus knot
  21289. * @param tube defines the thickness of the torus knot tube
  21290. * @param radialSegments defines the number of radial segments
  21291. * @param tubularSegments defines the number of tubular segments
  21292. * @param p defines the first number of windings
  21293. * @param q defines the second number of windings
  21294. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21295. * @param mesh defines the hosting mesh (can be null)
  21296. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21297. */
  21298. constructor(id: string, scene: Scene,
  21299. /**
  21300. * Defines the radius of the torus knot
  21301. */
  21302. radius: number,
  21303. /**
  21304. * Defines the thickness of the torus knot tube
  21305. */
  21306. tube: number,
  21307. /**
  21308. * Defines the number of radial segments
  21309. */
  21310. radialSegments: number,
  21311. /**
  21312. * Defines the number of tubular segments
  21313. */
  21314. tubularSegments: number,
  21315. /**
  21316. * Defines the first number of windings
  21317. */
  21318. p: number,
  21319. /**
  21320. * Defines the second number of windings
  21321. */
  21322. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21323. /**
  21324. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21325. */
  21326. side?: number);
  21327. copy(id: string): Geometry;
  21328. serialize(): any;
  21329. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21330. }
  21331. }
  21332. declare module BABYLON {
  21333. class GroundMesh extends Mesh {
  21334. generateOctree: boolean;
  21335. private _heightQuads;
  21336. constructor(name: string, scene: Scene);
  21337. getClassName(): string;
  21338. readonly subdivisions: number;
  21339. readonly subdivisionsX: number;
  21340. readonly subdivisionsY: number;
  21341. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21342. /**
  21343. * Returns a height (y) value in the Worl system :
  21344. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21345. * Returns the ground y position if (x, z) are outside the ground surface.
  21346. */
  21347. getHeightAtCoordinates(x: number, z: number): number;
  21348. /**
  21349. * Returns a normalized vector (Vector3) orthogonal to the ground
  21350. * at the ground coordinates (x, z) expressed in the World system.
  21351. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21352. */
  21353. getNormalAtCoordinates(x: number, z: number): Vector3;
  21354. /**
  21355. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21356. * at the ground coordinates (x, z) expressed in the World system.
  21357. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21358. * Returns the GroundMesh.
  21359. */
  21360. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21361. /**
  21362. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21363. * if the ground has been updated.
  21364. * This can be used in the render loop.
  21365. * Returns the GroundMesh.
  21366. */
  21367. updateCoordinateHeights(): GroundMesh;
  21368. private _getFacetAt(x, z);
  21369. private _initHeightQuads();
  21370. private _computeHeightQuads();
  21371. serialize(serializationObject: any): void;
  21372. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21373. }
  21374. }
  21375. declare module BABYLON {
  21376. /**
  21377. * Creates an instance based on a source mesh.
  21378. */
  21379. class InstancedMesh extends AbstractMesh {
  21380. private _sourceMesh;
  21381. private _currentLOD;
  21382. constructor(name: string, source: Mesh);
  21383. /**
  21384. * Returns the string "InstancedMesh".
  21385. */
  21386. getClassName(): string;
  21387. readonly receiveShadows: boolean;
  21388. readonly material: Nullable<Material>;
  21389. readonly visibility: number;
  21390. readonly skeleton: Nullable<Skeleton>;
  21391. renderingGroupId: number;
  21392. /**
  21393. * Returns the total number of vertices (integer).
  21394. */
  21395. getTotalVertices(): number;
  21396. readonly sourceMesh: Mesh;
  21397. /**
  21398. * Is this node ready to be used/rendered
  21399. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21400. * @return {boolean} is it ready
  21401. */
  21402. isReady(completeCheck?: boolean): boolean;
  21403. /**
  21404. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21405. */
  21406. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21407. /**
  21408. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21409. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21410. * The `data` are either a numeric array either a Float32Array.
  21411. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21412. * 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).
  21413. * Note that a new underlying VertexBuffer object is created each call.
  21414. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21415. *
  21416. * Possible `kind` values :
  21417. * - BABYLON.VertexBuffer.PositionKind
  21418. * - BABYLON.VertexBuffer.UVKind
  21419. * - BABYLON.VertexBuffer.UV2Kind
  21420. * - BABYLON.VertexBuffer.UV3Kind
  21421. * - BABYLON.VertexBuffer.UV4Kind
  21422. * - BABYLON.VertexBuffer.UV5Kind
  21423. * - BABYLON.VertexBuffer.UV6Kind
  21424. * - BABYLON.VertexBuffer.ColorKind
  21425. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21426. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21427. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21428. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21429. *
  21430. * Returns the Mesh.
  21431. */
  21432. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21433. /**
  21434. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21435. * If the mesh has no geometry, it is simply returned as it is.
  21436. * The `data` are either a numeric array either a Float32Array.
  21437. * No new underlying VertexBuffer object is created.
  21438. * 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.
  21439. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21440. *
  21441. * Possible `kind` values :
  21442. * - BABYLON.VertexBuffer.PositionKind
  21443. * - BABYLON.VertexBuffer.UVKind
  21444. * - BABYLON.VertexBuffer.UV2Kind
  21445. * - BABYLON.VertexBuffer.UV3Kind
  21446. * - BABYLON.VertexBuffer.UV4Kind
  21447. * - BABYLON.VertexBuffer.UV5Kind
  21448. * - BABYLON.VertexBuffer.UV6Kind
  21449. * - BABYLON.VertexBuffer.ColorKind
  21450. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21451. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21452. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21453. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21454. *
  21455. * Returns the Mesh.
  21456. */
  21457. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21458. /**
  21459. * Sets the mesh indices.
  21460. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21461. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21462. * This method creates a new index buffer each call.
  21463. * Returns the Mesh.
  21464. */
  21465. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21466. /**
  21467. * Boolean : True if the mesh owns the requested kind of data.
  21468. */
  21469. isVerticesDataPresent(kind: string): boolean;
  21470. /**
  21471. * Returns an array of indices (IndicesArray).
  21472. */
  21473. getIndices(): Nullable<IndicesArray>;
  21474. protected readonly _positions: Nullable<Vector3[]>;
  21475. /**
  21476. * Sets a new updated BoundingInfo to the mesh.
  21477. * Returns the mesh.
  21478. */
  21479. refreshBoundingInfo(): InstancedMesh;
  21480. /**
  21481. * Returns the current associated LOD AbstractMesh.
  21482. */
  21483. getLOD(camera: Camera): AbstractMesh;
  21484. /**
  21485. * Creates a new InstancedMesh from the current mesh.
  21486. * - name (string) : the cloned mesh name
  21487. * - newParent (optional Node) : the optional Node to parent the clone to.
  21488. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21489. *
  21490. * Returns the clone.
  21491. */
  21492. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21493. /**
  21494. * Disposes the InstancedMesh.
  21495. * Returns nothing.
  21496. */
  21497. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21498. }
  21499. }
  21500. declare module BABYLON {
  21501. class LinesMesh extends Mesh {
  21502. useVertexColor: boolean | undefined;
  21503. useVertexAlpha: boolean | undefined;
  21504. color: Color3;
  21505. alpha: number;
  21506. /**
  21507. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21508. * This margin is expressed in world space coordinates, so its value may vary.
  21509. * Default value is 0.1
  21510. * @returns the intersection Threshold value.
  21511. */
  21512. /**
  21513. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21514. * This margin is expressed in world space coordinates, so its value may vary.
  21515. * @param value the new threshold to apply
  21516. */
  21517. intersectionThreshold: number;
  21518. private _intersectionThreshold;
  21519. private _colorShader;
  21520. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21521. /**
  21522. * Returns the string "LineMesh"
  21523. */
  21524. getClassName(): string;
  21525. material: Material;
  21526. readonly checkCollisions: boolean;
  21527. createInstance(name: string): InstancedMesh;
  21528. dispose(doNotRecurse?: boolean): void;
  21529. /**
  21530. * Returns a new LineMesh object cloned from the current one.
  21531. */
  21532. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21533. }
  21534. }
  21535. declare module BABYLON {
  21536. /**
  21537. * @hidden
  21538. **/
  21539. class _InstancesBatch {
  21540. mustReturn: boolean;
  21541. visibleInstances: Nullable<InstancedMesh[]>[];
  21542. renderSelf: boolean[];
  21543. }
  21544. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21545. private static _FRONTSIDE: number;
  21546. private static _BACKSIDE: number;
  21547. private static _DOUBLESIDE: number;
  21548. private static _DEFAULTSIDE: number;
  21549. private static _NO_CAP: number;
  21550. private static _CAP_START: number;
  21551. private static _CAP_END: number;
  21552. private static _CAP_ALL: number;
  21553. /**
  21554. * Mesh side orientation : usually the external or front surface
  21555. */
  21556. static readonly FRONTSIDE: number;
  21557. /**
  21558. * Mesh side orientation : usually the internal or back surface
  21559. */
  21560. static readonly BACKSIDE: number;
  21561. /**
  21562. * Mesh side orientation : both internal and external or front and back surfaces
  21563. */
  21564. static readonly DOUBLESIDE: number;
  21565. /**
  21566. * Mesh side orientation : by default, `FRONTSIDE`
  21567. */
  21568. static readonly DEFAULTSIDE: number;
  21569. /**
  21570. * Mesh cap setting : no cap
  21571. */
  21572. static readonly NO_CAP: number;
  21573. /**
  21574. * Mesh cap setting : one cap at the beginning of the mesh
  21575. */
  21576. static readonly CAP_START: number;
  21577. /**
  21578. * Mesh cap setting : one cap at the end of the mesh
  21579. */
  21580. static readonly CAP_END: number;
  21581. /**
  21582. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21583. */
  21584. static readonly CAP_ALL: number;
  21585. /**
  21586. * An event triggered before rendering the mesh
  21587. */
  21588. onBeforeRenderObservable: Observable<Mesh>;
  21589. /**
  21590. * An event triggered after rendering the mesh
  21591. */
  21592. onAfterRenderObservable: Observable<Mesh>;
  21593. /**
  21594. * An event triggered before drawing the mesh
  21595. */
  21596. onBeforeDrawObservable: Observable<Mesh>;
  21597. private _onBeforeDrawObserver;
  21598. onBeforeDraw: () => void;
  21599. delayLoadState: number;
  21600. instances: InstancedMesh[];
  21601. delayLoadingFile: string;
  21602. private _LODLevels;
  21603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  21604. private _morphTargetManager;
  21605. morphTargetManager: Nullable<MorphTargetManager>;
  21606. private _renderIdForInstances;
  21607. private _batchCache;
  21608. private _instancesBufferSize;
  21609. private _instancesBuffer;
  21610. private _instancesData;
  21611. private _overridenInstanceCount;
  21612. private _effectiveMaterial;
  21613. private _preActivateId;
  21614. overrideMaterialSideOrientation: Nullable<number>;
  21615. private _areNormalsFrozen;
  21616. private _sourcePositions;
  21617. private _sourceNormals;
  21618. private _source;
  21619. readonly source: Nullable<Mesh>;
  21620. isUnIndexed: boolean;
  21621. /**
  21622. * @constructor
  21623. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21624. * @param {Scene} scene The scene to add this mesh to.
  21625. * @param {Node} parent The parent of this mesh, if it has one
  21626. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21627. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21628. * When false, achieved by calling a clone(), also passing False.
  21629. * This will make creation of children, recursive.
  21630. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21631. */
  21632. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21633. /**
  21634. * Returns the string "Mesh".
  21635. */
  21636. getClassName(): string;
  21637. /**
  21638. * Returns a string.
  21639. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21640. */
  21641. toString(fullDetails?: boolean): string;
  21642. /**
  21643. * True if the mesh has some Levels Of Details (LOD).
  21644. * Returns a boolean.
  21645. */
  21646. readonly hasLODLevels: boolean;
  21647. /**
  21648. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21649. * @returns an array of {BABYLON.MeshLODLevel}
  21650. */
  21651. getLODLevels(): MeshLODLevel[];
  21652. private _sortLODLevels();
  21653. /**
  21654. * Add a mesh as LOD level triggered at the given distance.
  21655. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21656. * @param {number} distance The distance from the center of the object to show this level
  21657. * @param {Mesh} mesh The mesh to be added as LOD level
  21658. * @return {Mesh} This mesh (for chaining)
  21659. */
  21660. addLODLevel(distance: number, mesh: Mesh): Mesh;
  21661. /**
  21662. * Returns the LOD level mesh at the passed distance or null if not found.
  21663. * It is related to the method `addLODLevel(distance, mesh)`.
  21664. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21665. * Returns an object Mesh or `null`.
  21666. */
  21667. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21668. /**
  21669. * Remove a mesh from the LOD array
  21670. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21671. * @param {Mesh} mesh The mesh to be removed.
  21672. * @return {Mesh} This mesh (for chaining)
  21673. */
  21674. removeLODLevel(mesh: Mesh): Mesh;
  21675. /**
  21676. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21677. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21678. */
  21679. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  21680. /**
  21681. * Returns the mesh internal Geometry object.
  21682. */
  21683. readonly geometry: Nullable<Geometry>;
  21684. /**
  21685. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21686. */
  21687. getTotalVertices(): number;
  21688. /**
  21689. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21690. * 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.
  21691. * You can force the copy with forceCopy === true
  21692. * Returns null if the mesh has no geometry or no vertex buffer.
  21693. * Possible `kind` values :
  21694. * - BABYLON.VertexBuffer.PositionKind
  21695. * - BABYLON.VertexBuffer.UVKind
  21696. * - BABYLON.VertexBuffer.UV2Kind
  21697. * - BABYLON.VertexBuffer.UV3Kind
  21698. * - BABYLON.VertexBuffer.UV4Kind
  21699. * - BABYLON.VertexBuffer.UV5Kind
  21700. * - BABYLON.VertexBuffer.UV6Kind
  21701. * - BABYLON.VertexBuffer.ColorKind
  21702. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21703. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21704. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21705. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21706. */
  21707. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21708. /**
  21709. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21710. * Returns `null` if the mesh has no geometry.
  21711. * Possible `kind` values :
  21712. * - BABYLON.VertexBuffer.PositionKind
  21713. * - BABYLON.VertexBuffer.UVKind
  21714. * - BABYLON.VertexBuffer.UV2Kind
  21715. * - BABYLON.VertexBuffer.UV3Kind
  21716. * - BABYLON.VertexBuffer.UV4Kind
  21717. * - BABYLON.VertexBuffer.UV5Kind
  21718. * - BABYLON.VertexBuffer.UV6Kind
  21719. * - BABYLON.VertexBuffer.ColorKind
  21720. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21721. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21722. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21723. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21724. */
  21725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21726. isVerticesDataPresent(kind: string): boolean;
  21727. /**
  21728. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21729. * Possible `kind` values :
  21730. * - BABYLON.VertexBuffer.PositionKind
  21731. * - BABYLON.VertexBuffer.UVKind
  21732. * - BABYLON.VertexBuffer.UV2Kind
  21733. * - BABYLON.VertexBuffer.UV3Kind
  21734. * - BABYLON.VertexBuffer.UV4Kind
  21735. * - BABYLON.VertexBuffer.UV5Kind
  21736. * - BABYLON.VertexBuffer.UV6Kind
  21737. * - BABYLON.VertexBuffer.ColorKind
  21738. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21739. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21740. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21741. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21742. */
  21743. isVertexBufferUpdatable(kind: string): boolean;
  21744. /**
  21745. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21746. * Possible `kind` values :
  21747. * - BABYLON.VertexBuffer.PositionKind
  21748. * - BABYLON.VertexBuffer.UVKind
  21749. * - BABYLON.VertexBuffer.UV2Kind
  21750. * - BABYLON.VertexBuffer.UV3Kind
  21751. * - BABYLON.VertexBuffer.UV4Kind
  21752. * - BABYLON.VertexBuffer.UV5Kind
  21753. * - BABYLON.VertexBuffer.UV6Kind
  21754. * - BABYLON.VertexBuffer.ColorKind
  21755. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21756. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21757. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21758. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21759. */
  21760. getVerticesDataKinds(): string[];
  21761. /**
  21762. * Returns a positive integer : the total number of indices in this mesh geometry.
  21763. * Returns zero if the mesh has no geometry.
  21764. */
  21765. getTotalIndices(): number;
  21766. /**
  21767. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21768. * 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.
  21769. * Returns an empty array if the mesh has no geometry.
  21770. */
  21771. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21772. readonly isBlocked: boolean;
  21773. /**
  21774. * Determine if the current mesh is ready to be rendered
  21775. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21776. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21777. * @returns true if all associated assets are ready (material, textures, shaders)
  21778. */
  21779. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21780. /**
  21781. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21782. * This property is pertinent only for updatable parametric shapes.
  21783. */
  21784. readonly areNormalsFrozen: boolean;
  21785. /**
  21786. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21787. * It has no effect at all on other shapes.
  21788. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21789. * Returns the Mesh.
  21790. */
  21791. freezeNormals(): Mesh;
  21792. /**
  21793. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21794. * It has no effect at all on other shapes.
  21795. * It reactivates the mesh normals computation if it was previously frozen.
  21796. * Returns the Mesh.
  21797. */
  21798. unfreezeNormals(): Mesh;
  21799. /**
  21800. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21801. */
  21802. overridenInstanceCount: number;
  21803. /**
  21804. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21805. * This means the mesh underlying bounding box and sphere are recomputed.
  21806. * Returns the Mesh.
  21807. */
  21808. refreshBoundingInfo(): Mesh;
  21809. private _getPositionData(applySkeleton);
  21810. subdivide(count: number): void;
  21811. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21812. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21813. /**
  21814. * Sets the mesh VertexBuffer.
  21815. * Returns the Mesh.
  21816. */
  21817. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21818. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21819. /**
  21820. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21821. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21822. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21823. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21824. * Returns the Mesh.
  21825. */
  21826. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21827. /**
  21828. * Creates a un-shared specific occurence of the geometry for the mesh.
  21829. * Returns the Mesh.
  21830. */
  21831. makeGeometryUnique(): Mesh;
  21832. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21833. /**
  21834. * Update the current index buffer
  21835. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21836. * Returns the Mesh.
  21837. */
  21838. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21839. /**
  21840. * Invert the geometry to move from a right handed system to a left handed one.
  21841. * Returns the Mesh.
  21842. */
  21843. toLeftHanded(): Mesh;
  21844. /**
  21845. * Registers for this mesh a javascript function called just before the rendering process.
  21846. * This function is passed the current mesh.
  21847. * Return the Mesh.
  21848. */
  21849. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21850. /**
  21851. * Disposes a previously registered javascript function called before the rendering.
  21852. * This function is passed the current mesh.
  21853. * Returns the Mesh.
  21854. */
  21855. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21856. /**
  21857. * Registers for this mesh a javascript function called just after the rendering is complete.
  21858. * This function is passed the current mesh.
  21859. * Returns the Mesh.
  21860. */
  21861. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21862. /**
  21863. * Disposes a previously registered javascript function called after the rendering.
  21864. * This function is passed the current mesh.
  21865. * Return the Mesh.
  21866. */
  21867. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21868. /**
  21869. * Triggers the draw call for the mesh.
  21870. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21871. * Returns the Mesh.
  21872. */
  21873. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21874. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21875. /**
  21876. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21877. */
  21878. getEmittedParticleSystems(): IParticleSystem[];
  21879. /**
  21880. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21881. */
  21882. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21883. /**
  21884. * Normalize matrix weights so that all vertices have a total weight set to 1
  21885. */
  21886. cleanMatrixWeights(): void;
  21887. private _queueLoad(scene);
  21888. /**
  21889. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21890. */
  21891. isInFrustum(frustumPlanes: Plane[]): boolean;
  21892. /**
  21893. * Sets the mesh material by the material or multiMaterial `id` property.
  21894. * The material `id` is a string identifying the material or the multiMaterial.
  21895. * This method returns the Mesh.
  21896. */
  21897. setMaterialByID(id: string): Mesh;
  21898. /**
  21899. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21900. */
  21901. getAnimatables(): IAnimatable[];
  21902. /**
  21903. * Modifies the mesh geometry according to the passed transformation matrix.
  21904. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21905. * The mesh normals are modified accordingly the same transformation.
  21906. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21907. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21908. * Returns the Mesh.
  21909. */
  21910. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21911. /**
  21912. * Modifies the mesh geometry according to its own current World Matrix.
  21913. * The mesh World Matrix is then reset.
  21914. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21915. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21916. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21917. * Returns the Mesh.
  21918. */
  21919. bakeCurrentTransformIntoVertices(): Mesh;
  21920. protected readonly _positions: Nullable<Vector3[]>;
  21921. /**
  21922. * Returns a new Mesh object generated from the current mesh properties.
  21923. * This method must not get confused with createInstance().
  21924. * The parameter `name` is a string, the name given to the new mesh.
  21925. * The optional parameter `newParent` can be any Node object (default `null`).
  21926. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21927. * 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.
  21928. */
  21929. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21930. /**
  21931. * Releases resources associated with this mesh.
  21932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21934. */
  21935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21936. /**
  21937. * Modifies the mesh geometry according to a displacement map.
  21938. * 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.
  21939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21940. * This method returns nothing.
  21941. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21942. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21943. * 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.
  21944. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21945. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21946. *
  21947. * Returns the Mesh.
  21948. */
  21949. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21950. /**
  21951. * Modifies the mesh geometry according to a displacementMap buffer.
  21952. * 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.
  21953. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21954. * This method returns nothing.
  21955. * 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.
  21956. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21957. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21958. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21959. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21960. *
  21961. * Returns the Mesh.
  21962. */
  21963. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21964. /**
  21965. * Modify the mesh to get a flat shading rendering.
  21966. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21967. * This method returns the Mesh.
  21968. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21969. */
  21970. convertToFlatShadedMesh(): Mesh;
  21971. /**
  21972. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21973. * In other words, more vertices, no more indices and a single bigger VBO.
  21974. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21975. * Returns the Mesh.
  21976. */
  21977. convertToUnIndexedMesh(): Mesh;
  21978. /**
  21979. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21980. * This method returns the Mesh.
  21981. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21982. */
  21983. flipFaces(flipNormals?: boolean): Mesh;
  21984. /**
  21985. * Creates a new InstancedMesh object from the mesh model.
  21986. * An instance shares the same properties and the same material than its model.
  21987. * Only these properties of each instance can then be set individually :
  21988. * - position
  21989. * - rotation
  21990. * - rotationQuaternion
  21991. * - setPivotMatrix
  21992. * - scaling
  21993. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21994. * Warning : this method is not supported for Line mesh and LineSystem
  21995. */
  21996. createInstance(name: string): InstancedMesh;
  21997. /**
  21998. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21999. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22000. * This method returns the Mesh.
  22001. */
  22002. synchronizeInstances(): Mesh;
  22003. /**
  22004. * Simplify the mesh according to the given array of settings.
  22005. * Function will return immediately and will simplify async. It returns the Mesh.
  22006. * @param settings a collection of simplification settings.
  22007. * @param parallelProcessing should all levels calculate parallel or one after the other.
  22008. * @param type the type of simplification to run.
  22009. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  22010. */
  22011. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  22012. /**
  22013. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22014. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22015. * This should be used together with the simplification to avoid disappearing triangles.
  22016. * Returns the Mesh.
  22017. * @param successCallback an optional success callback to be called after the optimization finished.
  22018. */
  22019. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22020. serialize(serializationObject: any): void;
  22021. /**
  22022. * Returns a new Mesh object parsed from the source provided.
  22023. * The parameter `parsedMesh` is the source.
  22024. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22025. */
  22026. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22027. /**
  22028. * Creates a ribbon mesh.
  22029. * Please consider using the same method from the MeshBuilder class instead.
  22030. * 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.
  22031. *
  22032. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22033. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22034. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22035. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22036. * 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.
  22037. * 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.
  22038. * 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
  22039. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22040. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22041. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22042. */
  22043. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22044. /**
  22045. * Creates a plane polygonal mesh. By default, this is a disc.
  22046. * Please consider using the same method from the MeshBuilder class instead.
  22047. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22048. * 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.
  22049. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22050. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22051. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22052. */
  22053. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22054. /**
  22055. * Creates a box mesh.
  22056. * Please consider using the same method from the MeshBuilder class instead.
  22057. * The parameter `size` sets the size (float) of each box side (default 1).
  22058. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22059. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22060. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22061. */
  22062. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22063. /**
  22064. * Creates a sphere mesh.
  22065. * Please consider using the same method from the MeshBuilder class instead.
  22066. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22067. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22068. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22069. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22070. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22071. */
  22072. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22073. /**
  22074. * Creates a cylinder or a cone mesh.
  22075. * Please consider using the same method from the MeshBuilder class instead.
  22076. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22077. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22078. * 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.
  22079. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22080. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22081. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22082. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22083. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22084. */
  22085. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22086. /**
  22087. * Creates a torus mesh.
  22088. * Please consider using the same method from the MeshBuilder class instead.
  22089. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22090. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22091. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22092. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22093. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22094. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22095. */
  22096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22097. /**
  22098. * Creates a torus knot mesh.
  22099. * Please consider using the same method from the MeshBuilder class instead.
  22100. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22101. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22102. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22103. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22104. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22105. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22106. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22107. */
  22108. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22109. /**
  22110. * Creates a line mesh.
  22111. * Please consider using the same method from the MeshBuilder class instead.
  22112. * 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.
  22113. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22114. * The parameter `points` is an array successive Vector3.
  22115. * 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
  22116. * When updating an instance, remember that only point positions can change, not the number of points.
  22117. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22118. */
  22119. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22120. /**
  22121. * Creates a dashed line mesh.
  22122. * Please consider using the same method from the MeshBuilder class instead.
  22123. * 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.
  22124. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22125. * The parameter `points` is an array successive Vector3.
  22126. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22127. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22128. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22129. * 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
  22130. * When updating an instance, remember that only point positions can change, not the number of points.
  22131. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22132. */
  22133. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22134. /**
  22135. * Creates a polygon mesh.
  22136. * Please consider using the same method from the MeshBuilder class instead.
  22137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22138. * 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.
  22139. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22141. * Remember you can only change the shape positions, not their number when updating a polygon.
  22142. */
  22143. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22144. /**
  22145. * Creates an extruded polygon mesh, with depth in the Y direction.
  22146. * Please consider using the same method from the MeshBuilder class instead.
  22147. */
  22148. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22149. /**
  22150. * Creates an extruded shape mesh.
  22151. * 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.
  22152. * Please consider using the same method from the MeshBuilder class instead.
  22153. *
  22154. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22155. * 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
  22156. * extruded along the Z axis.
  22157. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22158. * 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.
  22159. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22160. * 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
  22161. * 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
  22162. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22163. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22164. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22165. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22166. */
  22167. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22168. /**
  22169. * Creates an custom extruded shape mesh.
  22170. * 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.
  22171. * Please consider using the same method from the MeshBuilder class instead.
  22172. *
  22173. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22174. * 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
  22175. * extruded along the Z axis.
  22176. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22177. * 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
  22178. * and the distance of this point from the begining of the path :
  22179. * ```javascript
  22180. * var rotationFunction = function(i, distance) {
  22181. * // do things
  22182. * return rotationValue; }
  22183. * ```
  22184. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22185. * 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
  22186. * and the distance of this point from the begining of the path :
  22187. * ```javascript
  22188. * var scaleFunction = function(i, distance) {
  22189. * // do things
  22190. * return scaleValue;}
  22191. * ```
  22192. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22193. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22194. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22195. * 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
  22196. * 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
  22197. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22198. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22199. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22201. */
  22202. 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;
  22203. /**
  22204. * Creates lathe mesh.
  22205. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22206. * Please consider using the same method from the MeshBuilder class instead.
  22207. * 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
  22208. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22209. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22210. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22211. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22212. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22213. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22214. */
  22215. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22216. /**
  22217. * Creates a plane mesh.
  22218. * Please consider using the same method from the MeshBuilder class instead.
  22219. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22220. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22221. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22222. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22223. */
  22224. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22225. /**
  22226. * Creates a ground mesh.
  22227. * Please consider using the same method from the MeshBuilder class instead.
  22228. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22229. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22230. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22231. */
  22232. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22233. /**
  22234. * Creates a tiled ground mesh.
  22235. * Please consider using the same method from the MeshBuilder class instead.
  22236. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22237. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22238. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22239. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22240. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22241. * numbers of subdivisions on the ground width and height of each tile.
  22242. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22243. */
  22244. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22245. w: number;
  22246. h: number;
  22247. }, precision: {
  22248. w: number;
  22249. h: number;
  22250. }, scene: Scene, updatable?: boolean): Mesh;
  22251. /**
  22252. * Creates a ground mesh from a height map.
  22253. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22254. * Please consider using the same method from the MeshBuilder class instead.
  22255. * The parameter `url` sets the URL of the height map image resource.
  22256. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22257. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22258. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22259. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22260. * 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).
  22261. * This function is passed the newly built mesh :
  22262. * ```javascript
  22263. * function(mesh) { // do things
  22264. * return; }
  22265. * ```
  22266. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22267. */
  22268. 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;
  22269. /**
  22270. * Creates a tube mesh.
  22271. * 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.
  22272. * Please consider using the same method from the MeshBuilder class instead.
  22273. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22274. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22275. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22276. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22277. * 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.
  22278. * It must return a radius value (positive float) :
  22279. * ```javascript
  22280. * var radiusFunction = function(i, distance) {
  22281. * // do things
  22282. * return radius; }
  22283. * ```
  22284. * 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
  22285. * 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
  22286. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22287. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22288. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22289. */
  22290. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22291. (i: number, distance: number): number;
  22292. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22293. /**
  22294. * Creates a polyhedron mesh.
  22295. * Please consider using the same method from the MeshBuilder class instead.
  22296. * 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
  22297. * to choose the wanted type.
  22298. * The parameter `size` (positive float, default 1) sets the polygon size.
  22299. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22300. * 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`.
  22301. * 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
  22302. * 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)`).
  22303. * 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
  22304. * 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.
  22305. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22306. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22307. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22308. */
  22309. static CreatePolyhedron(name: string, options: {
  22310. type?: number;
  22311. size?: number;
  22312. sizeX?: number;
  22313. sizeY?: number;
  22314. sizeZ?: number;
  22315. custom?: any;
  22316. faceUV?: Vector4[];
  22317. faceColors?: Color4[];
  22318. updatable?: boolean;
  22319. sideOrientation?: number;
  22320. }, scene: Scene): Mesh;
  22321. /**
  22322. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22323. * Please consider using the same method from the MeshBuilder class instead.
  22324. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22325. * 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`).
  22326. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22327. * 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.
  22328. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22329. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22330. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22331. */
  22332. static CreateIcoSphere(name: string, options: {
  22333. radius?: number;
  22334. flat?: boolean;
  22335. subdivisions?: number;
  22336. sideOrientation?: number;
  22337. updatable?: boolean;
  22338. }, scene: Scene): Mesh;
  22339. /**
  22340. * Creates a decal mesh.
  22341. * Please consider using the same method from the MeshBuilder class instead.
  22342. * 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.
  22343. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22344. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22345. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22346. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22347. */
  22348. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22349. /**
  22350. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22351. */
  22352. setPositionsForCPUSkinning(): Float32Array;
  22353. /**
  22354. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22355. */
  22356. setNormalsForCPUSkinning(): Float32Array;
  22357. /**
  22358. * Updates the vertex buffer by applying transformation from the bones.
  22359. * Returns the Mesh.
  22360. *
  22361. * @param {skeleton} skeleton to apply
  22362. */
  22363. applySkeleton(skeleton: Skeleton): Mesh;
  22364. /**
  22365. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22366. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22367. */
  22368. static MinMax(meshes: AbstractMesh[]): {
  22369. min: Vector3;
  22370. max: Vector3;
  22371. };
  22372. /**
  22373. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22374. */
  22375. static Center(meshesOrMinMaxVector: {
  22376. min: Vector3;
  22377. max: Vector3;
  22378. } | AbstractMesh[]): Vector3;
  22379. /**
  22380. * Merge the array of meshes into a single mesh for performance reasons.
  22381. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  22382. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  22383. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22384. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22385. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22386. */
  22387. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22388. }
  22389. }
  22390. declare module BABYLON {
  22391. /**
  22392. * Define an interface for all classes that will get and set the data on vertices
  22393. */
  22394. interface IGetSetVerticesData {
  22395. isVerticesDataPresent(kind: string): boolean;
  22396. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22397. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  22398. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22399. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22400. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22401. }
  22402. /**
  22403. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22404. */
  22405. class VertexData {
  22406. /**
  22407. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22408. */
  22409. positions: Nullable<FloatArray>;
  22410. /**
  22411. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22412. */
  22413. normals: Nullable<FloatArray>;
  22414. /**
  22415. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22416. */
  22417. tangents: Nullable<FloatArray>;
  22418. /**
  22419. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22420. */
  22421. uvs: Nullable<FloatArray>;
  22422. /**
  22423. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22424. */
  22425. uvs2: Nullable<FloatArray>;
  22426. /**
  22427. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22428. */
  22429. uvs3: Nullable<FloatArray>;
  22430. /**
  22431. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22432. */
  22433. uvs4: Nullable<FloatArray>;
  22434. /**
  22435. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22436. */
  22437. uvs5: Nullable<FloatArray>;
  22438. /**
  22439. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22440. */
  22441. uvs6: Nullable<FloatArray>;
  22442. /**
  22443. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22444. */
  22445. colors: Nullable<FloatArray>;
  22446. /**
  22447. * 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).
  22448. */
  22449. matricesIndices: Nullable<FloatArray>;
  22450. /**
  22451. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22452. */
  22453. matricesWeights: Nullable<FloatArray>;
  22454. /**
  22455. * An array extending the number of possible indices
  22456. */
  22457. matricesIndicesExtra: Nullable<FloatArray>;
  22458. /**
  22459. * An array extending the number of possible weights when the number of indices is extended
  22460. */
  22461. matricesWeightsExtra: Nullable<FloatArray>;
  22462. /**
  22463. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22464. */
  22465. indices: Nullable<IndicesArray>;
  22466. /**
  22467. * Uses the passed data array to set the set the values for the specified kind of data
  22468. * @param data a linear array of floating numbers
  22469. * @param kind the type of data that is being set, eg positions, colors etc
  22470. */
  22471. set(data: FloatArray, kind: string): void;
  22472. /**
  22473. * Associates the vertexData to the passed Mesh.
  22474. * Sets it as updatable or not (default `false`)
  22475. * @param mesh the mesh the vertexData is applied to
  22476. * @param updatable when used and having the value true allows new data to update the vertexData
  22477. * @returns the VertexData
  22478. */
  22479. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22480. /**
  22481. * Associates the vertexData to the passed Geometry.
  22482. * Sets it as updatable or not (default `false`)
  22483. * @param geometry the geometry the vertexData is applied to
  22484. * @param updatable when used and having the value true allows new data to update the vertexData
  22485. * @returns VertexData
  22486. */
  22487. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22488. /**
  22489. * Updates the associated mesh
  22490. * @param mesh the mesh to be updated
  22491. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22492. * @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
  22493. * @returns VertexData
  22494. */
  22495. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22496. /**
  22497. * Updates the associated geometry
  22498. * @param geometry the geometry to be updated
  22499. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22500. * @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
  22501. * @returns VertexData.
  22502. */
  22503. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22504. private _applyTo(meshOrGeometry, updatable?);
  22505. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  22506. /**
  22507. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22508. * @param matrix the transforming matrix
  22509. * @returns the VertexData
  22510. */
  22511. transform(matrix: Matrix): VertexData;
  22512. /**
  22513. * Merges the passed VertexData into the current one
  22514. * @param other the VertexData to be merged into the current one
  22515. * @returns the modified VertexData
  22516. */
  22517. merge(other: VertexData): VertexData;
  22518. private _mergeElement(source, other);
  22519. private _validate();
  22520. /**
  22521. * Serializes the VertexData
  22522. * @returns a serialized object
  22523. */
  22524. serialize(): any;
  22525. /**
  22526. * Extracts the vertexData from a mesh
  22527. * @param mesh the mesh from which to extract the VertexData
  22528. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22529. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22530. * @returns the object VertexData associated to the passed mesh
  22531. */
  22532. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22533. /**
  22534. * Extracts the vertexData from the geometry
  22535. * @param geometry the geometry from which to extract the VertexData
  22536. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22537. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22538. * @returns the object VertexData associated to the passed mesh
  22539. */
  22540. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22541. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  22542. /**
  22543. * Creates the VertexData for a Ribbon
  22544. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22545. * * pathArray array of paths, each of which an array of successive Vector3
  22546. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22547. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22548. * * 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
  22549. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22550. * * 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)
  22551. * * 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)
  22552. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22553. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22554. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22555. * @returns the VertexData of the ribbon
  22556. */
  22557. static CreateRibbon(options: {
  22558. pathArray: Vector3[][];
  22559. closeArray?: boolean;
  22560. closePath?: boolean;
  22561. offset?: number;
  22562. sideOrientation?: number;
  22563. frontUVs?: Vector4;
  22564. backUVs?: Vector4;
  22565. invertUV?: boolean;
  22566. uvs?: Vector2[];
  22567. colors?: Color4[];
  22568. }): VertexData;
  22569. /**
  22570. * Creates the VertexData for a box
  22571. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22572. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22573. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22574. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22575. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22576. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22577. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22578. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22579. * * 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)
  22580. * * 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)
  22581. * @returns the VertexData of the box
  22582. */
  22583. static CreateBox(options: {
  22584. size?: number;
  22585. width?: number;
  22586. height?: number;
  22587. depth?: number;
  22588. faceUV?: Vector4[];
  22589. faceColors?: Color4[];
  22590. sideOrientation?: number;
  22591. frontUVs?: Vector4;
  22592. backUVs?: Vector4;
  22593. }): VertexData;
  22594. /**
  22595. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22596. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22597. * * segments sets the number of horizontal strips optional, default 32
  22598. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22599. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22600. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22601. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22602. * * 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
  22603. * * 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
  22604. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22605. * * 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)
  22606. * * 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)
  22607. * @returns the VertexData of the ellipsoid
  22608. */
  22609. static CreateSphere(options: {
  22610. segments?: number;
  22611. diameter?: number;
  22612. diameterX?: number;
  22613. diameterY?: number;
  22614. diameterZ?: number;
  22615. arc?: number;
  22616. slice?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Creates the VertexData for a cylinder, cone or prism
  22623. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22624. * * height sets the height (y direction) of the cylinder, optional, default 2
  22625. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22626. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22627. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22628. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22629. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22630. * * 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
  22631. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22632. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22633. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22634. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22635. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22636. * * 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)
  22637. * * 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)
  22638. * @returns the VertexData of the cylinder, cone or prism
  22639. */
  22640. static CreateCylinder(options: {
  22641. height?: number;
  22642. diameterTop?: number;
  22643. diameterBottom?: number;
  22644. diameter?: number;
  22645. tessellation?: number;
  22646. subdivisions?: number;
  22647. arc?: number;
  22648. faceColors?: Color4[];
  22649. faceUV?: Vector4[];
  22650. hasRings?: boolean;
  22651. enclose?: boolean;
  22652. sideOrientation?: number;
  22653. frontUVs?: Vector4;
  22654. backUVs?: Vector4;
  22655. }): VertexData;
  22656. /**
  22657. * Creates the VertexData for a torus
  22658. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22659. * * diameter the diameter of the torus, optional default 1
  22660. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22661. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22662. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22663. * * 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)
  22664. * * 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)
  22665. * @returns the VertexData of the torus
  22666. */
  22667. static CreateTorus(options: {
  22668. diameter?: number;
  22669. thickness?: number;
  22670. tessellation?: number;
  22671. sideOrientation?: number;
  22672. frontUVs?: Vector4;
  22673. backUVs?: Vector4;
  22674. }): VertexData;
  22675. /**
  22676. * Creates the VertexData of the LineSystem
  22677. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22678. * - lines an array of lines, each line being an array of successive Vector3
  22679. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22680. * @returns the VertexData of the LineSystem
  22681. */
  22682. static CreateLineSystem(options: {
  22683. lines: Vector3[][];
  22684. colors?: Nullable<Color4[][]>;
  22685. }): VertexData;
  22686. /**
  22687. * Create the VertexData for a DashedLines
  22688. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22689. * - points an array successive Vector3
  22690. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22691. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22692. * - dashNb the intended total number of dashes, optional, default 200
  22693. * @returns the VertexData for the DashedLines
  22694. */
  22695. static CreateDashedLines(options: {
  22696. points: Vector3[];
  22697. dashSize?: number;
  22698. gapSize?: number;
  22699. dashNb?: number;
  22700. }): VertexData;
  22701. /**
  22702. * Creates the VertexData for a Ground
  22703. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22704. * - width the width (x direction) of the ground, optional, default 1
  22705. * - height the height (z direction) of the ground, optional, default 1
  22706. * - subdivisions the number of subdivisions per side, optional, default 1
  22707. * @returns the VertexData of the Ground
  22708. */
  22709. static CreateGround(options: {
  22710. width?: number;
  22711. height?: number;
  22712. subdivisions?: number;
  22713. subdivisionsX?: number;
  22714. subdivisionsY?: number;
  22715. }): VertexData;
  22716. /**
  22717. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22718. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22719. * * xmin the ground minimum X coordinate, optional, default -1
  22720. * * zmin the ground minimum Z coordinate, optional, default -1
  22721. * * xmax the ground maximum X coordinate, optional, default 1
  22722. * * zmax the ground maximum Z coordinate, optional, default 1
  22723. * * 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}
  22724. * * 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}
  22725. * @returns the VertexData of the TiledGround
  22726. */
  22727. static CreateTiledGround(options: {
  22728. xmin: number;
  22729. zmin: number;
  22730. xmax: number;
  22731. zmax: number;
  22732. subdivisions?: {
  22733. w: number;
  22734. h: number;
  22735. };
  22736. precision?: {
  22737. w: number;
  22738. h: number;
  22739. };
  22740. }): VertexData;
  22741. /**
  22742. * Creates the VertexData of the Ground designed from a heightmap
  22743. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22744. * * width the width (x direction) of the ground
  22745. * * height the height (z direction) of the ground
  22746. * * subdivisions the number of subdivisions per side
  22747. * * minHeight the minimum altitude on the ground, optional, default 0
  22748. * * maxHeight the maximum altitude on the ground, optional default 1
  22749. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22750. * * buffer the array holding the image color data
  22751. * * bufferWidth the width of image
  22752. * * bufferHeight the height of image
  22753. * @returns the VertexData of the Ground designed from a heightmap
  22754. */
  22755. static CreateGroundFromHeightMap(options: {
  22756. width: number;
  22757. height: number;
  22758. subdivisions: number;
  22759. minHeight: number;
  22760. maxHeight: number;
  22761. colorFilter: Color3;
  22762. buffer: Uint8Array;
  22763. bufferWidth: number;
  22764. bufferHeight: number;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Plane
  22768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22769. * * size sets the width and height of the plane to the value of size, optional default 1
  22770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22772. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreatePlane(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the Disc or regular Polygon
  22787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22788. * * radius the radius of the disc, optional default 0.5
  22789. * * tessellation the number of polygon sides, optional, default 64
  22790. * * 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
  22791. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22792. * * 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)
  22793. * * 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)
  22794. * @returns the VertexData of the box
  22795. */
  22796. static CreateDisc(options: {
  22797. radius?: number;
  22798. tessellation?: number;
  22799. arc?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22807. * @param polygon a mesh built from polygonTriangulation.build()
  22808. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22811. * @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)
  22812. * @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)
  22813. * @returns the VertexData of the Polygon
  22814. */
  22815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22816. /**
  22817. * Creates the VertexData of the IcoSphere
  22818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22819. * * radius the radius of the IcoSphere, optional default 1
  22820. * * radiusX allows stretching in the x direction, optional, default radius
  22821. * * radiusY allows stretching in the y direction, optional, default radius
  22822. * * radiusZ allows stretching in the z direction, optional, default radius
  22823. * * flat when true creates a flat shaded mesh, optional, default true
  22824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22825. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22826. * * 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)
  22827. * * 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)
  22828. * @returns the VertexData of the IcoSphere
  22829. */
  22830. static CreateIcoSphere(options: {
  22831. radius?: number;
  22832. radiusX?: number;
  22833. radiusY?: number;
  22834. radiusZ?: number;
  22835. flat?: boolean;
  22836. subdivisions?: number;
  22837. sideOrientation?: number;
  22838. frontUVs?: Vector4;
  22839. backUVs?: Vector4;
  22840. }): VertexData;
  22841. /**
  22842. * Creates the VertexData for a Polyhedron
  22843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22844. * * type provided types are:
  22845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22846. * * 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)
  22847. * * size the size of the IcoSphere, optional default 1
  22848. * * sizeX allows stretching in the x direction, optional, default size
  22849. * * sizeY allows stretching in the y direction, optional, default size
  22850. * * sizeZ allows stretching in the z direction, optional, default size
  22851. * * 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
  22852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22854. * * flat when true creates a flat shaded mesh, optional, default true
  22855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22856. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22857. * * 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)
  22858. * * 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)
  22859. * @returns the VertexData of the Polyhedron
  22860. */
  22861. static CreatePolyhedron(options: {
  22862. type?: number;
  22863. size?: number;
  22864. sizeX?: number;
  22865. sizeY?: number;
  22866. sizeZ?: number;
  22867. custom?: any;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. flat?: boolean;
  22871. sideOrientation?: number;
  22872. frontUVs?: Vector4;
  22873. backUVs?: Vector4;
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a TorusKnot
  22877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22878. * * radius the radius of the torus knot, optional, default 2
  22879. * * tube the thickness of the tube, optional, default 0.5
  22880. * * radialSegments the number of sides on each tube segments, optional, default 32
  22881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22882. * * p the number of windings around the z axis, optional, default 2
  22883. * * q the number of windings around the x axis, optional, default 3
  22884. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the Torus Knot
  22888. */
  22889. static CreateTorusKnot(options: {
  22890. radius?: number;
  22891. tube?: number;
  22892. radialSegments?: number;
  22893. tubularSegments?: number;
  22894. p?: number;
  22895. q?: number;
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Compute normals for given positions and indices
  22902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22906. * * facetNormals : optional array of facet normals (vector3)
  22907. * * facetPositions : optional array of facet positions (vector3)
  22908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22910. * * bInfo : optional bounding info, required for facetPartitioning computation
  22911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22913. * * useRightHandedSystem: optional boolean to for right handed system computation
  22914. * * depthSort : optional boolean to enable the facet depth sort computation
  22915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22917. */
  22918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22919. facetNormals?: any;
  22920. facetPositions?: any;
  22921. facetPartitioning?: any;
  22922. ratio?: number;
  22923. bInfo?: any;
  22924. bbSize?: Vector3;
  22925. subDiv?: any;
  22926. useRightHandedSystem?: boolean;
  22927. depthSort?: boolean;
  22928. distanceTo?: Vector3;
  22929. depthSortedFacets?: any;
  22930. }): void;
  22931. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22932. /**
  22933. * Applies VertexData created from the imported parameters to the geometry
  22934. * @param parsedVertexData the parsed data from an imported file
  22935. * @param geometry the geometry to apply the VertexData to
  22936. */
  22937. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22938. }
  22939. }
  22940. declare module BABYLON {
  22941. /**
  22942. * Class containing static functions to help procedurally build meshes
  22943. */
  22944. class MeshBuilder {
  22945. private static updateSideOrientation(orientation?);
  22946. /**
  22947. * Creates a box mesh
  22948. * * The parameter `size` sets the size (float) of each box side (default 1)
  22949. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22950. * * 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)
  22951. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22953. * * 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
  22954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22955. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22956. * @param name defines the name of the mesh
  22957. * @param options defines the options used to create the mesh
  22958. * @param scene defines the hosting scene
  22959. * @returns the box mesh
  22960. */
  22961. static CreateBox(name: string, options: {
  22962. size?: number;
  22963. width?: number;
  22964. height?: number;
  22965. depth?: number;
  22966. faceUV?: Vector4[];
  22967. faceColors?: Color4[];
  22968. sideOrientation?: number;
  22969. frontUVs?: Vector4;
  22970. backUVs?: Vector4;
  22971. updatable?: boolean;
  22972. }, scene?: Nullable<Scene>): Mesh;
  22973. /**
  22974. * Creates a sphere mesh
  22975. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22976. * * 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`)
  22977. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22978. * * 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
  22979. * * 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)
  22980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22981. * * 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
  22982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22983. * @param name defines the name of the mesh
  22984. * @param options defines the options used to create the mesh
  22985. * @param scene defines the hosting scene
  22986. * @returns the sphere mesh
  22987. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22988. */
  22989. static CreateSphere(name: string, options: {
  22990. segments?: number;
  22991. diameter?: number;
  22992. diameterX?: number;
  22993. diameterY?: number;
  22994. diameterZ?: number;
  22995. arc?: number;
  22996. slice?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. updatable?: boolean;
  23001. }, scene: any): Mesh;
  23002. /**
  23003. * Creates a plane polygonal mesh. By default, this is a disc
  23004. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23005. * * 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
  23006. * * 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
  23007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23008. * * 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
  23009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23010. * @param name defines the name of the mesh
  23011. * @param options defines the options used to create the mesh
  23012. * @param scene defines the hosting scene
  23013. * @returns the plane polygonal mesh
  23014. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23015. */
  23016. static CreateDisc(name: string, options: {
  23017. radius?: number;
  23018. tessellation?: number;
  23019. arc?: number;
  23020. updatable?: boolean;
  23021. sideOrientation?: number;
  23022. frontUVs?: Vector4;
  23023. backUVs?: Vector4;
  23024. }, scene?: Nullable<Scene>): Mesh;
  23025. /**
  23026. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23027. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23028. * * 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`)
  23029. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23030. * * 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
  23031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23032. * * 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
  23033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23034. * @param name defines the name of the mesh
  23035. * @param options defines the options used to create the mesh
  23036. * @param scene defines the hosting scene
  23037. * @returns the icosahedron mesh
  23038. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23039. */
  23040. static CreateIcoSphere(name: string, options: {
  23041. radius?: number;
  23042. radiusX?: number;
  23043. radiusY?: number;
  23044. radiusZ?: number;
  23045. flat?: boolean;
  23046. subdivisions?: number;
  23047. sideOrientation?: number;
  23048. frontUVs?: Vector4;
  23049. backUVs?: Vector4;
  23050. updatable?: boolean;
  23051. }, scene: Scene): Mesh;
  23052. /**
  23053. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23054. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23055. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23056. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23057. * * 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
  23058. * * 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
  23059. * * 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
  23060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23061. * * 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
  23062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23063. * * 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
  23064. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23065. * * 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
  23066. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23068. * @param name defines the name of the mesh
  23069. * @param options defines the options used to create the mesh
  23070. * @param scene defines the hosting scene
  23071. * @returns the ribbon mesh
  23072. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23073. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23074. */
  23075. static CreateRibbon(name: string, options: {
  23076. pathArray: Vector3[][];
  23077. closeArray?: boolean;
  23078. closePath?: boolean;
  23079. offset?: number;
  23080. updatable?: boolean;
  23081. sideOrientation?: number;
  23082. frontUVs?: Vector4;
  23083. backUVs?: Vector4;
  23084. instance?: Mesh;
  23085. invertUV?: boolean;
  23086. uvs?: Vector2[];
  23087. colors?: Color4[];
  23088. }, scene?: Nullable<Scene>): Mesh;
  23089. /**
  23090. * Creates a cylinder or a cone mesh
  23091. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23092. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23093. * * 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.
  23094. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23095. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23096. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23097. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23098. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23099. * * 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).
  23100. * * 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
  23101. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23102. * * 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
  23103. * * 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.
  23104. * * If `enclose` is false, a ring surface is one element.
  23105. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23106. * * 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
  23107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23108. * * 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
  23109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23110. * @param name defines the name of the mesh
  23111. * @param options defines the options used to create the mesh
  23112. * @param scene defines the hosting scene
  23113. * @returns the cylinder mesh
  23114. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23115. */
  23116. static CreateCylinder(name: string, options: {
  23117. height?: number;
  23118. diameterTop?: number;
  23119. diameterBottom?: number;
  23120. diameter?: number;
  23121. tessellation?: number;
  23122. subdivisions?: number;
  23123. arc?: number;
  23124. faceColors?: Color4[];
  23125. faceUV?: Vector4[];
  23126. updatable?: boolean;
  23127. hasRings?: boolean;
  23128. enclose?: boolean;
  23129. sideOrientation?: number;
  23130. frontUVs?: Vector4;
  23131. backUVs?: Vector4;
  23132. }, scene: any): Mesh;
  23133. /**
  23134. * Creates a torus mesh
  23135. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23136. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23137. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23139. * * 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
  23140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23141. * @param name defines the name of the mesh
  23142. * @param options defines the options used to create the mesh
  23143. * @param scene defines the hosting scene
  23144. * @returns the torus mesh
  23145. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23146. */
  23147. static CreateTorus(name: string, options: {
  23148. diameter?: number;
  23149. thickness?: number;
  23150. tessellation?: number;
  23151. updatable?: boolean;
  23152. sideOrientation?: number;
  23153. frontUVs?: Vector4;
  23154. backUVs?: Vector4;
  23155. }, scene: any): Mesh;
  23156. /**
  23157. * Creates a torus knot mesh
  23158. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23159. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23160. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23161. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23163. * * 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
  23164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23165. * @param name defines the name of the mesh
  23166. * @param options defines the options used to create the mesh
  23167. * @param scene defines the hosting scene
  23168. * @returns the torus knot mesh
  23169. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23170. */
  23171. static CreateTorusKnot(name: string, options: {
  23172. radius?: number;
  23173. tube?: number;
  23174. radialSegments?: number;
  23175. tubularSegments?: number;
  23176. p?: number;
  23177. q?: number;
  23178. updatable?: boolean;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }, scene: any): Mesh;
  23183. /**
  23184. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23185. * * 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
  23186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23187. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23188. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23189. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23191. * * 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
  23192. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23195. * @param name defines the name of the new line system
  23196. * @param options defines the options used to create the line system
  23197. * @param scene defines the hosting scene
  23198. * @returns a new line system mesh
  23199. */
  23200. static CreateLineSystem(name: string, options: {
  23201. lines: Vector3[][];
  23202. updatable?: boolean;
  23203. instance?: Nullable<LinesMesh>;
  23204. colors?: Nullable<Color4[][]>;
  23205. useVertexAlpha?: boolean;
  23206. }, scene: Nullable<Scene>): LinesMesh;
  23207. /**
  23208. * Creates a line mesh
  23209. * 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
  23210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23211. * * The parameter `points` is an array successive Vector3
  23212. * * 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
  23213. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23214. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23215. * * When updating an instance, remember that only point positions can change, not the number of points
  23216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23217. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23218. * @param name defines the name of the new line system
  23219. * @param options defines the options used to create the line system
  23220. * @param scene defines the hosting scene
  23221. * @returns a new line mesh
  23222. */
  23223. static CreateLines(name: string, options: {
  23224. points: Vector3[];
  23225. updatable?: boolean;
  23226. instance?: Nullable<LinesMesh>;
  23227. colors?: Color4[];
  23228. useVertexAlpha?: boolean;
  23229. }, scene?: Nullable<Scene>): LinesMesh;
  23230. /**
  23231. * Creates a dashed line mesh
  23232. * * 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
  23233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23234. * * The parameter `points` is an array successive Vector3
  23235. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23236. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23237. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23238. * * 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
  23239. * * When updating an instance, remember that only point positions can change, not the number of points
  23240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23241. * @param name defines the name of the mesh
  23242. * @param options defines the options used to create the mesh
  23243. * @param scene defines the hosting scene
  23244. * @returns the dashed line mesh
  23245. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23246. */
  23247. static CreateDashedLines(name: string, options: {
  23248. points: Vector3[];
  23249. dashSize?: number;
  23250. gapSize?: number;
  23251. dashNb?: number;
  23252. updatable?: boolean;
  23253. instance?: LinesMesh;
  23254. }, scene?: Nullable<Scene>): LinesMesh;
  23255. /**
  23256. * 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.
  23257. * * 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.
  23258. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23259. * * 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.
  23260. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23261. * * 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
  23262. * * 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
  23263. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23265. * * 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
  23266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23268. * @param name defines the name of the mesh
  23269. * @param options defines the options used to create the mesh
  23270. * @param scene defines the hosting scene
  23271. * @returns the extruded shape mesh
  23272. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23273. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23274. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23275. */
  23276. static ExtrudeShape(name: string, options: {
  23277. shape: Vector3[];
  23278. path: Vector3[];
  23279. scale?: number;
  23280. rotation?: number;
  23281. cap?: number;
  23282. updatable?: boolean;
  23283. sideOrientation?: number;
  23284. frontUVs?: Vector4;
  23285. backUVs?: Vector4;
  23286. instance?: Mesh;
  23287. invertUV?: boolean;
  23288. }, scene?: Nullable<Scene>): Mesh;
  23289. /**
  23290. * Creates an custom extruded shape mesh.
  23291. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23292. * * 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.
  23293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23294. * * 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
  23295. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23296. * * 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
  23297. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23298. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23299. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23300. * * 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
  23301. * * 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
  23302. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23304. * * 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
  23305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23307. * @param name defines the name of the mesh
  23308. * @param options defines the options used to create the mesh
  23309. * @param scene defines the hosting scene
  23310. * @returns the custom extruded shape mesh
  23311. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23312. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23314. */
  23315. static ExtrudeShapeCustom(name: string, options: {
  23316. shape: Vector3[];
  23317. path: Vector3[];
  23318. scaleFunction?: any;
  23319. rotationFunction?: any;
  23320. ribbonCloseArray?: boolean;
  23321. ribbonClosePath?: boolean;
  23322. cap?: number;
  23323. updatable?: boolean;
  23324. sideOrientation?: number;
  23325. frontUVs?: Vector4;
  23326. backUVs?: Vector4;
  23327. instance?: Mesh;
  23328. invertUV?: boolean;
  23329. }, scene: Scene): Mesh;
  23330. /**
  23331. * Creates lathe mesh.
  23332. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23333. * * 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
  23334. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23335. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23336. * * 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
  23337. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23338. * * 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
  23339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23340. * * 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
  23341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23343. * @param name defines the name of the mesh
  23344. * @param options defines the options used to create the mesh
  23345. * @param scene defines the hosting scene
  23346. * @returns the lathe mesh
  23347. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23348. */
  23349. static CreateLathe(name: string, options: {
  23350. shape: Vector3[];
  23351. radius?: number;
  23352. tessellation?: number;
  23353. arc?: number;
  23354. closed?: boolean;
  23355. updatable?: boolean;
  23356. sideOrientation?: number;
  23357. frontUVs?: Vector4;
  23358. backUVs?: Vector4;
  23359. cap?: number;
  23360. invertUV?: boolean;
  23361. }, scene: Scene): Mesh;
  23362. /**
  23363. * Creates a plane mesh
  23364. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23365. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23366. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23368. * * 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
  23369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23370. * @param name defines the name of the mesh
  23371. * @param options defines the options used to create the mesh
  23372. * @param scene defines the hosting scene
  23373. * @returns the plane mesh
  23374. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23375. */
  23376. static CreatePlane(name: string, options: {
  23377. size?: number;
  23378. width?: number;
  23379. height?: number;
  23380. sideOrientation?: number;
  23381. frontUVs?: Vector4;
  23382. backUVs?: Vector4;
  23383. updatable?: boolean;
  23384. sourcePlane?: Plane;
  23385. }, scene: Scene): Mesh;
  23386. /**
  23387. * Creates a ground mesh
  23388. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23389. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23391. * @param name defines the name of the mesh
  23392. * @param options defines the options used to create the mesh
  23393. * @param scene defines the hosting scene
  23394. * @returns the ground mesh
  23395. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23396. */
  23397. static CreateGround(name: string, options: {
  23398. width?: number;
  23399. height?: number;
  23400. subdivisions?: number;
  23401. subdivisionsX?: number;
  23402. subdivisionsY?: number;
  23403. updatable?: boolean;
  23404. }, scene: any): Mesh;
  23405. /**
  23406. * Creates a tiled ground mesh
  23407. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23408. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23409. * * 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
  23410. * * 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
  23411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23412. * @param name defines the name of the mesh
  23413. * @param options defines the options used to create the mesh
  23414. * @param scene defines the hosting scene
  23415. * @returns the tiled ground mesh
  23416. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23417. */
  23418. static CreateTiledGround(name: string, options: {
  23419. xmin: number;
  23420. zmin: number;
  23421. xmax: number;
  23422. zmax: number;
  23423. subdivisions?: {
  23424. w: number;
  23425. h: number;
  23426. };
  23427. precision?: {
  23428. w: number;
  23429. h: number;
  23430. };
  23431. updatable?: boolean;
  23432. }, scene: Scene): Mesh;
  23433. /**
  23434. * Creates a ground mesh from a height map
  23435. * * The parameter `url` sets the URL of the height map image resource.
  23436. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23437. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23438. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23439. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23440. * * 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.
  23441. * * 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).
  23442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23443. * @param name defines the name of the mesh
  23444. * @param url defines the url to the height map
  23445. * @param options defines the options used to create the mesh
  23446. * @param scene defines the hosting scene
  23447. * @returns the ground mesh
  23448. * @see http://doc.babylonjs.com/babylon101/height_map
  23449. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23450. */
  23451. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23452. width?: number;
  23453. height?: number;
  23454. subdivisions?: number;
  23455. minHeight?: number;
  23456. maxHeight?: number;
  23457. colorFilter?: Color3;
  23458. updatable?: boolean;
  23459. onReady?: (mesh: GroundMesh) => void;
  23460. }, scene: Scene): GroundMesh;
  23461. /**
  23462. * Creates a polygon mesh
  23463. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23464. * * 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
  23465. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23467. * * 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)
  23468. * * Remember you can only change the shape positions, not their number when updating a polygon
  23469. * @param name defines the name of the mesh
  23470. * @param options defines the options used to create the mesh
  23471. * @param scene defines the hosting scene
  23472. * @returns the polygon mesh
  23473. */
  23474. static CreatePolygon(name: string, options: {
  23475. shape: Vector3[];
  23476. holes?: Vector3[][];
  23477. depth?: number;
  23478. faceUV?: Vector4[];
  23479. faceColors?: Color4[];
  23480. updatable?: boolean;
  23481. sideOrientation?: number;
  23482. frontUVs?: Vector4;
  23483. backUVs?: Vector4;
  23484. }, scene: Scene): Mesh;
  23485. /**
  23486. * Creates an extruded polygon mesh, with depth in the Y direction.
  23487. * * 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)
  23488. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23489. * @param name defines the name of the mesh
  23490. * @param options defines the options used to create the mesh
  23491. * @param scene defines the hosting scene
  23492. * @returns the polygon mesh
  23493. */
  23494. static ExtrudePolygon(name: string, options: {
  23495. shape: Vector3[];
  23496. holes?: Vector3[][];
  23497. depth?: number;
  23498. faceUV?: Vector4[];
  23499. faceColors?: Color4[];
  23500. updatable?: boolean;
  23501. sideOrientation?: number;
  23502. frontUVs?: Vector4;
  23503. backUVs?: Vector4;
  23504. }, scene: Scene): Mesh;
  23505. /**
  23506. * Creates a tube mesh.
  23507. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23508. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23509. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23510. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23511. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23512. * * 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)
  23513. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23514. * * 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
  23515. * * 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
  23516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23517. * * 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
  23518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23520. * @param name defines the name of the mesh
  23521. * @param options defines the options used to create the mesh
  23522. * @param scene defines the hosting scene
  23523. * @returns the tube mesh
  23524. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23525. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23526. */
  23527. static CreateTube(name: string, options: {
  23528. path: Vector3[];
  23529. radius?: number;
  23530. tessellation?: number;
  23531. radiusFunction?: {
  23532. (i: number, distance: number): number;
  23533. };
  23534. cap?: number;
  23535. arc?: number;
  23536. updatable?: boolean;
  23537. sideOrientation?: number;
  23538. frontUVs?: Vector4;
  23539. backUVs?: Vector4;
  23540. instance?: Mesh;
  23541. invertUV?: boolean;
  23542. }, scene: Scene): Mesh;
  23543. /**
  23544. * Creates a polyhedron mesh
  23545. * * 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
  23546. * * The parameter `size` (positive float, default 1) sets the polygon size
  23547. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23548. * * 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`
  23549. * * 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
  23550. * * 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)`)
  23551. * * 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
  23552. * * 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
  23553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23554. * * 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
  23555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23556. * @param name defines the name of the mesh
  23557. * @param options defines the options used to create the mesh
  23558. * @param scene defines the hosting scene
  23559. * @returns the polyhedron mesh
  23560. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23561. */
  23562. static CreatePolyhedron(name: string, options: {
  23563. type?: number;
  23564. size?: number;
  23565. sizeX?: number;
  23566. sizeY?: number;
  23567. sizeZ?: number;
  23568. custom?: any;
  23569. faceUV?: Vector4[];
  23570. faceColors?: Color4[];
  23571. flat?: boolean;
  23572. updatable?: boolean;
  23573. sideOrientation?: number;
  23574. frontUVs?: Vector4;
  23575. backUVs?: Vector4;
  23576. }, scene: Scene): Mesh;
  23577. /**
  23578. * Creates a decal mesh.
  23579. * 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
  23580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23584. * @param name defines the name of the mesh
  23585. * @param sourceMesh defines the mesh where the decal must be applied
  23586. * @param options defines the options used to create the mesh
  23587. * @param scene defines the hosting scene
  23588. * @returns the decal mesh
  23589. * @see http://doc.babylonjs.com/how_to/decals
  23590. */
  23591. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23592. position?: Vector3;
  23593. normal?: Vector3;
  23594. size?: Vector3;
  23595. angle?: number;
  23596. }): Mesh;
  23597. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  23598. }
  23599. }
  23600. declare module BABYLON {
  23601. class MeshLODLevel {
  23602. distance: number;
  23603. mesh: Mesh;
  23604. constructor(distance: number, mesh: Mesh);
  23605. }
  23606. }
  23607. declare module BABYLON {
  23608. /**
  23609. * A simplifier interface for future simplification implementations.
  23610. */
  23611. interface ISimplifier {
  23612. /**
  23613. * Simplification of a given mesh according to the given settings.
  23614. * Since this requires computation, it is assumed that the function runs async.
  23615. * @param settings The settings of the simplification, including quality and distance
  23616. * @param successCallback A callback that will be called after the mesh was simplified.
  23617. * @param errorCallback in case of an error, this callback will be called. optional.
  23618. */
  23619. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23620. }
  23621. /**
  23622. * Expected simplification settings.
  23623. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23624. */
  23625. interface ISimplificationSettings {
  23626. quality: number;
  23627. distance: number;
  23628. optimizeMesh?: boolean;
  23629. }
  23630. class SimplificationSettings implements ISimplificationSettings {
  23631. quality: number;
  23632. distance: number;
  23633. optimizeMesh: boolean | undefined;
  23634. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23635. }
  23636. interface ISimplificationTask {
  23637. settings: Array<ISimplificationSettings>;
  23638. simplificationType: SimplificationType;
  23639. mesh: Mesh;
  23640. successCallback?: () => void;
  23641. parallelProcessing: boolean;
  23642. }
  23643. class SimplificationQueue {
  23644. private _simplificationArray;
  23645. running: boolean;
  23646. constructor();
  23647. addTask(task: ISimplificationTask): void;
  23648. executeNext(): void;
  23649. runSimplification(task: ISimplificationTask): void;
  23650. private getSimplifier(task);
  23651. }
  23652. /**
  23653. * The implemented types of simplification
  23654. * At the moment only Quadratic Error Decimation is implemented
  23655. */
  23656. enum SimplificationType {
  23657. /** Quadratic error decimation */
  23658. QUADRATIC = 0,
  23659. }
  23660. class DecimationTriangle {
  23661. vertices: Array<DecimationVertex>;
  23662. normal: Vector3;
  23663. error: Array<number>;
  23664. deleted: boolean;
  23665. isDirty: boolean;
  23666. borderFactor: number;
  23667. deletePending: boolean;
  23668. originalOffset: number;
  23669. constructor(vertices: Array<DecimationVertex>);
  23670. }
  23671. class DecimationVertex {
  23672. position: Vector3;
  23673. id: number;
  23674. q: QuadraticMatrix;
  23675. isBorder: boolean;
  23676. triangleStart: number;
  23677. triangleCount: number;
  23678. originalOffsets: Array<number>;
  23679. constructor(position: Vector3, id: number);
  23680. updatePosition(newPosition: Vector3): void;
  23681. }
  23682. class QuadraticMatrix {
  23683. data: Array<number>;
  23684. constructor(data?: Array<number>);
  23685. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23686. addInPlace(matrix: QuadraticMatrix): void;
  23687. addArrayInPlace(data: Array<number>): void;
  23688. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23689. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23690. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23691. }
  23692. class Reference {
  23693. vertexId: number;
  23694. triangleId: number;
  23695. constructor(vertexId: number, triangleId: number);
  23696. }
  23697. /**
  23698. * An implementation of the Quadratic Error simplification algorithm.
  23699. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23700. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23701. * @author RaananW
  23702. */
  23703. class QuadraticErrorSimplification implements ISimplifier {
  23704. private _mesh;
  23705. private triangles;
  23706. private vertices;
  23707. private references;
  23708. private _reconstructedMesh;
  23709. syncIterations: number;
  23710. aggressiveness: number;
  23711. decimationIterations: number;
  23712. boundingBoxEpsilon: number;
  23713. constructor(_mesh: Mesh);
  23714. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23715. private runDecimation(settings, submeshIndex, successCallback);
  23716. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23717. private init(callback);
  23718. private reconstructMesh(submeshIndex);
  23719. private initDecimatedMesh();
  23720. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23721. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23722. private identifyBorder();
  23723. private updateMesh(identifyBorders?);
  23724. private vertexError(q, point);
  23725. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23726. }
  23727. }
  23728. declare module BABYLON {
  23729. class Polygon {
  23730. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23731. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23732. static Parse(input: string): Vector2[];
  23733. static StartingAt(x: number, y: number): Path2;
  23734. }
  23735. class PolygonMeshBuilder {
  23736. private _points;
  23737. private _outlinepoints;
  23738. private _holes;
  23739. private _name;
  23740. private _scene;
  23741. private _epoints;
  23742. private _eholes;
  23743. private _addToepoint(points);
  23744. constructor(name: string, contours: Path2, scene: Scene);
  23745. constructor(name: string, contours: Vector2[], scene: Scene);
  23746. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23747. build(updatable?: boolean, depth?: number): Mesh;
  23748. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23749. }
  23750. }
  23751. declare module BABYLON {
  23752. class BaseSubMesh {
  23753. readonly effect: Nullable<Effect>;
  23754. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23755. }
  23756. class SubMesh extends BaseSubMesh implements ICullable {
  23757. materialIndex: number;
  23758. verticesStart: number;
  23759. verticesCount: number;
  23760. indexStart: number;
  23761. indexCount: number;
  23762. linesIndexCount: number;
  23763. private _mesh;
  23764. private _renderingMesh;
  23765. private _boundingInfo;
  23766. private _linesIndexBuffer;
  23767. private _currentMaterial;
  23768. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23769. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23770. readonly IsGlobal: boolean;
  23771. /**
  23772. * Returns the submesh BoudingInfo object.
  23773. */
  23774. getBoundingInfo(): BoundingInfo;
  23775. /**
  23776. * Sets the submesh BoundingInfo.
  23777. * Return the SubMesh.
  23778. */
  23779. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23780. /**
  23781. * Returns the mesh of the current submesh.
  23782. */
  23783. getMesh(): AbstractMesh;
  23784. /**
  23785. * Returns the rendering mesh of the submesh.
  23786. */
  23787. getRenderingMesh(): Mesh;
  23788. /**
  23789. * Returns the submesh material.
  23790. */
  23791. getMaterial(): Nullable<Material>;
  23792. /**
  23793. * Sets a new updated BoundingInfo object to the submesh.
  23794. * Returns the SubMesh.
  23795. */
  23796. refreshBoundingInfo(): SubMesh;
  23797. /**
  23798. * Updates the submesh BoundingInfo.
  23799. * Returns the Submesh.
  23800. */
  23801. updateBoundingInfo(world: Matrix): SubMesh;
  23802. /**
  23803. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23804. * Boolean returned.
  23805. */
  23806. isInFrustum(frustumPlanes: Plane[]): boolean;
  23807. /**
  23808. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23809. * Boolean returned.
  23810. */
  23811. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23812. /**
  23813. * Renders the submesh.
  23814. * Returns it.
  23815. */
  23816. render(enableAlphaMode: boolean): SubMesh;
  23817. /**
  23818. * Returns a new Index Buffer.
  23819. * Type returned : WebGLBuffer.
  23820. */
  23821. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23822. /**
  23823. * True is the passed Ray intersects the submesh bounding box.
  23824. * Boolean returned.
  23825. */
  23826. canIntersects(ray: Ray): boolean;
  23827. /**
  23828. * Returns an object IntersectionInfo.
  23829. */
  23830. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23831. /**
  23832. * Creates a new Submesh from the passed Mesh.
  23833. */
  23834. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23835. /**
  23836. * Disposes the Submesh.
  23837. * Returns nothing.
  23838. */
  23839. dispose(): void;
  23840. /**
  23841. * Creates a new Submesh from the passed parameters :
  23842. * - materialIndex (integer) : the index of the main mesh material.
  23843. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23844. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23845. * - mesh (Mesh) : the main mesh to create the submesh from.
  23846. * - renderingMesh (optional Mesh) : rendering mesh.
  23847. */
  23848. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23849. }
  23850. }
  23851. declare module BABYLON {
  23852. class TransformNode extends Node {
  23853. static BILLBOARDMODE_NONE: number;
  23854. static BILLBOARDMODE_X: number;
  23855. static BILLBOARDMODE_Y: number;
  23856. static BILLBOARDMODE_Z: number;
  23857. static BILLBOARDMODE_ALL: number;
  23858. private _forward;
  23859. private _forwardInverted;
  23860. private _up;
  23861. private _right;
  23862. private _rightInverted;
  23863. private _rotation;
  23864. private _rotationQuaternion;
  23865. protected _scaling: Vector3;
  23866. protected _isDirty: boolean;
  23867. private _transformToBoneReferal;
  23868. billboardMode: number;
  23869. scalingDeterminant: number;
  23870. infiniteDistance: boolean;
  23871. /**
  23872. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23873. * By default the system will update normals to compensate
  23874. */
  23875. ignoreNonUniformScaling: boolean;
  23876. position: Vector3;
  23877. private _localWorld;
  23878. private _absolutePosition;
  23879. private _pivotMatrix;
  23880. private _pivotMatrixInverse;
  23881. private _postMultiplyPivotMatrix;
  23882. protected _isWorldMatrixFrozen: boolean;
  23883. /**
  23884. * An event triggered after the world matrix is updated
  23885. */
  23886. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23887. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23888. /**
  23889. * Gets a string idenfifying the name of the class
  23890. * @returns "TransformNode" string
  23891. */
  23892. getClassName(): string;
  23893. /**
  23894. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23895. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23896. * Default : (0.0, 0.0, 0.0)
  23897. */
  23898. rotation: Vector3;
  23899. /**
  23900. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23901. * Default : (1.0, 1.0, 1.0)
  23902. */
  23903. /**
  23904. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23905. * Default : (1.0, 1.0, 1.0)
  23906. */
  23907. scaling: Vector3;
  23908. /**
  23909. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23910. * It's null by default.
  23911. * 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)
  23912. */
  23913. rotationQuaternion: Nullable<Quaternion>;
  23914. /**
  23915. * The forward direction of that transform in world space.
  23916. */
  23917. readonly forward: Vector3;
  23918. /**
  23919. * The up direction of that transform in world space.
  23920. */
  23921. readonly up: Vector3;
  23922. /**
  23923. * The right direction of that transform in world space.
  23924. */
  23925. readonly right: Vector3;
  23926. /**
  23927. * Returns the latest update of the World matrix
  23928. * Returns a Matrix.
  23929. */
  23930. getWorldMatrix(): Matrix;
  23931. /** @hidden */
  23932. /**
  23933. * Returns directly the latest state of the mesh World matrix.
  23934. * A Matrix is returned.
  23935. */
  23936. readonly worldMatrixFromCache: Matrix;
  23937. /**
  23938. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23939. * Returns the TransformNode.
  23940. */
  23941. updatePoseMatrix(matrix: Matrix): TransformNode;
  23942. /**
  23943. * Returns the mesh Pose matrix.
  23944. * Returned object : Matrix
  23945. */
  23946. getPoseMatrix(): Matrix;
  23947. markAsDirty(property: string): TransformNode;
  23948. /**
  23949. * Returns the current mesh absolute position.
  23950. * Retuns a Vector3.
  23951. */
  23952. readonly absolutePosition: Vector3;
  23953. /**
  23954. * Sets a new matrix to apply before all other transformation
  23955. * @param matrix defines the transform matrix
  23956. * @returns the current TransformNode
  23957. */
  23958. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23959. /**
  23960. * Sets a new pivot matrix to the current node
  23961. * @param matrix defines the new pivot matrix to use
  23962. * @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
  23963. * @returns the current TransformNode
  23964. */
  23965. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23966. /**
  23967. * Returns the mesh pivot matrix.
  23968. * Default : Identity.
  23969. * A Matrix is returned.
  23970. */
  23971. getPivotMatrix(): Matrix;
  23972. /**
  23973. * Prevents the World matrix to be computed any longer.
  23974. * Returns the TransformNode.
  23975. */
  23976. freezeWorldMatrix(): TransformNode;
  23977. /**
  23978. * Allows back the World matrix computation.
  23979. * Returns the TransformNode.
  23980. */
  23981. unfreezeWorldMatrix(): this;
  23982. /**
  23983. * True if the World matrix has been frozen.
  23984. * Returns a boolean.
  23985. */
  23986. readonly isWorldMatrixFrozen: boolean;
  23987. /**
  23988. * Retuns the mesh absolute position in the World.
  23989. * Returns a Vector3.
  23990. */
  23991. getAbsolutePosition(): Vector3;
  23992. /**
  23993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23994. * Returns the TransformNode.
  23995. */
  23996. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23997. /**
  23998. * Sets the mesh position in its local space.
  23999. * Returns the TransformNode.
  24000. */
  24001. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24002. /**
  24003. * Returns the mesh position in the local space from the current World matrix values.
  24004. * Returns a new Vector3.
  24005. */
  24006. getPositionExpressedInLocalSpace(): Vector3;
  24007. /**
  24008. * Translates the mesh along the passed Vector3 in its local space.
  24009. * Returns the TransformNode.
  24010. */
  24011. locallyTranslate(vector3: Vector3): TransformNode;
  24012. private static _lookAtVectorCache;
  24013. /**
  24014. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24015. * @param targetPoint the position (must be in same space as current mesh) to look at
  24016. * @param yawCor optional yaw (y-axis) correction in radians
  24017. * @param pitchCor optional pitch (x-axis) correction in radians
  24018. * @param rollCor optional roll (z-axis) correction in radians
  24019. * @param space the choosen space of the target
  24020. * @returns the TransformNode.
  24021. */
  24022. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24023. /**
  24024. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24025. * This Vector3 is expressed in the World space.
  24026. */
  24027. getDirection(localAxis: Vector3): Vector3;
  24028. /**
  24029. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24030. * localAxis is expressed in the mesh local space.
  24031. * result is computed in the Wordl space from the mesh World matrix.
  24032. * Returns the TransformNode.
  24033. */
  24034. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24035. /**
  24036. * Sets a new pivot point to the current node
  24037. * @param point defines the new pivot point to use
  24038. * @param space defines if the point is in world or local space (local by default)
  24039. * @returns the current TransformNode
  24040. */
  24041. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24042. /**
  24043. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24044. */
  24045. getPivotPoint(): Vector3;
  24046. /**
  24047. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24048. * Returns the TransformNode.
  24049. */
  24050. getPivotPointToRef(result: Vector3): TransformNode;
  24051. /**
  24052. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24053. */
  24054. getAbsolutePivotPoint(): Vector3;
  24055. /**
  24056. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24057. * Returns the TransformNode.
  24058. */
  24059. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24060. /**
  24061. * Defines the passed node as the parent of the current node.
  24062. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24063. * Returns the TransformNode.
  24064. */
  24065. setParent(node: Nullable<Node>): TransformNode;
  24066. private _nonUniformScaling;
  24067. readonly nonUniformScaling: boolean;
  24068. /**
  24069. * Attach the current TransformNode to another TransformNode associated with a bone
  24070. * @param bone Bone affecting the TransformNode
  24071. * @param affectedTransformNode TransformNode associated with the bone
  24072. */
  24073. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24074. detachFromBone(): TransformNode;
  24075. private static _rotationAxisCache;
  24076. /**
  24077. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24078. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24079. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24080. * The passed axis is also normalized.
  24081. * Returns the TransformNode.
  24082. */
  24083. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24084. /**
  24085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24086. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24087. * The passed axis is also normalized.
  24088. * Returns the TransformNode.
  24089. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24090. */
  24091. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24092. /**
  24093. * Translates the mesh along the axis vector for the passed distance in the given space.
  24094. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24095. * Returns the TransformNode.
  24096. */
  24097. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24098. /**
  24099. * Adds a rotation step to the mesh current rotation.
  24100. * x, y, z are Euler angles expressed in radians.
  24101. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24102. * This means this rotation is made in the mesh local space only.
  24103. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24104. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24105. * ```javascript
  24106. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24107. * ```
  24108. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24109. * 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.
  24110. * Returns the TransformNode.
  24111. */
  24112. addRotation(x: number, y: number, z: number): TransformNode;
  24113. /**
  24114. * Computes the mesh World matrix and returns it.
  24115. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24116. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24117. * If the parameter `force`is set to `true`, the actual computation is done.
  24118. * Returns the mesh World Matrix.
  24119. */
  24120. computeWorldMatrix(force?: boolean): Matrix;
  24121. protected _afterComputeWorldMatrix(): void;
  24122. /**
  24123. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24124. * @param func: callback function to add
  24125. *
  24126. * Returns the TransformNode.
  24127. */
  24128. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24129. /**
  24130. * Removes a registered callback function.
  24131. * Returns the TransformNode.
  24132. */
  24133. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24134. /**
  24135. * Clone the current transform node
  24136. * Returns the new transform node
  24137. * @param name Name of the new clone
  24138. * @param newParent New parent for the clone
  24139. * @param doNotCloneChildren Do not clone children hierarchy
  24140. */
  24141. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24142. serialize(currentSerializationObject?: any): any;
  24143. /**
  24144. * Returns a new TransformNode object parsed from the source provided.
  24145. * The parameter `parsedMesh` is the source.
  24146. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24147. */
  24148. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24149. /**
  24150. * Releases resources associated with this transform node.
  24151. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24152. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24153. */
  24154. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24155. }
  24156. }
  24157. declare module BABYLON {
  24158. class VertexBuffer {
  24159. /** @hidden */
  24160. private _kind;
  24161. private _size;
  24162. private _ownsBuffer;
  24163. private _instanced;
  24164. private _instanceDivisor;
  24165. /**
  24166. * The byte type.
  24167. */
  24168. static readonly BYTE: number;
  24169. /**
  24170. * The unsigned byte type.
  24171. */
  24172. static readonly UNSIGNED_BYTE: number;
  24173. /**
  24174. * The short type.
  24175. */
  24176. static readonly SHORT: number;
  24177. /**
  24178. * The unsigned short type.
  24179. */
  24180. static readonly UNSIGNED_SHORT: number;
  24181. /**
  24182. * The integer type.
  24183. */
  24184. static readonly INT: number;
  24185. /**
  24186. * The unsigned integer type.
  24187. */
  24188. static readonly UNSIGNED_INT: number;
  24189. /**
  24190. * The float type.
  24191. */
  24192. static readonly FLOAT: number;
  24193. /**
  24194. * Gets or sets the instance divisor when in instanced mode
  24195. */
  24196. instanceDivisor: number;
  24197. /**
  24198. * Gets the byte stride.
  24199. */
  24200. readonly byteStride: number;
  24201. /**
  24202. * Gets the byte offset.
  24203. */
  24204. readonly byteOffset: number;
  24205. /**
  24206. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24207. */
  24208. readonly normalized: boolean;
  24209. /**
  24210. * Gets the data type of each component in the array.
  24211. */
  24212. readonly type: number;
  24213. /**
  24214. * Constructor
  24215. * @param engine the engine
  24216. * @param data the data to use for this vertex buffer
  24217. * @param kind the vertex buffer kind
  24218. * @param updatable whether the data is updatable
  24219. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24220. * @param stride the stride (optional)
  24221. * @param instanced whether the buffer is instanced (optional)
  24222. * @param offset the offset of the data (optional)
  24223. * @param size the number of components (optional)
  24224. * @param type the type of the component (optional)
  24225. * @param normalized whether the data contains normalized data (optional)
  24226. * @param useBytes set to true if stride and offset are in bytes (optional)
  24227. */
  24228. 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);
  24229. /**
  24230. * Returns the kind of the VertexBuffer (string).
  24231. */
  24232. getKind(): string;
  24233. /**
  24234. * Boolean : is the VertexBuffer updatable ?
  24235. */
  24236. isUpdatable(): boolean;
  24237. /**
  24238. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24239. */
  24240. getData(): Nullable<DataArray>;
  24241. /**
  24242. * Returns the WebGLBuffer associated to the VertexBuffer.
  24243. */
  24244. getBuffer(): Nullable<WebGLBuffer>;
  24245. /**
  24246. * Returns the stride as a multiple of the type byte length.
  24247. * DEPRECATED. Use byteStride instead.
  24248. */
  24249. getStrideSize(): number;
  24250. /**
  24251. * Returns the offset as a multiple of the type byte length.
  24252. * DEPRECATED. Use byteOffset instead.
  24253. */
  24254. getOffset(): number;
  24255. /**
  24256. * Returns the number of components per vertex attribute (integer).
  24257. */
  24258. getSize(): number;
  24259. /**
  24260. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24261. */
  24262. getIsInstanced(): boolean;
  24263. /**
  24264. * Returns the instancing divisor, zero for non-instanced (integer).
  24265. */
  24266. getInstanceDivisor(): number;
  24267. /**
  24268. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24269. * Returns the created WebGLBuffer.
  24270. */
  24271. create(data?: DataArray): void;
  24272. /**
  24273. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24274. * This function will create a new buffer if the current one is not updatable
  24275. * Returns the updated WebGLBuffer.
  24276. */
  24277. update(data: DataArray): void;
  24278. /**
  24279. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24280. * Returns the directly updated WebGLBuffer.
  24281. * @param data the new data
  24282. * @param offset the new offset
  24283. * @param useBytes set to true if the offset is in bytes
  24284. */
  24285. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24286. /**
  24287. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24288. */
  24289. dispose(): void;
  24290. /**
  24291. * Enumerates each value of this vertex buffer as numbers.
  24292. * @param count the number of values to enumerate
  24293. * @param callback the callback function called for each value
  24294. */
  24295. forEach(count: number, callback: (value: number, index: number) => void): void;
  24296. private static _PositionKind;
  24297. private static _NormalKind;
  24298. private static _TangentKind;
  24299. private static _UVKind;
  24300. private static _UV2Kind;
  24301. private static _UV3Kind;
  24302. private static _UV4Kind;
  24303. private static _UV5Kind;
  24304. private static _UV6Kind;
  24305. private static _ColorKind;
  24306. private static _MatricesIndicesKind;
  24307. private static _MatricesWeightsKind;
  24308. private static _MatricesIndicesExtraKind;
  24309. private static _MatricesWeightsExtraKind;
  24310. static readonly PositionKind: string;
  24311. static readonly NormalKind: string;
  24312. static readonly TangentKind: string;
  24313. static readonly UVKind: string;
  24314. static readonly UV2Kind: string;
  24315. static readonly UV3Kind: string;
  24316. static readonly UV4Kind: string;
  24317. static readonly UV5Kind: string;
  24318. static readonly UV6Kind: string;
  24319. static readonly ColorKind: string;
  24320. static readonly MatricesIndicesKind: string;
  24321. static readonly MatricesWeightsKind: string;
  24322. static readonly MatricesIndicesExtraKind: string;
  24323. static readonly MatricesWeightsExtraKind: string;
  24324. /**
  24325. * Deduces the stride given a kind.
  24326. * @param kind The kind string to deduce
  24327. * @returns The deduced stride
  24328. */
  24329. static DeduceStride(kind: string): number;
  24330. /**
  24331. * Gets the byte length of the given type.
  24332. * @param type the type
  24333. * @returns the number of bytes
  24334. */
  24335. static GetTypeByteLength(type: number): number;
  24336. /**
  24337. * Enumerates each value of the given parameters as numbers.
  24338. * @param data the data to enumerate
  24339. * @param byteOffset the byte offset of the data
  24340. * @param byteStride the byte stride of the data
  24341. * @param componentCount the number of components per element
  24342. * @param componentType the type of the component
  24343. * @param count the total number of components
  24344. * @param normalized whether the data is normalized
  24345. * @param callback the callback function called for each value
  24346. */
  24347. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24348. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  24349. }
  24350. }
  24351. declare module BABYLON {
  24352. interface PhysicsImpostorJoint {
  24353. mainImpostor: PhysicsImpostor;
  24354. connectedImpostor: PhysicsImpostor;
  24355. joint: PhysicsJoint;
  24356. }
  24357. class PhysicsEngine {
  24358. private _physicsPlugin;
  24359. gravity: Vector3;
  24360. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24361. setGravity(gravity: Vector3): void;
  24362. /**
  24363. * Set the time step of the physics engine.
  24364. * default is 1/60.
  24365. * To slow it down, enter 1/600 for example.
  24366. * To speed it up, 1/30
  24367. * @param {number} newTimeStep the new timestep to apply to this world.
  24368. */
  24369. setTimeStep(newTimeStep?: number): void;
  24370. /**
  24371. * Get the time step of the physics engine.
  24372. */
  24373. getTimeStep(): number;
  24374. dispose(): void;
  24375. getPhysicsPluginName(): string;
  24376. static Epsilon: number;
  24377. private _impostors;
  24378. private _joints;
  24379. /**
  24380. * Adding a new impostor for the impostor tracking.
  24381. * This will be done by the impostor itself.
  24382. * @param {PhysicsImpostor} impostor the impostor to add
  24383. */
  24384. addImpostor(impostor: PhysicsImpostor): void;
  24385. /**
  24386. * Remove an impostor from the engine.
  24387. * This impostor and its mesh will not longer be updated by the physics engine.
  24388. * @param {PhysicsImpostor} impostor the impostor to remove
  24389. */
  24390. removeImpostor(impostor: PhysicsImpostor): void;
  24391. /**
  24392. * Add a joint to the physics engine
  24393. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24394. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24395. * @param {PhysicsJoint} the joint that will connect both impostors.
  24396. */
  24397. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24398. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24399. /**
  24400. * Called by the scene. no need to call it.
  24401. */
  24402. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24403. getImpostors(): Array<PhysicsImpostor>;
  24404. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24405. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24406. }
  24407. interface IPhysicsEnginePlugin {
  24408. world: any;
  24409. name: string;
  24410. setGravity(gravity: Vector3): void;
  24411. setTimeStep(timeStep: number): void;
  24412. getTimeStep(): number;
  24413. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24415. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24416. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24417. removePhysicsBody(impostor: PhysicsImpostor): void;
  24418. generateJoint(joint: PhysicsImpostorJoint): void;
  24419. removeJoint(joint: PhysicsImpostorJoint): void;
  24420. isSupported(): boolean;
  24421. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24422. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24423. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24424. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24425. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24426. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24427. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24428. getBodyMass(impostor: PhysicsImpostor): number;
  24429. getBodyFriction(impostor: PhysicsImpostor): number;
  24430. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24431. getBodyRestitution(impostor: PhysicsImpostor): number;
  24432. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24433. sleepBody(impostor: PhysicsImpostor): void;
  24434. wakeUpBody(impostor: PhysicsImpostor): void;
  24435. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24436. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24437. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24438. getRadius(impostor: PhysicsImpostor): number;
  24439. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24441. dispose(): void;
  24442. }
  24443. }
  24444. declare module BABYLON {
  24445. class PhysicsHelper {
  24446. private _scene;
  24447. private _physicsEngine;
  24448. constructor(scene: Scene);
  24449. /**
  24450. * @param {Vector3} origin the origin of the explosion
  24451. * @param {number} radius the explosion radius
  24452. * @param {number} strength the explosion strength
  24453. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24454. */
  24455. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24456. /**
  24457. * @param {Vector3} origin the origin of the explosion
  24458. * @param {number} radius the explosion radius
  24459. * @param {number} strength the explosion strength
  24460. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24461. */
  24462. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24463. /**
  24464. * @param {Vector3} origin the origin of the explosion
  24465. * @param {number} radius the explosion radius
  24466. * @param {number} strength the explosion strength
  24467. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24468. */
  24469. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24470. /**
  24471. * @param {Vector3} origin the origin of the updraft
  24472. * @param {number} radius the radius of the updraft
  24473. * @param {number} strength the strength of the updraft
  24474. * @param {number} height the height of the updraft
  24475. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24476. */
  24477. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24478. /**
  24479. * @param {Vector3} origin the of the vortex
  24480. * @param {number} radius the radius of the vortex
  24481. * @param {number} strength the strength of the vortex
  24482. * @param {number} height the height of the vortex
  24483. */
  24484. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24485. }
  24486. /***** Radial explosion *****/
  24487. class PhysicsRadialExplosionEvent {
  24488. private _scene;
  24489. private _sphere;
  24490. private _sphereOptions;
  24491. private _rays;
  24492. private _dataFetched;
  24493. constructor(scene: Scene);
  24494. /**
  24495. * Returns the data related to the radial explosion event (sphere & rays).
  24496. * @returns {PhysicsRadialExplosionEventData}
  24497. */
  24498. getData(): PhysicsRadialExplosionEventData;
  24499. /**
  24500. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24501. * @param impostor
  24502. * @param {Vector3} origin the origin of the explosion
  24503. * @param {number} radius the explosion radius
  24504. * @param {number} strength the explosion strength
  24505. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24506. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24507. */
  24508. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24509. /**
  24510. * Disposes the sphere.
  24511. * @param {bolean} force
  24512. */
  24513. dispose(force?: boolean): void;
  24514. /*** Helpers ***/
  24515. private _prepareSphere();
  24516. private _intersectsWithSphere(impostor, origin, radius);
  24517. }
  24518. /***** Gravitational Field *****/
  24519. class PhysicsGravitationalFieldEvent {
  24520. private _physicsHelper;
  24521. private _scene;
  24522. private _origin;
  24523. private _radius;
  24524. private _strength;
  24525. private _falloff;
  24526. private _tickCallback;
  24527. private _sphere;
  24528. private _dataFetched;
  24529. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24530. /**
  24531. * Returns the data related to the gravitational field event (sphere).
  24532. * @returns {PhysicsGravitationalFieldEventData}
  24533. */
  24534. getData(): PhysicsGravitationalFieldEventData;
  24535. /**
  24536. * Enables the gravitational field.
  24537. */
  24538. enable(): void;
  24539. /**
  24540. * Disables the gravitational field.
  24541. */
  24542. disable(): void;
  24543. /**
  24544. * Disposes the sphere.
  24545. * @param {bolean} force
  24546. */
  24547. dispose(force?: boolean): void;
  24548. private _tick();
  24549. }
  24550. /***** Updraft *****/
  24551. class PhysicsUpdraftEvent {
  24552. private _scene;
  24553. private _origin;
  24554. private _radius;
  24555. private _strength;
  24556. private _height;
  24557. private _updraftMode;
  24558. private _physicsEngine;
  24559. private _originTop;
  24560. private _originDirection;
  24561. private _tickCallback;
  24562. private _cylinder;
  24563. private _cylinderPosition;
  24564. private _dataFetched;
  24565. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24566. /**
  24567. * Returns the data related to the updraft event (cylinder).
  24568. * @returns {PhysicsUpdraftEventData}
  24569. */
  24570. getData(): PhysicsUpdraftEventData;
  24571. /**
  24572. * Enables the updraft.
  24573. */
  24574. enable(): void;
  24575. /**
  24576. * Disables the cortex.
  24577. */
  24578. disable(): void;
  24579. /**
  24580. * Disposes the sphere.
  24581. * @param {bolean} force
  24582. */
  24583. dispose(force?: boolean): void;
  24584. private getImpostorForceAndContactPoint(impostor);
  24585. private _tick();
  24586. /*** Helpers ***/
  24587. private _prepareCylinder();
  24588. private _intersectsWithCylinder(impostor);
  24589. }
  24590. /***** Vortex *****/
  24591. class PhysicsVortexEvent {
  24592. private _scene;
  24593. private _origin;
  24594. private _radius;
  24595. private _strength;
  24596. private _height;
  24597. private _physicsEngine;
  24598. private _originTop;
  24599. private _centripetalForceThreshold;
  24600. private _updraftMultiplier;
  24601. private _tickCallback;
  24602. private _cylinder;
  24603. private _cylinderPosition;
  24604. private _dataFetched;
  24605. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24606. /**
  24607. * Returns the data related to the vortex event (cylinder).
  24608. * @returns {PhysicsVortexEventData}
  24609. */
  24610. getData(): PhysicsVortexEventData;
  24611. /**
  24612. * Enables the vortex.
  24613. */
  24614. enable(): void;
  24615. /**
  24616. * Disables the cortex.
  24617. */
  24618. disable(): void;
  24619. /**
  24620. * Disposes the sphere.
  24621. * @param {bolean} force
  24622. */
  24623. dispose(force?: boolean): void;
  24624. private getImpostorForceAndContactPoint(impostor);
  24625. private _tick();
  24626. /*** Helpers ***/
  24627. private _prepareCylinder();
  24628. private _intersectsWithCylinder(impostor);
  24629. }
  24630. /***** Enums *****/
  24631. /**
  24632. * The strenght of the force in correspondence to the distance of the affected object
  24633. */
  24634. enum PhysicsRadialImpulseFalloff {
  24635. /** Defines that impulse is constant in strength across it's whole radius */
  24636. Constant = 0,
  24637. /** DEfines that impulse gets weaker if it's further from the origin */
  24638. Linear = 1,
  24639. }
  24640. /**
  24641. * The strenght of the force in correspondence to the distance of the affected object
  24642. */
  24643. enum PhysicsUpdraftMode {
  24644. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24645. Center = 0,
  24646. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24647. Perpendicular = 1,
  24648. }
  24649. /***** Data interfaces *****/
  24650. interface PhysicsForceAndContactPoint {
  24651. force: Vector3;
  24652. contactPoint: Vector3;
  24653. }
  24654. interface PhysicsRadialExplosionEventData {
  24655. sphere: Mesh;
  24656. rays: Array<Ray>;
  24657. }
  24658. interface PhysicsGravitationalFieldEventData {
  24659. sphere: Mesh;
  24660. }
  24661. interface PhysicsUpdraftEventData {
  24662. cylinder: Mesh;
  24663. }
  24664. interface PhysicsVortexEventData {
  24665. cylinder: Mesh;
  24666. }
  24667. }
  24668. declare module BABYLON {
  24669. interface PhysicsImpostorParameters {
  24670. mass: number;
  24671. friction?: number;
  24672. restitution?: number;
  24673. nativeOptions?: any;
  24674. ignoreParent?: boolean;
  24675. disableBidirectionalTransformation?: boolean;
  24676. }
  24677. interface IPhysicsEnabledObject {
  24678. position: Vector3;
  24679. rotationQuaternion: Nullable<Quaternion>;
  24680. scaling: Vector3;
  24681. rotation?: Vector3;
  24682. parent?: any;
  24683. getBoundingInfo(): BoundingInfo;
  24684. computeWorldMatrix(force: boolean): Matrix;
  24685. getWorldMatrix?(): Matrix;
  24686. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24687. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24688. getIndices?(): Nullable<IndicesArray>;
  24689. getScene?(): Scene;
  24690. getAbsolutePosition(): Vector3;
  24691. getAbsolutePivotPoint(): Vector3;
  24692. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24693. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24694. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24695. getClassName(): string;
  24696. }
  24697. class PhysicsImpostor {
  24698. object: IPhysicsEnabledObject;
  24699. type: number;
  24700. private _options;
  24701. private _scene;
  24702. static DEFAULT_OBJECT_SIZE: Vector3;
  24703. static IDENTITY_QUATERNION: Quaternion;
  24704. private _physicsEngine;
  24705. private _physicsBody;
  24706. private _bodyUpdateRequired;
  24707. private _onBeforePhysicsStepCallbacks;
  24708. private _onAfterPhysicsStepCallbacks;
  24709. private _onPhysicsCollideCallbacks;
  24710. private _deltaPosition;
  24711. private _deltaRotation;
  24712. private _deltaRotationConjugated;
  24713. private _parent;
  24714. private _isDisposed;
  24715. private static _tmpVecs;
  24716. private static _tmpQuat;
  24717. readonly isDisposed: boolean;
  24718. mass: number;
  24719. friction: number;
  24720. restitution: number;
  24721. uniqueId: number;
  24722. private _joints;
  24723. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24724. /**
  24725. * This function will completly initialize this impostor.
  24726. * It will create a new body - but only if this mesh has no parent.
  24727. * If it has, this impostor will not be used other than to define the impostor
  24728. * of the child mesh.
  24729. */
  24730. private _getPhysicsParent();
  24731. /**
  24732. * Should a new body be generated.
  24733. */
  24734. isBodyInitRequired(): boolean;
  24735. setScalingUpdated(updated: boolean): void;
  24736. /**
  24737. * Force a regeneration of this or the parent's impostor's body.
  24738. * Use under cautious - This will remove all joints already implemented.
  24739. */
  24740. forceUpdate(): void;
  24741. /**
  24742. * Gets the body that holds this impostor. Either its own, or its parent.
  24743. */
  24744. /**
  24745. * Set the physics body. Used mainly by the physics engine/plugin
  24746. */
  24747. physicsBody: any;
  24748. parent: Nullable<PhysicsImpostor>;
  24749. resetUpdateFlags(): void;
  24750. getObjectExtendSize(): Vector3;
  24751. getObjectCenter(): Vector3;
  24752. /**
  24753. * Get a specific parametes from the options parameter.
  24754. */
  24755. getParam(paramName: string): any;
  24756. /**
  24757. * Sets a specific parameter in the options given to the physics plugin
  24758. */
  24759. setParam(paramName: string, value: number): void;
  24760. /**
  24761. * Specifically change the body's mass option. Won't recreate the physics body object
  24762. */
  24763. setMass(mass: number): void;
  24764. getLinearVelocity(): Nullable<Vector3>;
  24765. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24766. getAngularVelocity(): Nullable<Vector3>;
  24767. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24768. /**
  24769. * Execute a function with the physics plugin native code.
  24770. * Provide a function the will have two variables - the world object and the physics body object.
  24771. */
  24772. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24773. /**
  24774. * Register a function that will be executed before the physics world is stepping forward.
  24775. */
  24776. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24777. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24778. /**
  24779. * Register a function that will be executed after the physics step
  24780. */
  24781. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24782. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24783. /**
  24784. * register a function that will be executed when this impostor collides against a different body.
  24785. */
  24786. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24787. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24788. private _tmpQuat;
  24789. private _tmpQuat2;
  24790. getParentsRotation(): Quaternion;
  24791. /**
  24792. * this function is executed by the physics engine.
  24793. */
  24794. beforeStep: () => void;
  24795. /**
  24796. * this function is executed by the physics engine.
  24797. */
  24798. afterStep: () => void;
  24799. /**
  24800. * Legacy collision detection event support
  24801. */
  24802. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24803. onCollide: (e: {
  24804. body: any;
  24805. }) => void;
  24806. /**
  24807. * Apply a force
  24808. */
  24809. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24810. /**
  24811. * Apply an impulse
  24812. */
  24813. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24814. /**
  24815. * A help function to create a joint.
  24816. */
  24817. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24818. /**
  24819. * Add a joint to this impostor with a different impostor.
  24820. */
  24821. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24822. /**
  24823. * Will keep this body still, in a sleep mode.
  24824. */
  24825. sleep(): PhysicsImpostor;
  24826. /**
  24827. * Wake the body up.
  24828. */
  24829. wakeUp(): PhysicsImpostor;
  24830. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24831. dispose(): void;
  24832. setDeltaPosition(position: Vector3): void;
  24833. setDeltaRotation(rotation: Quaternion): void;
  24834. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24835. getRadius(): number;
  24836. /**
  24837. * Sync a bone with this impostor
  24838. * @param bone The bone to sync to the impostor.
  24839. * @param boneMesh The mesh that the bone is influencing.
  24840. * @param jointPivot The pivot of the joint / bone in local space.
  24841. * @param distToJoint Optional distance from the impostor to the joint.
  24842. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24843. */
  24844. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24845. /**
  24846. * Sync impostor to a bone
  24847. * @param bone The bone that the impostor will be synced to.
  24848. * @param boneMesh The mesh that the bone is influencing.
  24849. * @param jointPivot The pivot of the joint / bone in local space.
  24850. * @param distToJoint Optional distance from the impostor to the joint.
  24851. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24852. * @param boneAxis Optional vector3 axis the bone is aligned with
  24853. */
  24854. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24855. static NoImpostor: number;
  24856. static SphereImpostor: number;
  24857. static BoxImpostor: number;
  24858. static PlaneImpostor: number;
  24859. static MeshImpostor: number;
  24860. static CylinderImpostor: number;
  24861. static ParticleImpostor: number;
  24862. static HeightmapImpostor: number;
  24863. }
  24864. }
  24865. declare module BABYLON {
  24866. interface PhysicsJointData {
  24867. mainPivot?: Vector3;
  24868. connectedPivot?: Vector3;
  24869. mainAxis?: Vector3;
  24870. connectedAxis?: Vector3;
  24871. collision?: boolean;
  24872. nativeParams?: any;
  24873. }
  24874. /**
  24875. * This is a holder class for the physics joint created by the physics plugin.
  24876. * It holds a set of functions to control the underlying joint.
  24877. */
  24878. class PhysicsJoint {
  24879. type: number;
  24880. jointData: PhysicsJointData;
  24881. private _physicsJoint;
  24882. protected _physicsPlugin: IPhysicsEnginePlugin;
  24883. constructor(type: number, jointData: PhysicsJointData);
  24884. physicsJoint: any;
  24885. physicsPlugin: IPhysicsEnginePlugin;
  24886. /**
  24887. * Execute a function that is physics-plugin specific.
  24888. * @param {Function} func the function that will be executed.
  24889. * It accepts two parameters: the physics world and the physics joint.
  24890. */
  24891. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24892. static DistanceJoint: number;
  24893. static HingeJoint: number;
  24894. static BallAndSocketJoint: number;
  24895. static WheelJoint: number;
  24896. static SliderJoint: number;
  24897. static PrismaticJoint: number;
  24898. static UniversalJoint: number;
  24899. static Hinge2Joint: number;
  24900. static PointToPointJoint: number;
  24901. static SpringJoint: number;
  24902. static LockJoint: number;
  24903. }
  24904. /**
  24905. * A class representing a physics distance joint.
  24906. */
  24907. class DistanceJoint extends PhysicsJoint {
  24908. constructor(jointData: DistanceJointData);
  24909. /**
  24910. * Update the predefined distance.
  24911. */
  24912. updateDistance(maxDistance: number, minDistance?: number): void;
  24913. }
  24914. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24915. constructor(type: number, jointData: PhysicsJointData);
  24916. /**
  24917. * Set the motor values.
  24918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24919. * @param {number} force the force to apply
  24920. * @param {number} maxForce max force for this motor.
  24921. */
  24922. setMotor(force?: number, maxForce?: number): void;
  24923. /**
  24924. * Set the motor's limits.
  24925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24926. */
  24927. setLimit(upperLimit: number, lowerLimit?: number): void;
  24928. }
  24929. /**
  24930. * This class represents a single hinge physics joint
  24931. */
  24932. class HingeJoint extends MotorEnabledJoint {
  24933. constructor(jointData: PhysicsJointData);
  24934. /**
  24935. * Set the motor values.
  24936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24937. * @param {number} force the force to apply
  24938. * @param {number} maxForce max force for this motor.
  24939. */
  24940. setMotor(force?: number, maxForce?: number): void;
  24941. /**
  24942. * Set the motor's limits.
  24943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24944. */
  24945. setLimit(upperLimit: number, lowerLimit?: number): void;
  24946. }
  24947. /**
  24948. * This class represents a dual hinge physics joint (same as wheel joint)
  24949. */
  24950. class Hinge2Joint extends MotorEnabledJoint {
  24951. constructor(jointData: PhysicsJointData);
  24952. /**
  24953. * Set the motor values.
  24954. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24955. * @param {number} force the force to apply
  24956. * @param {number} maxForce max force for this motor.
  24957. * @param {motorIndex} the motor's index, 0 or 1.
  24958. */
  24959. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24960. /**
  24961. * Set the motor limits.
  24962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24963. * @param {number} upperLimit the upper limit
  24964. * @param {number} lowerLimit lower limit
  24965. * @param {motorIndex} the motor's index, 0 or 1.
  24966. */
  24967. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24968. }
  24969. interface IMotorEnabledJoint {
  24970. physicsJoint: any;
  24971. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24972. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24973. }
  24974. interface DistanceJointData extends PhysicsJointData {
  24975. maxDistance: number;
  24976. }
  24977. interface SpringJointData extends PhysicsJointData {
  24978. length: number;
  24979. stiffness: number;
  24980. damping: number;
  24981. }
  24982. }
  24983. declare module BABYLON {
  24984. class ReflectionProbe {
  24985. name: string;
  24986. private _scene;
  24987. private _renderTargetTexture;
  24988. private _projectionMatrix;
  24989. private _viewMatrix;
  24990. private _target;
  24991. private _add;
  24992. private _attachedMesh;
  24993. private _invertYAxis;
  24994. position: Vector3;
  24995. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24996. samples: number;
  24997. refreshRate: number;
  24998. getScene(): Scene;
  24999. readonly cubeTexture: RenderTargetTexture;
  25000. readonly renderList: Nullable<AbstractMesh[]>;
  25001. attachToMesh(mesh: AbstractMesh): void;
  25002. /**
  25003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25004. *
  25005. * @param renderingGroupId The rendering group id corresponding to its index
  25006. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25007. */
  25008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25009. dispose(): void;
  25010. }
  25011. }
  25012. declare module BABYLON {
  25013. class BoundingBoxRenderer {
  25014. frontColor: Color3;
  25015. backColor: Color3;
  25016. showBackLines: boolean;
  25017. renderList: SmartArray<BoundingBox>;
  25018. private _scene;
  25019. private _colorShader;
  25020. private _vertexBuffers;
  25021. private _indexBuffer;
  25022. constructor(scene: Scene);
  25023. private _prepareRessources();
  25024. private _createIndexBuffer();
  25025. reset(): void;
  25026. render(): void;
  25027. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25028. dispose(): void;
  25029. }
  25030. }
  25031. declare module BABYLON {
  25032. /**
  25033. * This represents a depth renderer in Babylon.
  25034. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25035. */
  25036. class DepthRenderer {
  25037. private _scene;
  25038. private _depthMap;
  25039. private _effect;
  25040. private _cachedDefines;
  25041. private _camera;
  25042. /**
  25043. * Instantiates a depth renderer
  25044. * @param scene The scene the renderer belongs to
  25045. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25046. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25047. */
  25048. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25049. /**
  25050. * Creates the depth rendering effect and checks if the effect is ready.
  25051. * @param subMesh The submesh to be used to render the depth map of
  25052. * @param useInstances If multiple world instances should be used
  25053. * @returns if the depth renderer is ready to render the depth map
  25054. */
  25055. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25056. /**
  25057. * Gets the texture which the depth map will be written to.
  25058. * @returns The depth map texture
  25059. */
  25060. getDepthMap(): RenderTargetTexture;
  25061. /**
  25062. * Disposes of the depth renderer.
  25063. */
  25064. dispose(): void;
  25065. }
  25066. }
  25067. declare module BABYLON {
  25068. class EdgesRenderer {
  25069. edgesWidthScalerForOrthographic: number;
  25070. edgesWidthScalerForPerspective: number;
  25071. private _source;
  25072. private _linesPositions;
  25073. private _linesNormals;
  25074. private _linesIndices;
  25075. private _epsilon;
  25076. private _indicesCount;
  25077. private _lineShader;
  25078. private _ib;
  25079. private _buffers;
  25080. private _checkVerticesInsteadOfIndices;
  25081. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25082. isEnabled: boolean;
  25083. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25084. private _prepareRessources();
  25085. dispose(): void;
  25086. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25087. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25088. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25089. render(): void;
  25090. }
  25091. }
  25092. declare module BABYLON {
  25093. /**
  25094. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25095. */
  25096. class GeometryBufferRenderer {
  25097. private _scene;
  25098. private _multiRenderTarget;
  25099. private _ratio;
  25100. private _enablePosition;
  25101. protected _effect: Effect;
  25102. protected _cachedDefines: string;
  25103. /**
  25104. * Set the render list (meshes to be rendered) used in the G buffer.
  25105. */
  25106. renderList: Mesh[];
  25107. /**
  25108. * Gets wether or not G buffer are supported by the running hardware.
  25109. * This requires draw buffer supports
  25110. */
  25111. readonly isSupported: boolean;
  25112. /**
  25113. * Gets wether or not position are enabled for the G buffer.
  25114. */
  25115. /**
  25116. * Sets wether or not position are enabled for the G buffer.
  25117. */
  25118. enablePosition: boolean;
  25119. /**
  25120. * Gets the scene associated with the buffer.
  25121. */
  25122. readonly scene: Scene;
  25123. /**
  25124. * Gets the ratio used by the buffer during its creation.
  25125. * How big is the buffer related to the main canvas.
  25126. */
  25127. readonly ratio: number;
  25128. /**
  25129. * Creates a new G Buffer for the scene
  25130. * @param scene The scene the buffer belongs to
  25131. * @param ratio How big is the buffer related to the main canvas.
  25132. */
  25133. constructor(scene: Scene, ratio?: number);
  25134. /**
  25135. * Checks wether everything is ready to render a submesh to the G buffer.
  25136. * @param subMesh the submesh to check readiness for
  25137. * @param useInstances is the mesh drawn using instance or not
  25138. * @returns true if ready otherwise false
  25139. */
  25140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25141. /**
  25142. * Gets the current underlying G Buffer.
  25143. * @returns the buffer
  25144. */
  25145. getGBuffer(): MultiRenderTarget;
  25146. /**
  25147. * Gets the number of samples used to render the buffer (anti aliasing).
  25148. */
  25149. /**
  25150. * Sets the number of samples used to render the buffer (anti aliasing).
  25151. */
  25152. samples: number;
  25153. /**
  25154. * Disposes the renderer and frees up associated resources.
  25155. */
  25156. dispose(): void;
  25157. protected _createRenderTargets(): void;
  25158. }
  25159. }
  25160. declare module BABYLON {
  25161. class OutlineRenderer {
  25162. private _scene;
  25163. private _effect;
  25164. private _cachedDefines;
  25165. zOffset: number;
  25166. constructor(scene: Scene);
  25167. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25169. }
  25170. }
  25171. declare module BABYLON {
  25172. class RenderingGroup {
  25173. index: number;
  25174. private _scene;
  25175. private _opaqueSubMeshes;
  25176. private _transparentSubMeshes;
  25177. private _alphaTestSubMeshes;
  25178. private _depthOnlySubMeshes;
  25179. private _particleSystems;
  25180. private _spriteManagers;
  25181. private _opaqueSortCompareFn;
  25182. private _alphaTestSortCompareFn;
  25183. private _transparentSortCompareFn;
  25184. private _renderOpaque;
  25185. private _renderAlphaTest;
  25186. private _renderTransparent;
  25187. private _edgesRenderers;
  25188. onBeforeTransparentRendering: () => void;
  25189. /**
  25190. * Set the opaque sort comparison function.
  25191. * If null the sub meshes will be render in the order they were created
  25192. */
  25193. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25194. /**
  25195. * Set the alpha test sort comparison function.
  25196. * If null the sub meshes will be render in the order they were created
  25197. */
  25198. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25199. /**
  25200. * Set the transparent sort comparison function.
  25201. * If null the sub meshes will be render in the order they were created
  25202. */
  25203. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25204. /**
  25205. * Creates a new rendering group.
  25206. * @param index The rendering group index
  25207. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25208. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25209. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25210. */
  25211. 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>);
  25212. /**
  25213. * Render all the sub meshes contained in the group.
  25214. * @param customRenderFunction Used to override the default render behaviour of the group.
  25215. * @returns true if rendered some submeshes.
  25216. */
  25217. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25218. /**
  25219. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25220. * @param subMeshes The submeshes to render
  25221. */
  25222. private renderOpaqueSorted(subMeshes);
  25223. /**
  25224. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25225. * @param subMeshes The submeshes to render
  25226. */
  25227. private renderAlphaTestSorted(subMeshes);
  25228. /**
  25229. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25230. * @param subMeshes The submeshes to render
  25231. */
  25232. private renderTransparentSorted(subMeshes);
  25233. /**
  25234. * Renders the submeshes in a specified order.
  25235. * @param subMeshes The submeshes to sort before render
  25236. * @param sortCompareFn The comparison function use to sort
  25237. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25238. * @param transparent Specifies to activate blending if true
  25239. */
  25240. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25241. /**
  25242. * Renders the submeshes in the order they were dispatched (no sort applied).
  25243. * @param subMeshes The submeshes to render
  25244. */
  25245. private static renderUnsorted(subMeshes);
  25246. /**
  25247. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25248. * are rendered back to front if in the same alpha index.
  25249. *
  25250. * @param a The first submesh
  25251. * @param b The second submesh
  25252. * @returns The result of the comparison
  25253. */
  25254. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25255. /**
  25256. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25257. * are rendered back to front.
  25258. *
  25259. * @param a The first submesh
  25260. * @param b The second submesh
  25261. * @returns The result of the comparison
  25262. */
  25263. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25264. /**
  25265. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25266. * are rendered front to back (prevent overdraw).
  25267. *
  25268. * @param a The first submesh
  25269. * @param b The second submesh
  25270. * @returns The result of the comparison
  25271. */
  25272. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25273. /**
  25274. * Resets the different lists of submeshes to prepare a new frame.
  25275. */
  25276. prepare(): void;
  25277. dispose(): void;
  25278. /**
  25279. * Inserts the submesh in its correct queue depending on its material.
  25280. * @param subMesh The submesh to dispatch
  25281. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25282. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25283. */
  25284. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25285. dispatchSprites(spriteManager: SpriteManager): void;
  25286. dispatchParticles(particleSystem: IParticleSystem): void;
  25287. private _renderParticles(activeMeshes);
  25288. private _renderSprites();
  25289. }
  25290. }
  25291. declare module BABYLON {
  25292. class RenderingManager {
  25293. /**
  25294. * The max id used for rendering groups (not included)
  25295. */
  25296. static MAX_RENDERINGGROUPS: number;
  25297. /**
  25298. * The min id used for rendering groups (included)
  25299. */
  25300. static MIN_RENDERINGGROUPS: number;
  25301. /**
  25302. * Used to globally prevent autoclearing scenes.
  25303. */
  25304. static AUTOCLEAR: boolean;
  25305. private _scene;
  25306. private _renderingGroups;
  25307. private _depthStencilBufferAlreadyCleaned;
  25308. private _autoClearDepthStencil;
  25309. private _customOpaqueSortCompareFn;
  25310. private _customAlphaTestSortCompareFn;
  25311. private _customTransparentSortCompareFn;
  25312. private _renderinGroupInfo;
  25313. constructor(scene: Scene);
  25314. private _clearDepthStencilBuffer(depth?, stencil?);
  25315. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25316. reset(): void;
  25317. dispose(): void;
  25318. /**
  25319. * Clear the info related to rendering groups preventing retention points during dispose.
  25320. */
  25321. freeRenderingGroups(): void;
  25322. private _prepareRenderingGroup(renderingGroupId);
  25323. dispatchSprites(spriteManager: SpriteManager): void;
  25324. dispatchParticles(particleSystem: IParticleSystem): void;
  25325. /**
  25326. * @param subMesh The submesh to dispatch
  25327. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25328. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25329. */
  25330. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25331. /**
  25332. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25333. * This allowed control for front to back rendering or reversly depending of the special needs.
  25334. *
  25335. * @param renderingGroupId The rendering group id corresponding to its index
  25336. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25337. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25338. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25339. */
  25340. 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;
  25341. /**
  25342. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25343. *
  25344. * @param renderingGroupId The rendering group id corresponding to its index
  25345. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25346. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25347. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25348. */
  25349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25350. }
  25351. }
  25352. declare module BABYLON {
  25353. /**
  25354. * Renders a layer on top of an existing scene
  25355. */
  25356. class UtilityLayerRenderer implements IDisposable {
  25357. /** the original scene that will be rendered on top of */ originalScene: Scene;
  25358. /**
  25359. * The scene that is rendered on top of the original scene
  25360. */
  25361. utilityLayerScene: Scene;
  25362. /**
  25363. * If the utility layer should automatically be rendered on top of existing scene
  25364. */
  25365. shouldRender: boolean;
  25366. private _afterRenderObserver;
  25367. private _sceneDisposeObserver;
  25368. /**
  25369. * Instantiates a UtilityLayerRenderer
  25370. * @param originalScene the original scene that will be rendered on top of
  25371. */
  25372. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  25373. /**
  25374. * Renders the utility layers scene on top of the original scene
  25375. */
  25376. render(): void;
  25377. /**
  25378. * Disposes of the renderer
  25379. */
  25380. dispose(): void;
  25381. private _updateCamera();
  25382. }
  25383. }
  25384. declare module BABYLON {
  25385. class Sprite {
  25386. name: string;
  25387. position: Vector3;
  25388. color: Color4;
  25389. width: number;
  25390. height: number;
  25391. angle: number;
  25392. cellIndex: number;
  25393. invertU: number;
  25394. invertV: number;
  25395. disposeWhenFinishedAnimating: boolean;
  25396. animations: Animation[];
  25397. isPickable: boolean;
  25398. actionManager: ActionManager;
  25399. private _animationStarted;
  25400. private _loopAnimation;
  25401. private _fromIndex;
  25402. private _toIndex;
  25403. private _delay;
  25404. private _direction;
  25405. private _manager;
  25406. private _time;
  25407. private _onAnimationEnd;
  25408. size: number;
  25409. constructor(name: string, manager: SpriteManager);
  25410. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  25411. stopAnimation(): void;
  25412. dispose(): void;
  25413. }
  25414. }
  25415. declare module BABYLON {
  25416. class SpriteManager {
  25417. name: string;
  25418. sprites: Sprite[];
  25419. renderingGroupId: number;
  25420. layerMask: number;
  25421. fogEnabled: boolean;
  25422. isPickable: boolean;
  25423. cellWidth: number;
  25424. cellHeight: number;
  25425. /**
  25426. * An event triggered when the manager is disposed.
  25427. */
  25428. onDisposeObservable: Observable<SpriteManager>;
  25429. private _onDisposeObserver;
  25430. onDispose: () => void;
  25431. private _capacity;
  25432. private _spriteTexture;
  25433. private _epsilon;
  25434. private _scene;
  25435. private _vertexData;
  25436. private _buffer;
  25437. private _vertexBuffers;
  25438. private _indexBuffer;
  25439. private _effectBase;
  25440. private _effectFog;
  25441. texture: Texture;
  25442. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  25443. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  25444. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25445. render(): void;
  25446. dispose(): void;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * Postprocess used to generate anaglyphic rendering
  25452. */
  25453. class AnaglyphPostProcess extends PostProcess {
  25454. private _passedProcess;
  25455. /**
  25456. * Creates a new AnaglyphPostProcess
  25457. * @param name defines postprocess name
  25458. * @param options defines creation options or target ratio scale
  25459. * @param rigCameras defines cameras using this postprocess
  25460. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25461. * @param engine defines hosting engine
  25462. * @param reusable defines if the postprocess will be reused multiple times per frame
  25463. */
  25464. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25465. }
  25466. }
  25467. declare module BABYLON {
  25468. class BlackAndWhitePostProcess extends PostProcess {
  25469. degree: number;
  25470. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25471. }
  25472. }
  25473. declare module BABYLON {
  25474. /**
  25475. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25476. */
  25477. class BloomEffect extends PostProcessRenderEffect {
  25478. private bloomScale;
  25479. /**
  25480. * Internal
  25481. */
  25482. /**
  25483. * Internal
  25484. */
  25485. private _blurX;
  25486. private _blurY;
  25487. private _merge;
  25488. /**
  25489. * The luminance threshold to find bright areas of the image to bloom.
  25490. */
  25491. threshold: number;
  25492. /**
  25493. * The strength of the bloom.
  25494. */
  25495. weight: number;
  25496. /**
  25497. * Specifies the size of the bloom blur kernel, relative to the final output size
  25498. */
  25499. kernel: number;
  25500. /**
  25501. * Creates a new instance of @see BloomEffect
  25502. * @param scene The scene the effect belongs to.
  25503. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25504. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25505. * @param bloomWeight The the strength of bloom.
  25506. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25507. * @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)
  25508. */
  25509. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25510. /**
  25511. * Disposes each of the internal effects for a given camera.
  25512. * @param camera The camera to dispose the effect on.
  25513. */
  25514. disposeEffects(camera: Camera): void;
  25515. /**
  25516. * Internal
  25517. */
  25518. /**
  25519. * Internal
  25520. * @returns if all the contained post processes are ready.
  25521. */
  25522. }
  25523. }
  25524. declare module BABYLON {
  25525. /**
  25526. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25527. */
  25528. class BloomMergePostProcess extends PostProcess {
  25529. /** Weight of the bloom to be added to the original input. */ weight: number;
  25530. /**
  25531. * Creates a new instance of @see BloomMergePostProcess
  25532. * @param name The name of the effect.
  25533. * @param originalFromInput Post process which's input will be used for the merge.
  25534. * @param blurred Blurred highlights post process which's output will be used.
  25535. * @param weight Weight of the bloom to be added to the original input.
  25536. * @param options The required width/height ratio to downsize to before computing the render pass.
  25537. * @param camera The camera to apply the render pass to.
  25538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25539. * @param engine The engine which the post process will be applied. (default: current engine)
  25540. * @param reusable If the post process can be reused on the same frame. (default: false)
  25541. * @param textureType Type of textures used when performing the post process. (default: 0)
  25542. * @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)
  25543. */
  25544. 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);
  25545. }
  25546. }
  25547. declare module BABYLON {
  25548. /**
  25549. * The Blur Post Process which blurs an image based on a kernel and direction.
  25550. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25551. */
  25552. class BlurPostProcess extends PostProcess {
  25553. /** The direction in which to blur the image. */ direction: Vector2;
  25554. private blockCompilation;
  25555. protected _kernel: number;
  25556. protected _idealKernel: number;
  25557. protected _packedFloat: boolean;
  25558. private _staticDefines;
  25559. /**
  25560. * Gets the length in pixels of the blur sample region
  25561. */
  25562. /**
  25563. * Sets the length in pixels of the blur sample region
  25564. */
  25565. kernel: number;
  25566. /**
  25567. * Gets wether or not the blur is unpacking/repacking floats
  25568. */
  25569. /**
  25570. * Sets wether or not the blur needs to unpack/repack floats
  25571. */
  25572. packedFloat: boolean;
  25573. /**
  25574. * Creates a new instance BlurPostProcess
  25575. * @param name The name of the effect.
  25576. * @param direction The direction in which to blur the image.
  25577. * @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.
  25578. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25579. * @param camera The camera to apply the render pass to.
  25580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25581. * @param engine The engine which the post process will be applied. (default: current engine)
  25582. * @param reusable If the post process can be reused on the same frame. (default: false)
  25583. * @param textureType Type of textures used when performing the post process. (default: 0)
  25584. * @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)
  25585. */
  25586. 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);
  25587. /**
  25588. * Updates the effect with the current post process compile time values and recompiles the shader.
  25589. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25590. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25591. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25592. * @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
  25593. * @param onCompiled Called when the shader has been compiled.
  25594. * @param onError Called if there is an error when compiling a shader.
  25595. */
  25596. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25597. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25598. /**
  25599. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25600. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25601. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25602. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25603. * The gaps between physical kernels are compensated for in the weighting of the samples
  25604. * @param idealKernel Ideal blur kernel.
  25605. * @return Nearest best kernel.
  25606. */
  25607. protected _nearestBestKernel(idealKernel: number): number;
  25608. /**
  25609. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25610. * @param x The point on the Gaussian distribution to sample.
  25611. * @return the value of the Gaussian function at x.
  25612. */
  25613. protected _gaussianWeight(x: number): number;
  25614. /**
  25615. * Generates a string that can be used as a floating point number in GLSL.
  25616. * @param x Value to print.
  25617. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25618. * @return GLSL float string.
  25619. */
  25620. protected _glslFloat(x: number, decimalFigures?: number): string;
  25621. }
  25622. }
  25623. declare module BABYLON {
  25624. /**
  25625. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25626. */
  25627. class ChromaticAberrationPostProcess extends PostProcess {
  25628. /**
  25629. * The amount of seperation of rgb channels (default: 30)
  25630. */
  25631. aberrationAmount: number;
  25632. /**
  25633. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25634. */
  25635. radialIntensity: number;
  25636. /**
  25637. * 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))
  25638. */
  25639. direction: Vector2;
  25640. /**
  25641. * 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))
  25642. */
  25643. centerPosition: Vector2;
  25644. /**
  25645. * Creates a new instance ChromaticAberrationPostProcess
  25646. * @param name The name of the effect.
  25647. * @param screenWidth The width of the screen to apply the effect on.
  25648. * @param screenHeight The height of the screen to apply the effect on.
  25649. * @param options The required width/height ratio to downsize to before computing the render pass.
  25650. * @param camera The camera to apply the render pass to.
  25651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25652. * @param engine The engine which the post process will be applied. (default: current engine)
  25653. * @param reusable If the post process can be reused on the same frame. (default: false)
  25654. * @param textureType Type of textures used when performing the post process. (default: 0)
  25655. * @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)
  25656. */
  25657. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25658. }
  25659. }
  25660. declare module BABYLON {
  25661. /**
  25662. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25663. */
  25664. class CircleOfConfusionPostProcess extends PostProcess {
  25665. /**
  25666. * 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.
  25667. */
  25668. lensSize: number;
  25669. /**
  25670. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25671. */
  25672. fStop: number;
  25673. /**
  25674. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25675. */
  25676. focusDistance: number;
  25677. /**
  25678. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25679. */
  25680. focalLength: number;
  25681. private _depthTexture;
  25682. /**
  25683. * Creates a new instance CircleOfConfusionPostProcess
  25684. * @param name The name of the effect.
  25685. * @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.
  25686. * @param options The required width/height ratio to downsize to before computing the render pass.
  25687. * @param camera The camera to apply the render pass to.
  25688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25689. * @param engine The engine which the post process will be applied. (default: current engine)
  25690. * @param reusable If the post process can be reused on the same frame. (default: false)
  25691. * @param textureType Type of textures used when performing the post process. (default: 0)
  25692. * @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)
  25693. */
  25694. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25695. /**
  25696. * 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.
  25697. */
  25698. depthTexture: RenderTargetTexture;
  25699. }
  25700. }
  25701. declare module BABYLON {
  25702. class ColorCorrectionPostProcess extends PostProcess {
  25703. private _colorTableTexture;
  25704. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25705. }
  25706. }
  25707. declare module BABYLON {
  25708. /**
  25709. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25710. * input texture to perform effects such as edge detection or sharpening
  25711. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25712. */
  25713. class ConvolutionPostProcess extends PostProcess {
  25714. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25715. /**
  25716. * Creates a new instance ConvolutionPostProcess
  25717. * @param name The name of the effect.
  25718. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25719. * @param options The required width/height ratio to downsize to before computing the render pass.
  25720. * @param camera The camera to apply the render pass to.
  25721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25722. * @param engine The engine which the post process will be applied. (default: current engine)
  25723. * @param reusable If the post process can be reused on the same frame. (default: false)
  25724. * @param textureType Type of textures used when performing the post process. (default: 0)
  25725. */
  25726. 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);
  25727. /**
  25728. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25729. */
  25730. static EdgeDetect0Kernel: number[];
  25731. /**
  25732. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25733. */
  25734. static EdgeDetect1Kernel: number[];
  25735. /**
  25736. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25737. */
  25738. static EdgeDetect2Kernel: number[];
  25739. /**
  25740. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25741. */
  25742. static SharpenKernel: number[];
  25743. /**
  25744. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25745. */
  25746. static EmbossKernel: number[];
  25747. /**
  25748. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25749. */
  25750. static GaussianKernel: number[];
  25751. }
  25752. }
  25753. declare module BABYLON {
  25754. /**
  25755. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25756. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25757. * based on samples that have a large difference in distance than the center pixel.
  25758. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25759. */
  25760. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25761. direction: Vector2;
  25762. /**
  25763. * Creates a new instance CircleOfConfusionPostProcess
  25764. * @param name The name of the effect.
  25765. * @param scene The scene the effect belongs to.
  25766. * @param direction The direction the blur should be applied.
  25767. * @param kernel The size of the kernel used to blur.
  25768. * @param options The required width/height ratio to downsize to before computing the render pass.
  25769. * @param camera The camera to apply the render pass to.
  25770. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25771. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25773. * @param engine The engine which the post process will be applied. (default: current engine)
  25774. * @param reusable If the post process can be reused on the same frame. (default: false)
  25775. * @param textureType Type of textures used when performing the post process. (default: 0)
  25776. * @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)
  25777. */
  25778. 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);
  25779. }
  25780. }
  25781. declare module BABYLON {
  25782. /**
  25783. * Specifies the level of max blur that should be applied when using the depth of field effect
  25784. */
  25785. enum DepthOfFieldEffectBlurLevel {
  25786. /**
  25787. * Subtle blur
  25788. */
  25789. Low = 0,
  25790. /**
  25791. * Medium blur
  25792. */
  25793. Medium = 1,
  25794. /**
  25795. * Large blur
  25796. */
  25797. High = 2,
  25798. }
  25799. /**
  25800. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25801. */
  25802. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25803. private _circleOfConfusion;
  25804. /**
  25805. * Internal, blurs from high to low
  25806. */
  25807. private _depthOfFieldBlurY;
  25808. private _dofMerge;
  25809. /**
  25810. * Internal post processes in depth of field effect
  25811. */
  25812. /**
  25813. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25814. */
  25815. focalLength: number;
  25816. /**
  25817. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25818. */
  25819. fStop: number;
  25820. /**
  25821. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25822. */
  25823. focusDistance: number;
  25824. /**
  25825. * 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.
  25826. */
  25827. lensSize: number;
  25828. /**
  25829. * Creates a new instance DepthOfFieldEffect
  25830. * @param scene The scene the effect belongs to.
  25831. * @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.
  25832. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25833. * @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)
  25834. */
  25835. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25836. /**
  25837. * 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.
  25838. */
  25839. depthTexture: RenderTargetTexture;
  25840. /**
  25841. * Disposes each of the internal effects for a given camera.
  25842. * @param camera The camera to dispose the effect on.
  25843. */
  25844. disposeEffects(camera: Camera): void;
  25845. /**
  25846. * Internal
  25847. */
  25848. /**
  25849. * Internal
  25850. * @returns if all the contained post processes are ready.
  25851. */
  25852. }
  25853. }
  25854. declare module BABYLON {
  25855. /**
  25856. * Options to be set when merging outputs from the default pipeline.
  25857. */
  25858. class DepthOfFieldMergePostProcessOptions {
  25859. /**
  25860. * The original image to merge on top of
  25861. */
  25862. originalFromInput: PostProcess;
  25863. /**
  25864. * Parameters to perform the merge of the depth of field effect
  25865. */
  25866. depthOfField?: {
  25867. circleOfConfusion: PostProcess;
  25868. blurSteps: Array<PostProcess>;
  25869. };
  25870. /**
  25871. * Parameters to perform the merge of bloom effect
  25872. */
  25873. bloom?: {
  25874. blurred: PostProcess;
  25875. weight: number;
  25876. };
  25877. }
  25878. /**
  25879. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25880. */
  25881. class DepthOfFieldMergePostProcess extends PostProcess {
  25882. private blurSteps;
  25883. /**
  25884. * Creates a new instance of DepthOfFieldMergePostProcess
  25885. * @param name The name of the effect.
  25886. * @param originalFromInput Post process which's input will be used for the merge.
  25887. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25888. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25889. * @param options The required width/height ratio to downsize to before computing the render pass.
  25890. * @param camera The camera to apply the render pass to.
  25891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25892. * @param engine The engine which the post process will be applied. (default: current engine)
  25893. * @param reusable If the post process can be reused on the same frame. (default: false)
  25894. * @param textureType Type of textures used when performing the post process. (default: 0)
  25895. * @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)
  25896. */
  25897. 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);
  25898. /**
  25899. * Updates the effect with the current post process compile time values and recompiles the shader.
  25900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25903. * @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
  25904. * @param onCompiled Called when the shader has been compiled.
  25905. * @param onError Called if there is an error when compiling a shader.
  25906. */
  25907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25908. }
  25909. }
  25910. declare module BABYLON {
  25911. class DisplayPassPostProcess extends PostProcess {
  25912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25913. }
  25914. }
  25915. declare module BABYLON {
  25916. /**
  25917. * 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.
  25918. */
  25919. class ExtractHighlightsPostProcess extends PostProcess {
  25920. /**
  25921. * The luminance threshold, pixels below this value will be set to black.
  25922. */
  25923. threshold: number;
  25924. /**
  25925. * Internal
  25926. */
  25927. /**
  25928. * Post process which has the input texture to be used when performing highlight extraction
  25929. */
  25930. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. class FilterPostProcess extends PostProcess {
  25935. kernelMatrix: Matrix;
  25936. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25937. }
  25938. }
  25939. declare module BABYLON {
  25940. class FxaaPostProcess extends PostProcess {
  25941. texelWidth: number;
  25942. texelHeight: number;
  25943. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25944. private _getDefines();
  25945. }
  25946. }
  25947. declare module BABYLON {
  25948. /**
  25949. * The GrainPostProcess adds noise to the image at mid luminance levels
  25950. */
  25951. class GrainPostProcess extends PostProcess {
  25952. /**
  25953. * The intensity of the grain added (default: 30)
  25954. */
  25955. intensity: number;
  25956. /**
  25957. * If the grain should be randomized on every frame
  25958. */
  25959. animated: boolean;
  25960. /**
  25961. * Creates a new instance of @see GrainPostProcess
  25962. * @param name The name of the effect.
  25963. * @param options The required width/height ratio to downsize to before computing the render pass.
  25964. * @param camera The camera to apply the render pass to.
  25965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25966. * @param engine The engine which the post process will be applied. (default: current engine)
  25967. * @param reusable If the post process can be reused on the same frame. (default: false)
  25968. * @param textureType Type of textures used when performing the post process. (default: 0)
  25969. * @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)
  25970. */
  25971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25972. }
  25973. }
  25974. declare module BABYLON {
  25975. class HighlightsPostProcess extends PostProcess {
  25976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25977. }
  25978. }
  25979. declare module BABYLON {
  25980. class ImageProcessingPostProcess extends PostProcess {
  25981. /**
  25982. * Default configuration related to image processing available in the PBR Material.
  25983. */
  25984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25985. /**
  25986. * Gets the image processing configuration used either in this material.
  25987. */
  25988. /**
  25989. * Sets the Default image processing configuration used either in the this material.
  25990. *
  25991. * If sets to null, the scene one is in use.
  25992. */
  25993. imageProcessingConfiguration: ImageProcessingConfiguration;
  25994. /**
  25995. * Keep track of the image processing observer to allow dispose and replace.
  25996. */
  25997. private _imageProcessingObserver;
  25998. /**
  25999. * Attaches a new image processing configuration to the PBR Material.
  26000. * @param configuration
  26001. */
  26002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26003. /**
  26004. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26005. */
  26006. /**
  26007. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26008. */
  26009. colorCurves: Nullable<ColorCurves>;
  26010. /**
  26011. * Gets wether the color curves effect is enabled.
  26012. */
  26013. /**
  26014. * Sets wether the color curves effect is enabled.
  26015. */
  26016. colorCurvesEnabled: boolean;
  26017. /**
  26018. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26019. */
  26020. /**
  26021. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26022. */
  26023. colorGradingTexture: Nullable<BaseTexture>;
  26024. /**
  26025. * Gets wether the color grading effect is enabled.
  26026. */
  26027. /**
  26028. * Gets wether the color grading effect is enabled.
  26029. */
  26030. colorGradingEnabled: boolean;
  26031. /**
  26032. * Gets exposure used in the effect.
  26033. */
  26034. /**
  26035. * Sets exposure used in the effect.
  26036. */
  26037. exposure: number;
  26038. /**
  26039. * Gets wether tonemapping is enabled or not.
  26040. */
  26041. /**
  26042. * Sets wether tonemapping is enabled or not
  26043. */
  26044. toneMappingEnabled: boolean;
  26045. /**
  26046. * Gets contrast used in the effect.
  26047. */
  26048. /**
  26049. * Sets contrast used in the effect.
  26050. */
  26051. contrast: number;
  26052. /**
  26053. * Gets Vignette stretch size.
  26054. */
  26055. /**
  26056. * Sets Vignette stretch size.
  26057. */
  26058. vignetteStretch: number;
  26059. /**
  26060. * Gets Vignette centre X Offset.
  26061. */
  26062. /**
  26063. * Sets Vignette centre X Offset.
  26064. */
  26065. vignetteCentreX: number;
  26066. /**
  26067. * Gets Vignette centre Y Offset.
  26068. */
  26069. /**
  26070. * Sets Vignette centre Y Offset.
  26071. */
  26072. vignetteCentreY: number;
  26073. /**
  26074. * Gets Vignette weight or intensity of the vignette effect.
  26075. */
  26076. /**
  26077. * Sets Vignette weight or intensity of the vignette effect.
  26078. */
  26079. vignetteWeight: number;
  26080. /**
  26081. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26082. * if vignetteEnabled is set to true.
  26083. */
  26084. /**
  26085. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26086. * if vignetteEnabled is set to true.
  26087. */
  26088. vignetteColor: Color4;
  26089. /**
  26090. * Gets Camera field of view used by the Vignette effect.
  26091. */
  26092. /**
  26093. * Sets Camera field of view used by the Vignette effect.
  26094. */
  26095. vignetteCameraFov: number;
  26096. /**
  26097. * Gets the vignette blend mode allowing different kind of effect.
  26098. */
  26099. /**
  26100. * Sets the vignette blend mode allowing different kind of effect.
  26101. */
  26102. vignetteBlendMode: number;
  26103. /**
  26104. * Gets wether the vignette effect is enabled.
  26105. */
  26106. /**
  26107. * Sets wether the vignette effect is enabled.
  26108. */
  26109. vignetteEnabled: boolean;
  26110. private _fromLinearSpace;
  26111. /**
  26112. * Gets wether the input of the processing is in Gamma or Linear Space.
  26113. */
  26114. /**
  26115. * Sets wether the input of the processing is in Gamma or Linear Space.
  26116. */
  26117. fromLinearSpace: boolean;
  26118. /**
  26119. * Defines cache preventing GC.
  26120. */
  26121. private _defines;
  26122. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26123. getClassName(): string;
  26124. protected _updateParameters(): void;
  26125. dispose(camera?: Camera): void;
  26126. }
  26127. }
  26128. declare module BABYLON {
  26129. class PassPostProcess extends PostProcess {
  26130. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26131. }
  26132. }
  26133. declare module BABYLON {
  26134. type PostProcessOptions = {
  26135. width: number;
  26136. height: number;
  26137. };
  26138. /**
  26139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26141. */
  26142. class PostProcess {
  26143. /** Name of the PostProcess. */ name: string;
  26144. /**
  26145. * Width of the texture to apply the post process on
  26146. */
  26147. width: number;
  26148. /**
  26149. * Height of the texture to apply the post process on
  26150. */
  26151. height: number;
  26152. /**
  26153. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26154. */
  26155. /**
  26156. * Sampling mode used by the shader
  26157. * See https://doc.babylonjs.com/classes/3.1/texture
  26158. */
  26159. renderTargetSamplingMode: number;
  26160. /**
  26161. * Clear color to use when screen clearing
  26162. */
  26163. clearColor: Color4;
  26164. /**
  26165. * If the buffer needs to be cleared before applying the post process. (default: true)
  26166. * Should be set to false if shader will overwrite all previous pixels.
  26167. */
  26168. autoClear: boolean;
  26169. /**
  26170. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26171. */
  26172. alphaMode: number;
  26173. /**
  26174. * Sets the setAlphaBlendConstants of the babylon engine
  26175. */
  26176. alphaConstants: Color4;
  26177. /**
  26178. * Animations to be used for the post processing
  26179. */
  26180. animations: Animation[];
  26181. /**
  26182. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26183. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26184. */
  26185. enablePixelPerfectMode: boolean;
  26186. /**
  26187. * Force the postprocess to be applied without taking in account viewport
  26188. */
  26189. forceFullscreenViewport: boolean;
  26190. /**
  26191. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26192. *
  26193. * | Value | Type | Description |
  26194. * | ----- | ----------------------------------- | ----------- |
  26195. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  26196. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  26197. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  26198. *
  26199. */
  26200. scaleMode: number;
  26201. /**
  26202. * Force textures to be a power of two (default: false)
  26203. */
  26204. alwaysForcePOT: boolean;
  26205. /**
  26206. * Number of sample textures (default: 1)
  26207. */
  26208. samples: number;
  26209. /**
  26210. * Modify the scale of the post process to be the same as the viewport (default: false)
  26211. */
  26212. adaptScaleToCurrentViewport: boolean;
  26213. private _camera;
  26214. private _scene;
  26215. private _engine;
  26216. private _options;
  26217. private _reusable;
  26218. private _textureType;
  26219. /**
  26220. * Smart array of input and output textures for the post process.
  26221. */
  26222. /**
  26223. * The index in _textures that corresponds to the output texture.
  26224. */
  26225. private _effect;
  26226. private _samplers;
  26227. private _fragmentUrl;
  26228. private _vertexUrl;
  26229. private _parameters;
  26230. private _scaleRatio;
  26231. protected _indexParameters: any;
  26232. private _shareOutputWithPostProcess;
  26233. private _texelSize;
  26234. private _forcedOutputTexture;
  26235. /**
  26236. * An event triggered when the postprocess is activated.
  26237. */
  26238. onActivateObservable: Observable<Camera>;
  26239. private _onActivateObserver;
  26240. /**
  26241. * A function that is added to the onActivateObservable
  26242. */
  26243. onActivate: Nullable<(camera: Camera) => void>;
  26244. /**
  26245. * An event triggered when the postprocess changes its size.
  26246. */
  26247. onSizeChangedObservable: Observable<PostProcess>;
  26248. private _onSizeChangedObserver;
  26249. /**
  26250. * A function that is added to the onSizeChangedObservable
  26251. */
  26252. onSizeChanged: (postProcess: PostProcess) => void;
  26253. /**
  26254. * An event triggered when the postprocess applies its effect.
  26255. */
  26256. onApplyObservable: Observable<Effect>;
  26257. private _onApplyObserver;
  26258. /**
  26259. * A function that is added to the onApplyObservable
  26260. */
  26261. onApply: (effect: Effect) => void;
  26262. /**
  26263. * An event triggered before rendering the postprocess
  26264. */
  26265. onBeforeRenderObservable: Observable<Effect>;
  26266. private _onBeforeRenderObserver;
  26267. /**
  26268. * A function that is added to the onBeforeRenderObservable
  26269. */
  26270. onBeforeRender: (effect: Effect) => void;
  26271. /**
  26272. * An event triggered after rendering the postprocess
  26273. */
  26274. onAfterRenderObservable: Observable<Effect>;
  26275. private _onAfterRenderObserver;
  26276. /**
  26277. * A function that is added to the onAfterRenderObservable
  26278. */
  26279. onAfterRender: (efect: Effect) => void;
  26280. /**
  26281. * 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
  26282. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26283. */
  26284. inputTexture: InternalTexture;
  26285. /**
  26286. * Gets the camera which post process is applied to.
  26287. * @returns The camera the post process is applied to.
  26288. */
  26289. getCamera(): Camera;
  26290. /**
  26291. * Gets the texel size of the postprocess.
  26292. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26293. */
  26294. readonly texelSize: Vector2;
  26295. /**
  26296. * Creates a new instance PostProcess
  26297. * @param name The name of the PostProcess.
  26298. * @param fragmentUrl The url of the fragment shader to be used.
  26299. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26300. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26301. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26302. * @param camera The camera to apply the render pass to.
  26303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26304. * @param engine The engine which the post process will be applied. (default: current engine)
  26305. * @param reusable If the post process can be reused on the same frame. (default: false)
  26306. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26307. * @param textureType Type of textures used when performing the post process. (default: 0)
  26308. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26309. * @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
  26310. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26311. */
  26312. 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);
  26313. /**
  26314. * Gets the engine which this post process belongs to.
  26315. * @returns The engine the post process was enabled with.
  26316. */
  26317. getEngine(): Engine;
  26318. /**
  26319. * The effect that is created when initializing the post process.
  26320. * @returns The created effect corrisponding the the postprocess.
  26321. */
  26322. getEffect(): Effect;
  26323. /**
  26324. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26325. * @param postProcess The post process to share the output with.
  26326. * @returns This post process.
  26327. */
  26328. shareOutputWith(postProcess: PostProcess): PostProcess;
  26329. /**
  26330. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26331. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26332. */
  26333. useOwnOutput(): void;
  26334. /**
  26335. * Updates the effect with the current post process compile time values and recompiles the shader.
  26336. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26337. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26338. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26339. * @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
  26340. * @param onCompiled Called when the shader has been compiled.
  26341. * @param onError Called if there is an error when compiling a shader.
  26342. */
  26343. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26344. /**
  26345. * The post process is reusable if it can be used multiple times within one frame.
  26346. * @returns If the post process is reusable
  26347. */
  26348. isReusable(): boolean;
  26349. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26350. markTextureDirty(): void;
  26351. /**
  26352. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26353. * 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.
  26354. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26355. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26356. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26357. * @returns The target texture that was bound to be written to.
  26358. */
  26359. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26360. /**
  26361. * If the post process is supported.
  26362. */
  26363. readonly isSupported: boolean;
  26364. /**
  26365. * The aspect ratio of the output texture.
  26366. */
  26367. readonly aspectRatio: number;
  26368. /**
  26369. * Get a value indicating if the post-process is ready to be used
  26370. * @returns true if the post-process is ready (shader is compiled)
  26371. */
  26372. isReady(): boolean;
  26373. /**
  26374. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26375. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26376. */
  26377. apply(): Nullable<Effect>;
  26378. private _disposeTextures();
  26379. /**
  26380. * Disposes the post process.
  26381. * @param camera The camera to dispose the post process on.
  26382. */
  26383. dispose(camera?: Camera): void;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. /**
  26388. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26389. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26390. */
  26391. class PostProcessManager {
  26392. private _scene;
  26393. private _indexBuffer;
  26394. private _vertexBuffers;
  26395. /**
  26396. * Creates a new instance PostProcess
  26397. * @param scene The scene that the post process is associated with.
  26398. */
  26399. constructor(scene: Scene);
  26400. private _prepareBuffers();
  26401. private _buildIndexBuffer();
  26402. /**
  26403. * Rebuilds the vertex buffers of the manager.
  26404. */
  26405. /**
  26406. * Prepares a frame to be run through a post process.
  26407. * @param sourceTexture The input texture to the post procesess. (default: null)
  26408. * @param postProcesses An array of post processes to be run. (default: null)
  26409. * @returns True if the post processes were able to be run.
  26410. */
  26411. /**
  26412. * Manually render a set of post processes to a texture.
  26413. * @param postProcesses An array of post processes to be run.
  26414. * @param targetTexture The target texture to render to.
  26415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26416. */
  26417. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26418. /**
  26419. * Finalize the result of the output of the postprocesses.
  26420. * @param doNotPresent If true the result will not be displayed to the screen.
  26421. * @param targetTexture The target texture to render to.
  26422. * @param faceIndex The index of the face to bind the target texture to.
  26423. * @param postProcesses The array of post processes to render.
  26424. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26425. */
  26426. /**
  26427. * Disposes of the post process manager.
  26428. */
  26429. dispose(): void;
  26430. }
  26431. }
  26432. declare module BABYLON {
  26433. class RefractionPostProcess extends PostProcess {
  26434. color: Color3;
  26435. depth: number;
  26436. colorLevel: number;
  26437. private _refTexture;
  26438. private _ownRefractionTexture;
  26439. /**
  26440. * Gets or sets the refraction texture
  26441. * Please note that you are responsible for disposing the texture if you set it manually
  26442. */
  26443. refractionTexture: Texture;
  26444. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26445. dispose(camera: Camera): void;
  26446. }
  26447. }
  26448. declare module BABYLON {
  26449. /**
  26450. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26451. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26452. */
  26453. class SharpenPostProcess extends PostProcess {
  26454. /**
  26455. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26456. */
  26457. colorAmount: number;
  26458. /**
  26459. * How much sharpness should be applied (default: 0.3)
  26460. */
  26461. edgeAmount: number;
  26462. /**
  26463. * Creates a new instance ConvolutionPostProcess
  26464. * @param name The name of the effect.
  26465. * @param options The required width/height ratio to downsize to before computing the render pass.
  26466. * @param camera The camera to apply the render pass to.
  26467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26468. * @param engine The engine which the post process will be applied. (default: current engine)
  26469. * @param reusable If the post process can be reused on the same frame. (default: false)
  26470. * @param textureType Type of textures used when performing the post process. (default: 0)
  26471. * @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)
  26472. */
  26473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26474. }
  26475. }
  26476. declare module BABYLON {
  26477. class StereoscopicInterlacePostProcess extends PostProcess {
  26478. private _stepSize;
  26479. private _passedProcess;
  26480. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26481. }
  26482. }
  26483. declare module BABYLON {
  26484. /** Defines operator used for tonemapping */
  26485. enum TonemappingOperator {
  26486. /** Hable */
  26487. Hable = 0,
  26488. /** Reinhard */
  26489. Reinhard = 1,
  26490. /** HejiDawson */
  26491. HejiDawson = 2,
  26492. /** Photographic */
  26493. Photographic = 3,
  26494. }
  26495. /**
  26496. * Defines a post process to apply tone mapping
  26497. */
  26498. class TonemapPostProcess extends PostProcess {
  26499. private _operator;
  26500. /** Defines the required exposure adjustement */
  26501. exposureAdjustment: number;
  26502. /**
  26503. * Creates a new TonemapPostProcess
  26504. * @param name defines the name of the postprocess
  26505. * @param _operator defines the operator to use
  26506. * @param exposureAdjustment defines the required exposure adjustement
  26507. * @param camera defines the camera to use (can be null)
  26508. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26509. * @param engine defines the hosting engine (can be ignore if camera is set)
  26510. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26511. */
  26512. constructor(name: string, _operator: TonemappingOperator,
  26513. /** Defines the required exposure adjustement */
  26514. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. class VolumetricLightScatteringPostProcess extends PostProcess {
  26519. private _volumetricLightScatteringPass;
  26520. private _volumetricLightScatteringRTT;
  26521. private _viewPort;
  26522. private _screenCoordinates;
  26523. private _cachedDefines;
  26524. /**
  26525. * If not undefined, the mesh position is computed from the attached node position
  26526. */
  26527. attachedNode: {
  26528. position: Vector3;
  26529. };
  26530. /**
  26531. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26532. */
  26533. customMeshPosition: Vector3;
  26534. /**
  26535. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26536. */
  26537. useCustomMeshPosition: boolean;
  26538. /**
  26539. * If the post-process should inverse the light scattering direction
  26540. */
  26541. invert: boolean;
  26542. /**
  26543. * The internal mesh used by the post-process
  26544. */
  26545. mesh: Mesh;
  26546. useDiffuseColor: boolean;
  26547. /**
  26548. * Array containing the excluded meshes not rendered in the internal pass
  26549. */
  26550. excludedMeshes: AbstractMesh[];
  26551. /**
  26552. * Controls the overall intensity of the post-process
  26553. */
  26554. exposure: number;
  26555. /**
  26556. * Dissipates each sample's contribution in range [0, 1]
  26557. */
  26558. decay: number;
  26559. /**
  26560. * Controls the overall intensity of each sample
  26561. */
  26562. weight: number;
  26563. /**
  26564. * Controls the density of each sample
  26565. */
  26566. density: number;
  26567. /**
  26568. * @constructor
  26569. * @param {string} name - The post-process name
  26570. * @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)
  26571. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26572. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26573. * @param {number} samples - The post-process quality, default 100
  26574. * @param {number} samplingMode - The post-process filtering mode
  26575. * @param {BABYLON.Engine} engine - The babylon engine
  26576. * @param {boolean} reusable - If the post-process is reusable
  26577. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26578. */
  26579. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26580. getClassName(): string;
  26581. private _isReady(subMesh, useInstances);
  26582. /**
  26583. * Sets the new light position for light scattering effect
  26584. * @param {BABYLON.Vector3} The new custom light position
  26585. */
  26586. setCustomMeshPosition(position: Vector3): void;
  26587. /**
  26588. * Returns the light position for light scattering effect
  26589. * @return {BABYLON.Vector3} The custom light position
  26590. */
  26591. getCustomMeshPosition(): Vector3;
  26592. /**
  26593. * Disposes the internal assets and detaches the post-process from the camera
  26594. */
  26595. dispose(camera: Camera): void;
  26596. /**
  26597. * Returns the render target texture used by the post-process
  26598. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26599. */
  26600. getPass(): RenderTargetTexture;
  26601. private _meshExcluded(mesh);
  26602. private _createPass(scene, ratio);
  26603. private _updateMeshScreenCoordinates(scene);
  26604. /**
  26605. * Creates a default mesh for the Volumeric Light Scattering post-process
  26606. * @param {string} The mesh name
  26607. * @param {BABYLON.Scene} The scene where to create the mesh
  26608. * @return {BABYLON.Mesh} the default mesh
  26609. */
  26610. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26611. }
  26612. }
  26613. declare module BABYLON {
  26614. class VRDistortionCorrectionPostProcess extends PostProcess {
  26615. private _isRightEye;
  26616. private _distortionFactors;
  26617. private _postProcessScaleFactor;
  26618. private _lensCenterOffset;
  26619. private _scaleIn;
  26620. private _scaleFactor;
  26621. private _lensCenter;
  26622. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26623. }
  26624. }
  26625. declare module BABYLON {
  26626. /**
  26627. * @hidden
  26628. **/
  26629. class _AlphaState {
  26630. private _isAlphaBlendDirty;
  26631. private _isBlendFunctionParametersDirty;
  26632. private _isBlendEquationParametersDirty;
  26633. private _isBlendConstantsDirty;
  26634. private _alphaBlend;
  26635. private _blendFunctionParameters;
  26636. private _blendEquationParameters;
  26637. private _blendConstants;
  26638. /**
  26639. * Initializes the state.
  26640. */
  26641. constructor();
  26642. readonly isDirty: boolean;
  26643. alphaBlend: boolean;
  26644. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26645. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26646. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26647. reset(): void;
  26648. apply(gl: WebGLRenderingContext): void;
  26649. }
  26650. }
  26651. declare module BABYLON {
  26652. /**
  26653. * @hidden
  26654. **/
  26655. class _DepthCullingState {
  26656. private _isDepthTestDirty;
  26657. private _isDepthMaskDirty;
  26658. private _isDepthFuncDirty;
  26659. private _isCullFaceDirty;
  26660. private _isCullDirty;
  26661. private _isZOffsetDirty;
  26662. private _isFrontFaceDirty;
  26663. private _depthTest;
  26664. private _depthMask;
  26665. private _depthFunc;
  26666. private _cull;
  26667. private _cullFace;
  26668. private _zOffset;
  26669. private _frontFace;
  26670. /**
  26671. * Initializes the state.
  26672. */
  26673. constructor();
  26674. readonly isDirty: boolean;
  26675. zOffset: number;
  26676. cullFace: Nullable<number>;
  26677. cull: Nullable<boolean>;
  26678. depthFunc: Nullable<number>;
  26679. depthMask: boolean;
  26680. depthTest: boolean;
  26681. frontFace: Nullable<number>;
  26682. reset(): void;
  26683. apply(gl: WebGLRenderingContext): void;
  26684. }
  26685. }
  26686. declare module BABYLON {
  26687. /**
  26688. * @hidden
  26689. **/
  26690. class _StencilState {
  26691. private _isStencilTestDirty;
  26692. private _isStencilMaskDirty;
  26693. private _isStencilFuncDirty;
  26694. private _isStencilOpDirty;
  26695. private _stencilTest;
  26696. private _stencilMask;
  26697. private _stencilFunc;
  26698. private _stencilFuncRef;
  26699. private _stencilFuncMask;
  26700. private _stencilOpStencilFail;
  26701. private _stencilOpDepthFail;
  26702. private _stencilOpStencilDepthPass;
  26703. readonly isDirty: boolean;
  26704. stencilFunc: number;
  26705. stencilFuncRef: number;
  26706. stencilFuncMask: number;
  26707. stencilOpStencilFail: number;
  26708. stencilOpDepthFail: number;
  26709. stencilOpStencilDepthPass: number;
  26710. stencilMask: number;
  26711. stencilTest: boolean;
  26712. constructor();
  26713. reset(): void;
  26714. apply(gl: WebGLRenderingContext): void;
  26715. }
  26716. }
  26717. declare module BABYLON {
  26718. /**
  26719. * Class used to evalaute queries containing `and` and `or` operators
  26720. */
  26721. class AndOrNotEvaluator {
  26722. /**
  26723. * Evaluate a query
  26724. * @param query defines the query to evaluate
  26725. * @param evaluateCallback defines the callback used to filter result
  26726. * @returns true if the query matches
  26727. */
  26728. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26729. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26730. private static _SimplifyNegation(booleanString);
  26731. }
  26732. }
  26733. declare module BABYLON {
  26734. /**
  26735. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26736. */
  26737. enum AssetTaskState {
  26738. /**
  26739. * Initialization
  26740. */
  26741. INIT = 0,
  26742. /**
  26743. * Running
  26744. */
  26745. RUNNING = 1,
  26746. /**
  26747. * Done
  26748. */
  26749. DONE = 2,
  26750. /**
  26751. * Error
  26752. */
  26753. ERROR = 3,
  26754. }
  26755. /**
  26756. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26757. */
  26758. abstract class AbstractAssetTask {
  26759. /**
  26760. * Task name
  26761. */ name: string;
  26762. /**
  26763. * Callback called when the task is successful
  26764. */
  26765. onSuccess: (task: any) => void;
  26766. /**
  26767. * Callback called when the task is not successful
  26768. */
  26769. onError: (task: any, message?: string, exception?: any) => void;
  26770. /**
  26771. * Creates a new {BABYLON.AssetsManager}
  26772. * @param name defines the name of the task
  26773. */
  26774. constructor(
  26775. /**
  26776. * Task name
  26777. */ name: string);
  26778. private _isCompleted;
  26779. private _taskState;
  26780. private _errorObject;
  26781. /**
  26782. * Get if the task is completed
  26783. */
  26784. readonly isCompleted: boolean;
  26785. /**
  26786. * Gets the current state of the task
  26787. */
  26788. readonly taskState: AssetTaskState;
  26789. /**
  26790. * Gets the current error object (if task is in error)
  26791. */
  26792. readonly errorObject: {
  26793. message?: string;
  26794. exception?: any;
  26795. };
  26796. /**
  26797. * Internal only
  26798. * @hidden
  26799. */
  26800. /**
  26801. * Execute the current task
  26802. * @param scene defines the scene where you want your assets to be loaded
  26803. * @param onSuccess is a callback called when the task is successfully executed
  26804. * @param onError is a callback called if an error occurs
  26805. */
  26806. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26807. /**
  26808. * Execute the current task
  26809. * @param scene defines the scene where you want your assets to be loaded
  26810. * @param onSuccess is a callback called when the task is successfully executed
  26811. * @param onError is a callback called if an error occurs
  26812. */
  26813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26814. private onErrorCallback(onError, message?, exception?);
  26815. private onDoneCallback(onSuccess, onError);
  26816. }
  26817. /**
  26818. * Define the interface used by progress events raised during assets loading
  26819. */
  26820. interface IAssetsProgressEvent {
  26821. /**
  26822. * Defines the number of remaining tasks to process
  26823. */
  26824. remainingCount: number;
  26825. /**
  26826. * Defines the total number of tasks
  26827. */
  26828. totalCount: number;
  26829. /**
  26830. * Defines the task that was just processed
  26831. */
  26832. task: AbstractAssetTask;
  26833. }
  26834. /**
  26835. * Class used to share progress information about assets loading
  26836. */
  26837. class AssetsProgressEvent implements IAssetsProgressEvent {
  26838. /**
  26839. * Defines the number of remaining tasks to process
  26840. */
  26841. remainingCount: number;
  26842. /**
  26843. * Defines the total number of tasks
  26844. */
  26845. totalCount: number;
  26846. /**
  26847. * Defines the task that was just processed
  26848. */
  26849. task: AbstractAssetTask;
  26850. /**
  26851. * Creates a {BABYLON.AssetsProgressEvent}
  26852. * @param remainingCount defines the number of remaining tasks to process
  26853. * @param totalCount defines the total number of tasks
  26854. * @param task defines the task that was just processed
  26855. */
  26856. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26857. }
  26858. /**
  26859. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26860. */
  26861. class MeshAssetTask extends AbstractAssetTask {
  26862. /**
  26863. * Defines the name of the task
  26864. */
  26865. name: string;
  26866. /**
  26867. * Defines the list of mesh's names you want to load
  26868. */
  26869. meshesNames: any;
  26870. /**
  26871. * Defines the root url to use as a base to load your meshes and associated resources
  26872. */
  26873. rootUrl: string;
  26874. /**
  26875. * Defines the filename of the scene to load from
  26876. */
  26877. sceneFilename: string;
  26878. /**
  26879. * Gets the list of loaded meshes
  26880. */
  26881. loadedMeshes: Array<AbstractMesh>;
  26882. /**
  26883. * Gets the list of loaded particle systems
  26884. */
  26885. loadedParticleSystems: Array<ParticleSystem>;
  26886. /**
  26887. * Gets the list of loaded skeletons
  26888. */
  26889. loadedSkeletons: Array<Skeleton>;
  26890. /**
  26891. * Callback called when the task is successful
  26892. */
  26893. onSuccess: (task: MeshAssetTask) => void;
  26894. /**
  26895. * Callback called when the task is successful
  26896. */
  26897. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26898. /**
  26899. * Creates a new {BABYLON.MeshAssetTask}
  26900. * @param name defines the name of the task
  26901. * @param meshesNames defines the list of mesh's names you want to load
  26902. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26903. * @param sceneFilename defines the filename of the scene to load from
  26904. */
  26905. constructor(
  26906. /**
  26907. * Defines the name of the task
  26908. */
  26909. name: string,
  26910. /**
  26911. * Defines the list of mesh's names you want to load
  26912. */
  26913. meshesNames: any,
  26914. /**
  26915. * Defines the root url to use as a base to load your meshes and associated resources
  26916. */
  26917. rootUrl: string,
  26918. /**
  26919. * Defines the filename of the scene to load from
  26920. */
  26921. sceneFilename: string);
  26922. /**
  26923. * Execute the current task
  26924. * @param scene defines the scene where you want your assets to be loaded
  26925. * @param onSuccess is a callback called when the task is successfully executed
  26926. * @param onError is a callback called if an error occurs
  26927. */
  26928. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26929. }
  26930. /**
  26931. * Define a task used by {BABYLON.AssetsManager} to load text content
  26932. */
  26933. class TextFileAssetTask extends AbstractAssetTask {
  26934. /**
  26935. * Defines the name of the task
  26936. */
  26937. name: string;
  26938. /**
  26939. * Defines the location of the file to load
  26940. */
  26941. url: string;
  26942. /**
  26943. * Gets the loaded text string
  26944. */
  26945. text: string;
  26946. /**
  26947. * Callback called when the task is successful
  26948. */
  26949. onSuccess: (task: TextFileAssetTask) => void;
  26950. /**
  26951. * Callback called when the task is successful
  26952. */
  26953. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26954. /**
  26955. * Creates a new TextFileAssetTask object
  26956. * @param name defines the name of the task
  26957. * @param url defines the location of the file to load
  26958. */
  26959. constructor(
  26960. /**
  26961. * Defines the name of the task
  26962. */
  26963. name: string,
  26964. /**
  26965. * Defines the location of the file to load
  26966. */
  26967. url: string);
  26968. /**
  26969. * Execute the current task
  26970. * @param scene defines the scene where you want your assets to be loaded
  26971. * @param onSuccess is a callback called when the task is successfully executed
  26972. * @param onError is a callback called if an error occurs
  26973. */
  26974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26975. }
  26976. /**
  26977. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26978. */
  26979. class BinaryFileAssetTask extends AbstractAssetTask {
  26980. /**
  26981. * Defines the name of the task
  26982. */
  26983. name: string;
  26984. /**
  26985. * Defines the location of the file to load
  26986. */
  26987. url: string;
  26988. /**
  26989. * Gets the lodaded data (as an array buffer)
  26990. */
  26991. data: ArrayBuffer;
  26992. /**
  26993. * Callback called when the task is successful
  26994. */
  26995. onSuccess: (task: BinaryFileAssetTask) => void;
  26996. /**
  26997. * Callback called when the task is successful
  26998. */
  26999. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27000. /**
  27001. * Creates a new BinaryFileAssetTask object
  27002. * @param name defines the name of the new task
  27003. * @param url defines the location of the file to load
  27004. */
  27005. constructor(
  27006. /**
  27007. * Defines the name of the task
  27008. */
  27009. name: string,
  27010. /**
  27011. * Defines the location of the file to load
  27012. */
  27013. url: string);
  27014. /**
  27015. * Execute the current task
  27016. * @param scene defines the scene where you want your assets to be loaded
  27017. * @param onSuccess is a callback called when the task is successfully executed
  27018. * @param onError is a callback called if an error occurs
  27019. */
  27020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27021. }
  27022. /**
  27023. * Define a task used by {BABYLON.AssetsManager} to load images
  27024. */
  27025. class ImageAssetTask extends AbstractAssetTask {
  27026. /**
  27027. * Defines the name of the task
  27028. */
  27029. name: string;
  27030. /**
  27031. * Defines the location of the image to load
  27032. */
  27033. url: string;
  27034. /**
  27035. * Gets the loaded images
  27036. */
  27037. image: HTMLImageElement;
  27038. /**
  27039. * Callback called when the task is successful
  27040. */
  27041. onSuccess: (task: ImageAssetTask) => void;
  27042. /**
  27043. * Callback called when the task is successful
  27044. */
  27045. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27046. /**
  27047. * Creates a new ImageAssetTask
  27048. * @param name defines the name of the task
  27049. * @param url defines the location of the image to load
  27050. */
  27051. constructor(
  27052. /**
  27053. * Defines the name of the task
  27054. */
  27055. name: string,
  27056. /**
  27057. * Defines the location of the image to load
  27058. */
  27059. url: string);
  27060. /**
  27061. * Execute the current task
  27062. * @param scene defines the scene where you want your assets to be loaded
  27063. * @param onSuccess is a callback called when the task is successfully executed
  27064. * @param onError is a callback called if an error occurs
  27065. */
  27066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27067. }
  27068. /**
  27069. * Defines the interface used by texture loading tasks
  27070. */
  27071. interface ITextureAssetTask<TEX extends BaseTexture> {
  27072. /**
  27073. * Gets the loaded texture
  27074. */
  27075. texture: TEX;
  27076. }
  27077. /**
  27078. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27079. */
  27080. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27081. /**
  27082. * Defines the name of the task
  27083. */
  27084. name: string;
  27085. /**
  27086. * Defines the location of the file to load
  27087. */
  27088. url: string;
  27089. /**
  27090. * Defines if mipmap should not be generated (default is false)
  27091. */
  27092. noMipmap: boolean | undefined;
  27093. /**
  27094. * Defines if texture must be inverted on Y axis (default is false)
  27095. */
  27096. invertY: boolean | undefined;
  27097. /**
  27098. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27099. */
  27100. samplingMode: number;
  27101. /**
  27102. * Gets the loaded texture
  27103. */
  27104. texture: Texture;
  27105. /**
  27106. * Callback called when the task is successful
  27107. */
  27108. onSuccess: (task: TextureAssetTask) => void;
  27109. /**
  27110. * Callback called when the task is successful
  27111. */
  27112. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27113. /**
  27114. * Creates a new TextureAssetTask object
  27115. * @param name defines the name of the task
  27116. * @param url defines the location of the file to load
  27117. * @param noMipmap defines if mipmap should not be generated (default is false)
  27118. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27119. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27120. */
  27121. constructor(
  27122. /**
  27123. * Defines the name of the task
  27124. */
  27125. name: string,
  27126. /**
  27127. * Defines the location of the file to load
  27128. */
  27129. url: string,
  27130. /**
  27131. * Defines if mipmap should not be generated (default is false)
  27132. */
  27133. noMipmap?: boolean | undefined,
  27134. /**
  27135. * Defines if texture must be inverted on Y axis (default is false)
  27136. */
  27137. invertY?: boolean | undefined,
  27138. /**
  27139. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27140. */
  27141. samplingMode?: number);
  27142. /**
  27143. * Execute the current task
  27144. * @param scene defines the scene where you want your assets to be loaded
  27145. * @param onSuccess is a callback called when the task is successfully executed
  27146. * @param onError is a callback called if an error occurs
  27147. */
  27148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27149. }
  27150. /**
  27151. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27152. */
  27153. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27154. /**
  27155. * Defines the name of the task
  27156. */
  27157. name: string;
  27158. /**
  27159. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27160. */
  27161. url: string;
  27162. /**
  27163. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27164. */
  27165. extensions: string[] | undefined;
  27166. /**
  27167. * Defines if mipmaps should not be generated (default is false)
  27168. */
  27169. noMipmap: boolean | undefined;
  27170. /**
  27171. * Defines the explicit list of files (undefined by default)
  27172. */
  27173. files: string[] | undefined;
  27174. /**
  27175. * Gets the loaded texture
  27176. */
  27177. texture: CubeTexture;
  27178. /**
  27179. * Callback called when the task is successful
  27180. */
  27181. onSuccess: (task: CubeTextureAssetTask) => void;
  27182. /**
  27183. * Callback called when the task is successful
  27184. */
  27185. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27186. /**
  27187. * Creates a new CubeTextureAssetTask
  27188. * @param name defines the name of the task
  27189. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27190. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27191. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27192. * @param files defines the explicit list of files (undefined by default)
  27193. */
  27194. constructor(
  27195. /**
  27196. * Defines the name of the task
  27197. */
  27198. name: string,
  27199. /**
  27200. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27201. */
  27202. url: string,
  27203. /**
  27204. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27205. */
  27206. extensions?: string[] | undefined,
  27207. /**
  27208. * Defines if mipmaps should not be generated (default is false)
  27209. */
  27210. noMipmap?: boolean | undefined,
  27211. /**
  27212. * Defines the explicit list of files (undefined by default)
  27213. */
  27214. files?: string[] | undefined);
  27215. /**
  27216. * Execute the current task
  27217. * @param scene defines the scene where you want your assets to be loaded
  27218. * @param onSuccess is a callback called when the task is successfully executed
  27219. * @param onError is a callback called if an error occurs
  27220. */
  27221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27222. }
  27223. /**
  27224. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27225. */
  27226. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27227. /**
  27228. * Defines the name of the task
  27229. */
  27230. name: string;
  27231. /**
  27232. * Defines the location of the file to load
  27233. */
  27234. url: string;
  27235. /**
  27236. * Defines the desired size (the more it increases the longer the generation will be)
  27237. */
  27238. size: number;
  27239. /**
  27240. * Defines if mipmaps should not be generated (default is false)
  27241. */
  27242. noMipmap: boolean;
  27243. /**
  27244. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27245. */
  27246. generateHarmonics: boolean;
  27247. /**
  27248. * 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)
  27249. */
  27250. gammaSpace: boolean;
  27251. /**
  27252. * Internal Use Only
  27253. */
  27254. reserved: boolean;
  27255. /**
  27256. * Gets the loaded texture
  27257. */
  27258. texture: HDRCubeTexture;
  27259. /**
  27260. * Callback called when the task is successful
  27261. */
  27262. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27263. /**
  27264. * Callback called when the task is successful
  27265. */
  27266. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27267. /**
  27268. * Creates a new HDRCubeTextureAssetTask object
  27269. * @param name defines the name of the task
  27270. * @param url defines the location of the file to load
  27271. * @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.
  27272. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27273. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27274. * @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)
  27275. * @param reserved Internal use only
  27276. */
  27277. constructor(
  27278. /**
  27279. * Defines the name of the task
  27280. */
  27281. name: string,
  27282. /**
  27283. * Defines the location of the file to load
  27284. */
  27285. url: string,
  27286. /**
  27287. * Defines the desired size (the more it increases the longer the generation will be)
  27288. */
  27289. size: number,
  27290. /**
  27291. * Defines if mipmaps should not be generated (default is false)
  27292. */
  27293. noMipmap?: boolean,
  27294. /**
  27295. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27296. */
  27297. generateHarmonics?: boolean,
  27298. /**
  27299. * 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)
  27300. */
  27301. gammaSpace?: boolean,
  27302. /**
  27303. * Internal Use Only
  27304. */
  27305. reserved?: boolean);
  27306. /**
  27307. * Execute the current task
  27308. * @param scene defines the scene where you want your assets to be loaded
  27309. * @param onSuccess is a callback called when the task is successfully executed
  27310. * @param onError is a callback called if an error occurs
  27311. */
  27312. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27313. }
  27314. /**
  27315. * This class can be used to easily import assets into a scene
  27316. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27317. */
  27318. class AssetsManager {
  27319. private _scene;
  27320. private _isLoading;
  27321. protected _tasks: AbstractAssetTask[];
  27322. protected _waitingTasksCount: number;
  27323. protected _totalTasksCount: number;
  27324. /**
  27325. * Callback called when all tasks are processed
  27326. */
  27327. onFinish: (tasks: AbstractAssetTask[]) => void;
  27328. /**
  27329. * Callback called when a task is successful
  27330. */
  27331. onTaskSuccess: (task: AbstractAssetTask) => void;
  27332. /**
  27333. * Callback called when a task had an error
  27334. */
  27335. onTaskError: (task: AbstractAssetTask) => void;
  27336. /**
  27337. * Callback called when a task is done (whatever the result is)
  27338. */
  27339. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27340. /**
  27341. * Observable called when all tasks are processed
  27342. */
  27343. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27344. /**
  27345. * Observable called when a task had an error
  27346. */
  27347. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27348. /**
  27349. * Observable called when a task is successful
  27350. */
  27351. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27352. /**
  27353. * Observable called when a task is done (whatever the result is)
  27354. */
  27355. onProgressObservable: Observable<IAssetsProgressEvent>;
  27356. /**
  27357. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27359. */
  27360. useDefaultLoadingScreen: boolean;
  27361. /**
  27362. * Creates a new AssetsManager
  27363. * @param scene defines the scene to work on
  27364. */
  27365. constructor(scene: Scene);
  27366. /**
  27367. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27368. * @param taskName defines the name of the new task
  27369. * @param meshesNames defines the name of meshes to load
  27370. * @param rootUrl defines the root url to use to locate files
  27371. * @param sceneFilename defines the filename of the scene file
  27372. * @returns a new {BABYLON.MeshAssetTask} object
  27373. */
  27374. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27375. /**
  27376. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27377. * @param taskName defines the name of the new task
  27378. * @param url defines the url of the file to load
  27379. * @returns a new {BABYLON.TextFileAssetTask} object
  27380. */
  27381. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27382. /**
  27383. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27384. * @param taskName defines the name of the new task
  27385. * @param url defines the url of the file to load
  27386. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27387. */
  27388. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27389. /**
  27390. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27391. * @param taskName defines the name of the new task
  27392. * @param url defines the url of the file to load
  27393. * @returns a new {BABYLON.ImageAssetTask} object
  27394. */
  27395. addImageTask(taskName: string, url: string): ImageAssetTask;
  27396. /**
  27397. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27398. * @param taskName defines the name of the new task
  27399. * @param url defines the url of the file to load
  27400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27401. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27402. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27403. * @returns a new {BABYLON.TextureAssetTask} object
  27404. */
  27405. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27406. /**
  27407. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27408. * @param taskName defines the name of the new task
  27409. * @param url defines the url of the file to load
  27410. * @param extensions defines the extension to use to load the cube map (can be null)
  27411. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27412. * @param files defines the list of files to load (can be null)
  27413. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27414. */
  27415. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27416. /**
  27417. *
  27418. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27419. * @param taskName defines the name of the new task
  27420. * @param url defines the url of the file to load
  27421. * @param size defines the size you want for the cubemap (can be null)
  27422. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27423. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27424. * @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)
  27425. * @param reserved Internal use only
  27426. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27427. */
  27428. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27429. private _decreaseWaitingTasksCount(task);
  27430. private _runTask(task);
  27431. /**
  27432. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27433. * @return the current instance of the {BABYLON.AssetsManager}
  27434. */
  27435. reset(): AssetsManager;
  27436. /**
  27437. * Start the loading process
  27438. * @return the current instance of the {BABYLON.AssetsManager}
  27439. */
  27440. load(): AssetsManager;
  27441. }
  27442. }
  27443. declare module BABYLON {
  27444. /**
  27445. * Class used to enable access to IndexedDB
  27446. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27447. */
  27448. class Database {
  27449. private callbackManifestChecked;
  27450. private currentSceneUrl;
  27451. private db;
  27452. private _enableSceneOffline;
  27453. private _enableTexturesOffline;
  27454. private manifestVersionFound;
  27455. private mustUpdateRessources;
  27456. private hasReachedQuota;
  27457. private isSupported;
  27458. private idbFactory;
  27459. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27460. static IsUASupportingBlobStorage: boolean;
  27461. /** Gets a boolean indicating if Database storate is enabled */
  27462. static IDBStorageEnabled: boolean;
  27463. /**
  27464. * Gets a boolean indicating if scene must be saved in the database
  27465. */
  27466. readonly enableSceneOffline: boolean;
  27467. /**
  27468. * Gets a boolean indicating if textures must be saved in the database
  27469. */
  27470. readonly enableTexturesOffline: boolean;
  27471. /**
  27472. * Creates a new Database
  27473. * @param urlToScene defines the url to load the scene
  27474. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27475. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27476. */
  27477. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27478. private static _ParseURL;
  27479. private static _ReturnFullUrlLocation;
  27480. private _checkManifestFile();
  27481. /**
  27482. * Open the database and make it available
  27483. * @param successCallback defines the callback to call on success
  27484. * @param errorCallback defines the callback to call on error
  27485. */
  27486. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27487. /**
  27488. * Loads an image from the database
  27489. * @param url defines the url to load from
  27490. * @param image defines the target DOM image
  27491. */
  27492. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27493. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27494. private _saveImageIntoDBAsync(url, image);
  27495. private _checkVersionFromDB(url, versionLoaded);
  27496. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27497. private _saveVersionIntoDBAsync(url, callback);
  27498. /**
  27499. * Loads a file from database
  27500. * @param url defines the URL to load from
  27501. * @param sceneLoaded defines a callback to call on success
  27502. * @param progressCallBack defines a callback to call when progress changed
  27503. * @param errorCallback defines a callback to call on error
  27504. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27505. */
  27506. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27507. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27508. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27509. }
  27510. }
  27511. declare module BABYLON {
  27512. interface DDSInfo {
  27513. width: number;
  27514. height: number;
  27515. mipmapCount: number;
  27516. isFourCC: boolean;
  27517. isRGB: boolean;
  27518. isLuminance: boolean;
  27519. isCube: boolean;
  27520. isCompressed: boolean;
  27521. dxgiFormat: number;
  27522. textureType: number;
  27523. /** Sphericle polynomial created for the dds texture */
  27524. sphericalPolynomial?: SphericalPolynomial;
  27525. }
  27526. class DDSTools {
  27527. static StoreLODInAlphaChannel: boolean;
  27528. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27529. private static _FloatView;
  27530. private static _Int32View;
  27531. private static _ToHalfFloat(value);
  27532. private static _FromHalfFloat(value);
  27533. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27534. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27535. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27536. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27537. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27538. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27539. private static _ExtractLongWordOrder(value);
  27540. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27541. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27542. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27543. }
  27544. }
  27545. declare module BABYLON {
  27546. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27547. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27548. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27549. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27550. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27551. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27552. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27553. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27554. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27555. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27556. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27557. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27558. /**
  27559. * Decorator used to define property that can be serialized as reference to a camera
  27560. * @param sourceName defines the name of the property to decorate
  27561. */
  27562. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27563. class SerializationHelper {
  27564. static Serialize<T>(entity: T, serializationObject?: any): any;
  27565. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27566. static Clone<T>(creationFunction: () => T, source: T): T;
  27567. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27568. }
  27569. }
  27570. declare module BABYLON {
  27571. /**
  27572. * Wrapper class for promise with external resolve and reject.
  27573. */
  27574. class Deferred<T> {
  27575. /**
  27576. * The promise associated with this deferred object.
  27577. */
  27578. readonly promise: Promise<T>;
  27579. private _resolve;
  27580. private _reject;
  27581. /**
  27582. * The resolve method of the promise associated with this deferred object.
  27583. */
  27584. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27585. /**
  27586. * The reject method of the promise associated with this deferred object.
  27587. */
  27588. readonly reject: (reason?: any) => void;
  27589. /**
  27590. * Constructor for this deferred object.
  27591. */
  27592. constructor();
  27593. }
  27594. }
  27595. declare module BABYLON {
  27596. class FilesInput {
  27597. static FilesToLoad: {
  27598. [key: string]: File;
  27599. };
  27600. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27601. private _engine;
  27602. private _currentScene;
  27603. private _sceneLoadedCallback;
  27604. private _progressCallback;
  27605. private _additionalRenderLoopLogicCallback;
  27606. private _textureLoadingCallback;
  27607. private _startingProcessingFilesCallback;
  27608. private _onReloadCallback;
  27609. private _errorCallback;
  27610. private _elementToMonitor;
  27611. private _sceneFileToLoad;
  27612. private _filesToLoad;
  27613. 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);
  27614. private _dragEnterHandler;
  27615. private _dragOverHandler;
  27616. private _dropHandler;
  27617. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27618. dispose(): void;
  27619. private renderFunction();
  27620. private drag(e);
  27621. private drop(eventDrop);
  27622. private _traverseFolder(folder, files, remaining, callback);
  27623. private _processFiles(files);
  27624. loadFiles(event: any): void;
  27625. private _processReload();
  27626. reload(): void;
  27627. }
  27628. }
  27629. declare module BABYLON {
  27630. /**
  27631. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27632. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27633. */
  27634. class KhronosTextureContainer {
  27635. arrayBuffer: any;
  27636. static HEADER_LEN: number;
  27637. static COMPRESSED_2D: number;
  27638. static COMPRESSED_3D: number;
  27639. static TEX_2D: number;
  27640. static TEX_3D: number;
  27641. glType: number;
  27642. glTypeSize: number;
  27643. glFormat: number;
  27644. glInternalFormat: number;
  27645. glBaseInternalFormat: number;
  27646. pixelWidth: number;
  27647. pixelHeight: number;
  27648. pixelDepth: number;
  27649. numberOfArrayElements: number;
  27650. numberOfFaces: number;
  27651. numberOfMipmapLevels: number;
  27652. bytesOfKeyValueData: number;
  27653. loadType: number;
  27654. /**
  27655. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27656. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27657. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27658. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27659. */
  27660. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27661. switchEndainness(val: number): number;
  27662. /**
  27663. * It is assumed that the texture has already been created & is currently bound
  27664. */
  27665. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27666. private _upload2DCompressedLevels(gl, loadMipmaps);
  27667. }
  27668. }
  27669. declare module BABYLON {
  27670. /**
  27671. * A class serves as a medium between the observable and its observers
  27672. */
  27673. class EventState {
  27674. /**
  27675. * Create a new EventState
  27676. * @param mask defines the mask associated with this state
  27677. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27678. * @param target defines the original target of the state
  27679. * @param currentTarget defines the current target of the state
  27680. */
  27681. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27682. /**
  27683. * Initialize the current event state
  27684. * @param mask defines the mask associated with this state
  27685. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27686. * @param target defines the original target of the state
  27687. * @param currentTarget defines the current target of the state
  27688. * @returns the current event state
  27689. */
  27690. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27691. /**
  27692. * An Observer can set this property to true to prevent subsequent observers of being notified
  27693. */
  27694. skipNextObservers: boolean;
  27695. /**
  27696. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27697. */
  27698. mask: number;
  27699. /**
  27700. * The object that originally notified the event
  27701. */
  27702. target?: any;
  27703. /**
  27704. * The current object in the bubbling phase
  27705. */
  27706. currentTarget?: any;
  27707. /**
  27708. * This will be populated with the return value of the last function that was executed.
  27709. * If it is the first function in the callback chain it will be the event data.
  27710. */
  27711. lastReturnValue?: any;
  27712. }
  27713. /**
  27714. * Represent an Observer registered to a given Observable object.
  27715. */
  27716. class Observer<T> {
  27717. /**
  27718. * Defines the callback to call when the observer is notified
  27719. */
  27720. callback: (eventData: T, eventState: EventState) => void;
  27721. /**
  27722. * Defines the mask of the observer (used to filter notifications)
  27723. */
  27724. mask: number;
  27725. /**
  27726. * Defines the current scope used to restore the JS context
  27727. */
  27728. scope: any;
  27729. /** @hidden */
  27730. /**
  27731. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27732. */
  27733. unregisterOnNextCall: boolean;
  27734. /**
  27735. * Creates a new observer
  27736. * @param callback defines the callback to call when the observer is notified
  27737. * @param mask defines the mask of the observer (used to filter notifications)
  27738. * @param scope defines the current scope used to restore the JS context
  27739. */
  27740. constructor(
  27741. /**
  27742. * Defines the callback to call when the observer is notified
  27743. */
  27744. callback: (eventData: T, eventState: EventState) => void,
  27745. /**
  27746. * Defines the mask of the observer (used to filter notifications)
  27747. */
  27748. mask: number,
  27749. /**
  27750. * Defines the current scope used to restore the JS context
  27751. */
  27752. scope?: any);
  27753. }
  27754. /**
  27755. * Represent a list of observers registered to multiple Observables object.
  27756. */
  27757. class MultiObserver<T> {
  27758. private _observers;
  27759. private _observables;
  27760. /**
  27761. * Release associated resources
  27762. */
  27763. dispose(): void;
  27764. /**
  27765. * Raise a callback when one of the observable will notify
  27766. * @param observables defines a list of observables to watch
  27767. * @param callback defines the callback to call on notification
  27768. * @param mask defines the mask used to filter notifications
  27769. * @param scope defines the current scope used to restore the JS context
  27770. * @returns the new MultiObserver
  27771. */
  27772. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27773. }
  27774. /**
  27775. * The Observable class is a simple implementation of the Observable pattern.
  27776. *
  27777. * 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.
  27778. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27779. * 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).
  27780. * 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.
  27781. */
  27782. class Observable<T> {
  27783. private _observers;
  27784. private _eventState;
  27785. private _onObserverAdded;
  27786. /**
  27787. * Creates a new observable
  27788. * @param onObserverAdded defines a callback to call when a new observer is added
  27789. */
  27790. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27791. /**
  27792. * Create a new Observer with the specified callback
  27793. * @param callback the callback that will be executed for that Observer
  27794. * @param mask the mask used to filter observers
  27795. * @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.
  27796. * @param scope optional scope for the callback to be called from
  27797. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27798. * @returns the new observer created for the callback
  27799. */
  27800. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27801. /**
  27802. * Create a new Observer with the specified callback and unregisters after the next notification
  27803. * @param callback the callback that will be executed for that Observer
  27804. * @returns the new observer created for the callback
  27805. */
  27806. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  27807. /**
  27808. * Remove an Observer from the Observable object
  27809. * @param observer the instance of the Observer to remove
  27810. * @returns false if it doesn't belong to this Observable
  27811. */
  27812. remove(observer: Nullable<Observer<T>>): boolean;
  27813. /**
  27814. * Remove a callback from the Observable object
  27815. * @param callback the callback to remove
  27816. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27817. * @returns false if it doesn't belong to this Observable
  27818. */
  27819. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27820. private _deferUnregister(observer);
  27821. /**
  27822. * Notify all Observers by calling their respective callback with the given data
  27823. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27824. * @param eventData defines the data to send to all observers
  27825. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27826. * @param target defines the original target of the state
  27827. * @param currentTarget defines the current target of the state
  27828. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27829. */
  27830. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27831. /**
  27832. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27833. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27834. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27835. * and it is crucial that all callbacks will be executed.
  27836. * The order of the callbacks is kept, callbacks are not executed parallel.
  27837. *
  27838. * @param eventData The data to be sent to each callback
  27839. * @param mask is used to filter observers defaults to -1
  27840. * @param target defines the callback target (see EventState)
  27841. * @param currentTarget defines he current object in the bubbling phase
  27842. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27843. */
  27844. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27845. /**
  27846. * Notify a specific observer
  27847. * @param observer defines the observer to notify
  27848. * @param eventData defines the data to be sent to each callback
  27849. * @param mask is used to filter observers defaults to -1
  27850. */
  27851. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27852. /**
  27853. * Gets a boolean indicating if the observable has at least one observer
  27854. * @returns true is the Observable has at least one Observer registered
  27855. */
  27856. hasObservers(): boolean;
  27857. /**
  27858. * Clear the list of observers
  27859. */
  27860. clear(): void;
  27861. /**
  27862. * Clone the current observable
  27863. * @returns a new observable
  27864. */
  27865. clone(): Observable<T>;
  27866. /**
  27867. * Does this observable handles observer registered with a given mask
  27868. * @param mask defines the mask to be tested
  27869. * @return whether or not one observer registered with the given mask is handeled
  27870. **/
  27871. hasSpecificMask(mask?: number): boolean;
  27872. }
  27873. }
  27874. declare module BABYLON {
  27875. /**
  27876. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27877. */
  27878. class PerformanceMonitor {
  27879. private _enabled;
  27880. private _rollingFrameTime;
  27881. private _lastFrameTimeMs;
  27882. /**
  27883. * constructor
  27884. * @param frameSampleSize The number of samples required to saturate the sliding window
  27885. */
  27886. constructor(frameSampleSize?: number);
  27887. /**
  27888. * Samples current frame
  27889. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27890. */
  27891. sampleFrame(timeMs?: number): void;
  27892. /**
  27893. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27894. * @return Average frame time in milliseconds
  27895. */
  27896. readonly averageFrameTime: number;
  27897. /**
  27898. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27899. * @return Frame time variance in milliseconds squared
  27900. */
  27901. readonly averageFrameTimeVariance: number;
  27902. /**
  27903. * Returns the frame time of the most recent frame
  27904. * @return Frame time in milliseconds
  27905. */
  27906. readonly instantaneousFrameTime: number;
  27907. /**
  27908. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27909. * @return Framerate in frames per second
  27910. */
  27911. readonly averageFPS: number;
  27912. /**
  27913. * Returns the average framerate in frames per second using the most recent frame time
  27914. * @return Framerate in frames per second
  27915. */
  27916. readonly instantaneousFPS: number;
  27917. /**
  27918. * Returns true if enough samples have been taken to completely fill the sliding window
  27919. * @return true if saturated
  27920. */
  27921. readonly isSaturated: boolean;
  27922. /**
  27923. * Enables contributions to the sliding window sample set
  27924. */
  27925. enable(): void;
  27926. /**
  27927. * Disables contributions to the sliding window sample set
  27928. * Samples will not be interpolated over the disabled period
  27929. */
  27930. disable(): void;
  27931. /**
  27932. * Returns true if sampling is enabled
  27933. * @return true if enabled
  27934. */
  27935. readonly isEnabled: boolean;
  27936. /**
  27937. * Resets performance monitor
  27938. */
  27939. reset(): void;
  27940. }
  27941. /**
  27942. * RollingAverage
  27943. *
  27944. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27945. */
  27946. class RollingAverage {
  27947. /**
  27948. * Current average
  27949. */
  27950. average: number;
  27951. /**
  27952. * Current variance
  27953. */
  27954. variance: number;
  27955. protected _samples: Array<number>;
  27956. protected _sampleCount: number;
  27957. protected _pos: number;
  27958. protected _m2: number;
  27959. /**
  27960. * constructor
  27961. * @param length The number of samples required to saturate the sliding window
  27962. */
  27963. constructor(length: number);
  27964. /**
  27965. * Adds a sample to the sample set
  27966. * @param v The sample value
  27967. */
  27968. add(v: number): void;
  27969. /**
  27970. * Returns previously added values or null if outside of history or outside the sliding window domain
  27971. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27972. * @return Value previously recorded with add() or null if outside of range
  27973. */
  27974. history(i: number): number;
  27975. /**
  27976. * Returns true if enough samples have been taken to completely fill the sliding window
  27977. * @return true if sample-set saturated
  27978. */
  27979. isSaturated(): boolean;
  27980. /**
  27981. * Resets the rolling average (equivalent to 0 samples taken so far)
  27982. */
  27983. reset(): void;
  27984. /**
  27985. * Wraps a value around the sample range boundaries
  27986. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27987. * @return Wrapped position in sample range
  27988. */
  27989. protected _wrapPosition(i: number): number;
  27990. }
  27991. }
  27992. declare module BABYLON {
  27993. /**
  27994. * Helper class that provides a small promise polyfill
  27995. */
  27996. class PromisePolyfill {
  27997. /**
  27998. * Static function used to check if the polyfill is required
  27999. * If this is the case then the function will inject the polyfill to window.Promise
  28000. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28001. */
  28002. static Apply(force?: boolean): void;
  28003. }
  28004. }
  28005. declare module BABYLON {
  28006. /**
  28007. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28009. */
  28010. class SceneOptimization {
  28011. /**
  28012. * Defines the priority of this optimization (0 by default which means first in the list)
  28013. */
  28014. priority: number;
  28015. /**
  28016. * Gets a string describing the action executed by the current optimization
  28017. * @returns description string
  28018. */
  28019. getDescription(): string;
  28020. /**
  28021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28022. * @param scene defines the current scene where to apply this optimization
  28023. * @param optimizer defines the current optimizer
  28024. * @returns true if everything that can be done was applied
  28025. */
  28026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28027. /**
  28028. * Creates the SceneOptimization object
  28029. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28030. * @param desc defines the description associated with the optimization
  28031. */
  28032. constructor(
  28033. /**
  28034. * Defines the priority of this optimization (0 by default which means first in the list)
  28035. */
  28036. priority?: number);
  28037. }
  28038. /**
  28039. * Defines an optimization used to reduce the size of render target textures
  28040. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28041. */
  28042. class TextureOptimization extends SceneOptimization {
  28043. /**
  28044. * Defines the priority of this optimization (0 by default which means first in the list)
  28045. */
  28046. priority: number;
  28047. /**
  28048. * 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
  28049. */
  28050. maximumSize: number;
  28051. /**
  28052. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28053. */
  28054. step: number;
  28055. /**
  28056. * Gets a string describing the action executed by the current optimization
  28057. * @returns description string
  28058. */
  28059. getDescription(): string;
  28060. /**
  28061. * Creates the TextureOptimization object
  28062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28063. * @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
  28064. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28065. */
  28066. constructor(
  28067. /**
  28068. * Defines the priority of this optimization (0 by default which means first in the list)
  28069. */
  28070. priority?: number,
  28071. /**
  28072. * 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
  28073. */
  28074. maximumSize?: number,
  28075. /**
  28076. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28077. */
  28078. step?: number);
  28079. /**
  28080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28081. * @param scene defines the current scene where to apply this optimization
  28082. * @param optimizer defines the current optimizer
  28083. * @returns true if everything that can be done was applied
  28084. */
  28085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28086. }
  28087. /**
  28088. * Defines an optimization used to increase or decrease the rendering resolution
  28089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28090. */
  28091. class HardwareScalingOptimization extends SceneOptimization {
  28092. /**
  28093. * Defines the priority of this optimization (0 by default which means first in the list)
  28094. */
  28095. priority: number;
  28096. /**
  28097. * Defines the maximum scale to use (2 by default)
  28098. */
  28099. maximumScale: number;
  28100. /**
  28101. * Defines the step to use between two passes (0.5 by default)
  28102. */
  28103. step: number;
  28104. private _currentScale;
  28105. private _directionOffset;
  28106. /**
  28107. * Gets a string describing the action executed by the current optimization
  28108. * @return description string
  28109. */
  28110. getDescription(): string;
  28111. /**
  28112. * Creates the HardwareScalingOptimization object
  28113. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28114. * @param maximumScale defines the maximum scale to use (2 by default)
  28115. * @param step defines the step to use between two passes (0.5 by default)
  28116. */
  28117. constructor(
  28118. /**
  28119. * Defines the priority of this optimization (0 by default which means first in the list)
  28120. */
  28121. priority?: number,
  28122. /**
  28123. * Defines the maximum scale to use (2 by default)
  28124. */
  28125. maximumScale?: number,
  28126. /**
  28127. * Defines the step to use between two passes (0.5 by default)
  28128. */
  28129. step?: number);
  28130. /**
  28131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28132. * @param scene defines the current scene where to apply this optimization
  28133. * @param optimizer defines the current optimizer
  28134. * @returns true if everything that can be done was applied
  28135. */
  28136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28137. }
  28138. /**
  28139. * Defines an optimization used to remove shadows
  28140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28141. */
  28142. class ShadowsOptimization extends SceneOptimization {
  28143. /**
  28144. * Gets a string describing the action executed by the current optimization
  28145. * @return description string
  28146. */
  28147. getDescription(): string;
  28148. /**
  28149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28150. * @param scene defines the current scene where to apply this optimization
  28151. * @param optimizer defines the current optimizer
  28152. * @returns true if everything that can be done was applied
  28153. */
  28154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28155. }
  28156. /**
  28157. * Defines an optimization used to turn post-processes off
  28158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28159. */
  28160. class PostProcessesOptimization extends SceneOptimization {
  28161. /**
  28162. * Gets a string describing the action executed by the current optimization
  28163. * @return description string
  28164. */
  28165. getDescription(): string;
  28166. /**
  28167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28168. * @param scene defines the current scene where to apply this optimization
  28169. * @param optimizer defines the current optimizer
  28170. * @returns true if everything that can be done was applied
  28171. */
  28172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28173. }
  28174. /**
  28175. * Defines an optimization used to turn lens flares off
  28176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28177. */
  28178. class LensFlaresOptimization extends SceneOptimization {
  28179. /**
  28180. * Gets a string describing the action executed by the current optimization
  28181. * @return description string
  28182. */
  28183. getDescription(): string;
  28184. /**
  28185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28186. * @param scene defines the current scene where to apply this optimization
  28187. * @param optimizer defines the current optimizer
  28188. * @returns true if everything that can be done was applied
  28189. */
  28190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28191. }
  28192. /**
  28193. * Defines an optimization based on user defined callback.
  28194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28195. */
  28196. class CustomOptimization extends SceneOptimization {
  28197. /**
  28198. * Callback called to apply the custom optimization.
  28199. */
  28200. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28201. /**
  28202. * Callback called to get custom description
  28203. */
  28204. onGetDescription: () => string;
  28205. /**
  28206. * Gets a string describing the action executed by the current optimization
  28207. * @returns description string
  28208. */
  28209. getDescription(): string;
  28210. /**
  28211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28212. * @param scene defines the current scene where to apply this optimization
  28213. * @param optimizer defines the current optimizer
  28214. * @returns true if everything that can be done was applied
  28215. */
  28216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28217. }
  28218. /**
  28219. * Defines an optimization used to turn particles off
  28220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28221. */
  28222. class ParticlesOptimization extends SceneOptimization {
  28223. /**
  28224. * Gets a string describing the action executed by the current optimization
  28225. * @return description string
  28226. */
  28227. getDescription(): string;
  28228. /**
  28229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28230. * @param scene defines the current scene where to apply this optimization
  28231. * @param optimizer defines the current optimizer
  28232. * @returns true if everything that can be done was applied
  28233. */
  28234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28235. }
  28236. /**
  28237. * Defines an optimization used to turn render targets off
  28238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28239. */
  28240. class RenderTargetsOptimization extends SceneOptimization {
  28241. /**
  28242. * Gets a string describing the action executed by the current optimization
  28243. * @return description string
  28244. */
  28245. getDescription(): string;
  28246. /**
  28247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28248. * @param scene defines the current scene where to apply this optimization
  28249. * @param optimizer defines the current optimizer
  28250. * @returns true if everything that can be done was applied
  28251. */
  28252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28253. }
  28254. /**
  28255. * Defines an optimization used to merge meshes with compatible materials
  28256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28257. */
  28258. class MergeMeshesOptimization extends SceneOptimization {
  28259. private static _UpdateSelectionTree;
  28260. /**
  28261. * Gets or sets a boolean which defines if optimization octree has to be updated
  28262. */
  28263. /**
  28264. * Gets or sets a boolean which defines if optimization octree has to be updated
  28265. */
  28266. static UpdateSelectionTree: boolean;
  28267. /**
  28268. * Gets a string describing the action executed by the current optimization
  28269. * @return description string
  28270. */
  28271. getDescription(): string;
  28272. private _canBeMerged;
  28273. /**
  28274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28275. * @param scene defines the current scene where to apply this optimization
  28276. * @param optimizer defines the current optimizer
  28277. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28278. * @returns true if everything that can be done was applied
  28279. */
  28280. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28281. }
  28282. /**
  28283. * Defines a list of options used by SceneOptimizer
  28284. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28285. */
  28286. class SceneOptimizerOptions {
  28287. /**
  28288. * Defines the target frame rate to reach (60 by default)
  28289. */
  28290. targetFrameRate: number;
  28291. /**
  28292. * Defines the interval between two checkes (2000ms by default)
  28293. */
  28294. trackerDuration: number;
  28295. /**
  28296. * Gets the list of optimizations to apply
  28297. */
  28298. optimizations: SceneOptimization[];
  28299. /**
  28300. * Creates a new list of options used by SceneOptimizer
  28301. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28302. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28303. */
  28304. constructor(
  28305. /**
  28306. * Defines the target frame rate to reach (60 by default)
  28307. */
  28308. targetFrameRate?: number,
  28309. /**
  28310. * Defines the interval between two checkes (2000ms by default)
  28311. */
  28312. trackerDuration?: number);
  28313. /**
  28314. * Add a new optimization
  28315. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28316. * @returns the current SceneOptimizerOptions
  28317. */
  28318. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28319. /**
  28320. * Add a new custom optimization
  28321. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28322. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28323. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28324. * @returns the current SceneOptimizerOptions
  28325. */
  28326. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28327. /**
  28328. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28329. * @param targetFrameRate defines the target frame rate (60 by default)
  28330. * @returns a SceneOptimizerOptions object
  28331. */
  28332. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28333. /**
  28334. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28335. * @param targetFrameRate defines the target frame rate (60 by default)
  28336. * @returns a SceneOptimizerOptions object
  28337. */
  28338. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28339. /**
  28340. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28341. * @param targetFrameRate defines the target frame rate (60 by default)
  28342. * @returns a SceneOptimizerOptions object
  28343. */
  28344. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28345. }
  28346. /**
  28347. * Class used to run optimizations in order to reach a target frame rate
  28348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28349. */
  28350. class SceneOptimizer implements IDisposable {
  28351. private _isRunning;
  28352. private _options;
  28353. private _scene;
  28354. private _currentPriorityLevel;
  28355. private _targetFrameRate;
  28356. private _trackerDuration;
  28357. private _currentFrameRate;
  28358. private _sceneDisposeObserver;
  28359. private _improvementMode;
  28360. /**
  28361. * Defines an observable called when the optimizer reaches the target frame rate
  28362. */
  28363. onSuccessObservable: Observable<SceneOptimizer>;
  28364. /**
  28365. * Defines an observable called when the optimizer enables an optimization
  28366. */
  28367. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28368. /**
  28369. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28370. */
  28371. onFailureObservable: Observable<SceneOptimizer>;
  28372. /**
  28373. * Gets a boolean indicating if the optimizer is in improvement mode
  28374. */
  28375. readonly isInImprovementMode: boolean;
  28376. /**
  28377. * Gets the current priority level (0 at start)
  28378. */
  28379. readonly currentPriorityLevel: number;
  28380. /**
  28381. * Gets the current frame rate checked by the SceneOptimizer
  28382. */
  28383. readonly currentFrameRate: number;
  28384. /**
  28385. * Gets or sets the current target frame rate (60 by default)
  28386. */
  28387. /**
  28388. * Gets or sets the current target frame rate (60 by default)
  28389. */
  28390. targetFrameRate: number;
  28391. /**
  28392. * Gets or sets the current interval between two checks (every 2000ms by default)
  28393. */
  28394. /**
  28395. * Gets or sets the current interval between two checks (every 2000ms by default)
  28396. */
  28397. trackerDuration: number;
  28398. /**
  28399. * Gets the list of active optimizations
  28400. */
  28401. readonly optimizations: SceneOptimization[];
  28402. /**
  28403. * Creates a new SceneOptimizer
  28404. * @param scene defines the scene to work on
  28405. * @param options defines the options to use with the SceneOptimizer
  28406. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28407. * @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)
  28408. */
  28409. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28410. /**
  28411. * Stops the current optimizer
  28412. */
  28413. stop(): void;
  28414. /**
  28415. * Reset the optimizer to initial step (current priority level = 0)
  28416. */
  28417. reset(): void;
  28418. /**
  28419. * Start the optimizer. By default it will try to reach a specific framerate
  28420. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28421. */
  28422. start(): void;
  28423. private _checkCurrentState();
  28424. /**
  28425. * Release all resources
  28426. */
  28427. dispose(): void;
  28428. /**
  28429. * Helper function to create a SceneOptimizer with one single line of code
  28430. * @param scene defines the scene to work on
  28431. * @param options defines the options to use with the SceneOptimizer
  28432. * @param onSuccess defines a callback to call on success
  28433. * @param onFailure defines a callback to call on failure
  28434. * @returns the new SceneOptimizer object
  28435. */
  28436. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28437. }
  28438. }
  28439. declare module BABYLON {
  28440. class SceneSerializer {
  28441. static ClearCache(): void;
  28442. static Serialize(scene: Scene): any;
  28443. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28444. }
  28445. }
  28446. declare module BABYLON {
  28447. class SmartArray<T> {
  28448. data: Array<T>;
  28449. length: number;
  28450. protected _id: number;
  28451. [index: number]: T;
  28452. constructor(capacity: number);
  28453. push(value: T): void;
  28454. forEach(func: (content: T) => void): void;
  28455. sort(compareFn: (a: T, b: T) => number): void;
  28456. reset(): void;
  28457. dispose(): void;
  28458. concat(array: any): void;
  28459. indexOf(value: T): number;
  28460. contains(value: T): boolean;
  28461. private static _GlobalId;
  28462. }
  28463. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28464. private _duplicateId;
  28465. [index: number]: T;
  28466. push(value: T): void;
  28467. pushNoDuplicate(value: T): boolean;
  28468. reset(): void;
  28469. concatWithNoDuplicate(array: any): void;
  28470. }
  28471. }
  28472. declare module BABYLON {
  28473. /**
  28474. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28475. * The underlying implementation relies on an associative array to ensure the best performances.
  28476. * The value can be anything including 'null' but except 'undefined'
  28477. */
  28478. class StringDictionary<T> {
  28479. /**
  28480. * This will clear this dictionary and copy the content from the 'source' one.
  28481. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28482. * @param source the dictionary to take the content from and copy to this dictionary
  28483. */
  28484. copyFrom(source: StringDictionary<T>): void;
  28485. /**
  28486. * Get a value based from its key
  28487. * @param key the given key to get the matching value from
  28488. * @return the value if found, otherwise undefined is returned
  28489. */
  28490. get(key: string): T | undefined;
  28491. /**
  28492. * Get a value from its key or add it if it doesn't exist.
  28493. * This method will ensure you that a given key/data will be present in the dictionary.
  28494. * @param key the given key to get the matching value from
  28495. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28496. * The factory will only be invoked if there's no data for the given key.
  28497. * @return the value corresponding to the key.
  28498. */
  28499. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28500. /**
  28501. * Get a value from its key if present in the dictionary otherwise add it
  28502. * @param key the key to get the value from
  28503. * @param val if there's no such key/value pair in the dictionary add it with this value
  28504. * @return the value corresponding to the key
  28505. */
  28506. getOrAdd(key: string, val: T): T;
  28507. /**
  28508. * Check if there's a given key in the dictionary
  28509. * @param key the key to check for
  28510. * @return true if the key is present, false otherwise
  28511. */
  28512. contains(key: string): boolean;
  28513. /**
  28514. * Add a new key and its corresponding value
  28515. * @param key the key to add
  28516. * @param value the value corresponding to the key
  28517. * @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
  28518. */
  28519. add(key: string, value: T): boolean;
  28520. set(key: string, value: T): boolean;
  28521. /**
  28522. * Get the element of the given key and remove it from the dictionary
  28523. * @param key
  28524. */
  28525. getAndRemove(key: string): Nullable<T>;
  28526. /**
  28527. * Remove a key/value from the dictionary.
  28528. * @param key the key to remove
  28529. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28530. */
  28531. remove(key: string): boolean;
  28532. /**
  28533. * Clear the whole content of the dictionary
  28534. */
  28535. clear(): void;
  28536. readonly count: number;
  28537. /**
  28538. * Execute a callback on each key/val of the dictionary.
  28539. * Note that you can remove any element in this dictionary in the callback implementation
  28540. * @param callback the callback to execute on a given key/value pair
  28541. */
  28542. forEach(callback: (key: string, val: T) => void): void;
  28543. /**
  28544. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28545. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28546. * Note that you can remove any element in this dictionary in the callback implementation
  28547. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28548. */
  28549. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28550. private _count;
  28551. private _data;
  28552. }
  28553. }
  28554. declare module BABYLON {
  28555. class Tags {
  28556. static EnableFor(obj: any): void;
  28557. static DisableFor(obj: any): void;
  28558. static HasTags(obj: any): boolean;
  28559. static GetTags(obj: any, asString?: boolean): any;
  28560. static AddTagsTo(obj: any, tagsString: string): void;
  28561. private static _AddTagTo(obj: any, tag: string): void;
  28562. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28563. private static _RemoveTagFrom(obj: any, tag: string): void;
  28564. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28565. }
  28566. }
  28567. declare module BABYLON {
  28568. class TextureTools {
  28569. /**
  28570. * Uses the GPU to create a copy texture rescaled at a given size
  28571. * @param texture Texture to copy from
  28572. * @param width Desired width
  28573. * @param height Desired height
  28574. * @return Generated texture
  28575. */
  28576. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28577. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28578. private static _environmentBRDFBase64Texture;
  28579. }
  28580. }
  28581. declare module BABYLON {
  28582. class TGATools {
  28583. private static _TYPE_INDEXED;
  28584. private static _TYPE_RGB;
  28585. private static _TYPE_GREY;
  28586. private static _TYPE_RLE_INDEXED;
  28587. private static _TYPE_RLE_RGB;
  28588. private static _TYPE_RLE_GREY;
  28589. private static _ORIGIN_MASK;
  28590. private static _ORIGIN_SHIFT;
  28591. private static _ORIGIN_BL;
  28592. private static _ORIGIN_BR;
  28593. private static _ORIGIN_UL;
  28594. private static _ORIGIN_UR;
  28595. static GetTGAHeader(data: Uint8Array): any;
  28596. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28597. 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;
  28598. 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;
  28599. 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;
  28600. 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;
  28601. 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;
  28602. 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;
  28603. }
  28604. }
  28605. declare module BABYLON {
  28606. interface IAnimatable {
  28607. animations: Array<Animation>;
  28608. }
  28609. class LoadFileError extends Error {
  28610. request: XMLHttpRequest | undefined;
  28611. private static _setPrototypeOf;
  28612. constructor(message: string, request?: XMLHttpRequest | undefined);
  28613. }
  28614. class RetryStrategy {
  28615. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28616. }
  28617. interface IFileRequest {
  28618. /**
  28619. * Raised when the request is complete (success or error).
  28620. */
  28621. onCompleteObservable: Observable<IFileRequest>;
  28622. /**
  28623. * Aborts the request for a file.
  28624. */
  28625. abort: () => void;
  28626. }
  28627. class Tools {
  28628. static BaseUrl: string;
  28629. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28630. /**
  28631. * Default behaviour for cors in the application.
  28632. * It can be a string if the expected behavior is identical in the entire app.
  28633. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28634. */
  28635. static CorsBehavior: string | ((url: string | string[]) => string);
  28636. static UseFallbackTexture: boolean;
  28637. /**
  28638. * Use this object to register external classes like custom textures or material
  28639. * to allow the laoders to instantiate them
  28640. */
  28641. static RegisteredExternalClasses: {
  28642. [key: string]: Object;
  28643. };
  28644. static fallbackTexture: string;
  28645. /**
  28646. * Interpolates between a and b via alpha
  28647. * @param a The lower value (returned when alpha = 0)
  28648. * @param b The upper value (returned when alpha = 1)
  28649. * @param alpha The interpolation-factor
  28650. * @return The mixed value
  28651. */
  28652. static Mix(a: number, b: number, alpha: number): number;
  28653. static Instantiate(className: string): any;
  28654. /**
  28655. * Provides a slice function that will work even on IE
  28656. * @param data defines the array to slice
  28657. * @param start defines the start of the data (optional)
  28658. * @param end defines the end of the data (optional)
  28659. * @returns the new sliced array
  28660. */
  28661. static Slice<T>(data: T, start?: number, end?: number): T;
  28662. static SetImmediate(action: () => void): void;
  28663. static IsExponentOfTwo(value: number): boolean;
  28664. private static _tmpFloatArray;
  28665. /**
  28666. * Returns the nearest 32-bit single precision float representation of a Number
  28667. * @param value A Number. If the parameter is of a different type, it will get converted
  28668. * to a number or to NaN if it cannot be converted
  28669. * @returns number
  28670. */
  28671. static FloatRound(value: number): number;
  28672. /**
  28673. * Find the next highest power of two.
  28674. * @param x Number to start search from.
  28675. * @return Next highest power of two.
  28676. */
  28677. static CeilingPOT(x: number): number;
  28678. /**
  28679. * Find the next lowest power of two.
  28680. * @param x Number to start search from.
  28681. * @return Next lowest power of two.
  28682. */
  28683. static FloorPOT(x: number): number;
  28684. /**
  28685. * Find the nearest power of two.
  28686. * @param x Number to start search from.
  28687. * @return Next nearest power of two.
  28688. */
  28689. static NearestPOT(x: number): number;
  28690. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28691. static GetFilename(path: string): string;
  28692. /**
  28693. * Extracts the "folder" part of a path (everything before the filename).
  28694. * @param uri The URI to extract the info from
  28695. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28696. * @returns The "folder" part of the path
  28697. */
  28698. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28699. static GetDOMTextContent(element: HTMLElement): string;
  28700. static ToDegrees(angle: number): number;
  28701. static ToRadians(angle: number): number;
  28702. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28703. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28704. minimum: Vector3;
  28705. maximum: Vector3;
  28706. };
  28707. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28708. minimum: Vector3;
  28709. maximum: Vector3;
  28710. };
  28711. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28712. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28713. minimum: Vector2;
  28714. maximum: Vector2;
  28715. };
  28716. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28717. static GetPointerPrefix(): string;
  28718. /**
  28719. * @param func - the function to be called
  28720. * @param requester - the object that will request the next frame. Falls back to window.
  28721. */
  28722. static QueueNewFrame(func: () => void, requester?: any): number;
  28723. static RequestFullscreen(element: HTMLElement): void;
  28724. static ExitFullscreen(): void;
  28725. static SetCorsBehavior(url: string | string[], element: {
  28726. crossOrigin: string | null;
  28727. }): void;
  28728. static CleanUrl(url: string): string;
  28729. static PreprocessUrl: (url: string) => string;
  28730. /**
  28731. * Loads an image as an HTMLImageElement.
  28732. * @param input url string, ArrayBuffer, or Blob to load
  28733. * @param onLoad callback called when the image successfully loads
  28734. * @param onError callback called when the image fails to load
  28735. * @param database database for caching
  28736. * @returns the HTMLImageElement of the loaded image
  28737. */
  28738. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28739. 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;
  28740. /**
  28741. * Load a script (identified by an url). When the url returns, the
  28742. * content of this file is added into a new script element, attached to the DOM (body element)
  28743. */
  28744. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28745. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28746. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28747. static FileAsURL(content: string): string;
  28748. static Format(value: number, decimals?: number): string;
  28749. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28750. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28751. static IsEmpty(obj: any): boolean;
  28752. static RegisterTopRootEvents(events: {
  28753. name: string;
  28754. handler: Nullable<(e: FocusEvent) => any>;
  28755. }[]): void;
  28756. static UnregisterTopRootEvents(events: {
  28757. name: string;
  28758. handler: Nullable<(e: FocusEvent) => any>;
  28759. }[]): void;
  28760. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28761. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28762. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28763. /**
  28764. * Generates an image screenshot from the specified camera.
  28765. *
  28766. * @param engine The engine to use for rendering
  28767. * @param camera The camera to use for rendering
  28768. * @param size This parameter can be set to a single number or to an object with the
  28769. * following (optional) properties: precision, width, height. If a single number is passed,
  28770. * it will be used for both width and height. If an object is passed, the screenshot size
  28771. * will be derived from the parameters. The precision property is a multiplier allowing
  28772. * rendering at a higher or lower resolution.
  28773. * @param successCallback The callback receives a single parameter which contains the
  28774. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28775. * src parameter of an <img> to display it.
  28776. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28777. * Check your browser for supported MIME types.
  28778. * @param samples Texture samples (default: 1)
  28779. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28780. * @param fileName A name for for the downloaded file.
  28781. * @constructor
  28782. */
  28783. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28784. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28785. /**
  28786. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28787. * Be aware Math.random() could cause collisions, but:
  28788. * "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"
  28789. */
  28790. static RandomId(): string;
  28791. /**
  28792. * Test if the given uri is a base64 string.
  28793. * @param uri The uri to test
  28794. * @return True if the uri is a base64 string or false otherwise.
  28795. */
  28796. static IsBase64(uri: string): boolean;
  28797. /**
  28798. * Decode the given base64 uri.
  28799. * @param uri The uri to decode
  28800. * @return The decoded base64 data.
  28801. */
  28802. static DecodeBase64(uri: string): ArrayBuffer;
  28803. private static _NoneLogLevel;
  28804. private static _MessageLogLevel;
  28805. private static _WarningLogLevel;
  28806. private static _ErrorLogLevel;
  28807. private static _LogCache;
  28808. static errorsCount: number;
  28809. static OnNewCacheEntry: (entry: string) => void;
  28810. static readonly NoneLogLevel: number;
  28811. static readonly MessageLogLevel: number;
  28812. static readonly WarningLogLevel: number;
  28813. static readonly ErrorLogLevel: number;
  28814. static readonly AllLogLevel: number;
  28815. private static _AddLogEntry(entry);
  28816. private static _FormatMessage(message);
  28817. private static _LogDisabled(message);
  28818. private static _LogEnabled(message);
  28819. private static _WarnDisabled(message);
  28820. private static _WarnEnabled(message);
  28821. private static _ErrorDisabled(message);
  28822. private static _ErrorEnabled(message);
  28823. static Log: (message: string) => void;
  28824. static Warn: (message: string) => void;
  28825. static Error: (message: string) => void;
  28826. static readonly LogCache: string;
  28827. static ClearLogCache(): void;
  28828. static LogLevels: number;
  28829. static IsWindowObjectExist(): boolean;
  28830. private static _PerformanceNoneLogLevel;
  28831. private static _PerformanceUserMarkLogLevel;
  28832. private static _PerformanceConsoleLogLevel;
  28833. private static _performance;
  28834. static readonly PerformanceNoneLogLevel: number;
  28835. static readonly PerformanceUserMarkLogLevel: number;
  28836. static readonly PerformanceConsoleLogLevel: number;
  28837. static PerformanceLogLevel: number;
  28838. private static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28839. private static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28840. private static _StartUserMark(counterName: string, condition?: boolean): void;
  28841. private static _EndUserMark(counterName: string, condition?: boolean): void;
  28842. private static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28843. private static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28844. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28845. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28846. static readonly Now: number;
  28847. /**
  28848. * This method will return the name of the class used to create the instance of the given object.
  28849. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28850. * @param object the object to get the class name from
  28851. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28852. */
  28853. static GetClassName(object: any, isType?: boolean): string;
  28854. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28855. /**
  28856. * This method will return the name of the full name of the class, including its owning module (if any).
  28857. * 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).
  28858. * @param object the object to get the class name from
  28859. * @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.
  28860. */
  28861. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28862. /**
  28863. * 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.
  28864. * @param array
  28865. */
  28866. static arrayOrStringFeeder(array: any): (i: number) => number;
  28867. /**
  28868. * Compute the hashCode of a stream of number
  28869. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28870. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28871. * @return the hash code computed
  28872. */
  28873. static hashCodeFromStream(feeder: (index: number) => number): number;
  28874. /**
  28875. * Returns a promise that resolves after the given amount of time.
  28876. * @param delay Number of milliseconds to delay
  28877. * @returns Promise that resolves after the given amount of time
  28878. */
  28879. static DelayAsync(delay: number): Promise<void>;
  28880. }
  28881. /**
  28882. * This class is used to track a performance counter which is number based.
  28883. * The user has access to many properties which give statistics of different nature
  28884. *
  28885. * The implementer can track two kinds of Performance Counter: time and count
  28886. * 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.
  28887. * 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.
  28888. */
  28889. class PerfCounter {
  28890. static Enabled: boolean;
  28891. /**
  28892. * Returns the smallest value ever
  28893. */
  28894. readonly min: number;
  28895. /**
  28896. * Returns the biggest value ever
  28897. */
  28898. readonly max: number;
  28899. /**
  28900. * Returns the average value since the performance counter is running
  28901. */
  28902. readonly average: number;
  28903. /**
  28904. * Returns the average value of the last second the counter was monitored
  28905. */
  28906. readonly lastSecAverage: number;
  28907. /**
  28908. * Returns the current value
  28909. */
  28910. readonly current: number;
  28911. readonly total: number;
  28912. readonly count: number;
  28913. constructor();
  28914. /**
  28915. * Call this method to start monitoring a new frame.
  28916. * 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.
  28917. */
  28918. fetchNewFrame(): void;
  28919. /**
  28920. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28921. * @param newCount the count value to add to the monitored count
  28922. * @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.
  28923. */
  28924. addCount(newCount: number, fetchResult: boolean): void;
  28925. /**
  28926. * Start monitoring this performance counter
  28927. */
  28928. beginMonitoring(): void;
  28929. /**
  28930. * Compute the time lapsed since the previous beginMonitoring() call.
  28931. * @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
  28932. */
  28933. endMonitoring(newFrame?: boolean): void;
  28934. private _fetchResult();
  28935. private _startMonitoringTime;
  28936. private _min;
  28937. private _max;
  28938. private _average;
  28939. private _current;
  28940. private _totalValueCount;
  28941. private _totalAccumulated;
  28942. private _lastSecAverage;
  28943. private _lastSecAccumulated;
  28944. private _lastSecTime;
  28945. private _lastSecValueCount;
  28946. }
  28947. /**
  28948. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28949. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28950. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28951. * @param name The name of the class, case should be preserved
  28952. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28953. */
  28954. function className(name: string, module?: string): (target: Object) => void;
  28955. /**
  28956. * An implementation of a loop for asynchronous functions.
  28957. */
  28958. class AsyncLoop {
  28959. iterations: number;
  28960. private _fn;
  28961. private _successCallback;
  28962. index: number;
  28963. private _done;
  28964. /**
  28965. * Constroctor.
  28966. * @param iterations the number of iterations.
  28967. * @param _fn the function to run each iteration
  28968. * @param _successCallback the callback that will be called upon succesful execution
  28969. * @param offset starting offset.
  28970. */
  28971. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28972. /**
  28973. * Execute the next iteration. Must be called after the last iteration was finished.
  28974. */
  28975. executeNext(): void;
  28976. /**
  28977. * Break the loop and run the success callback.
  28978. */
  28979. breakLoop(): void;
  28980. /**
  28981. * Helper function
  28982. */
  28983. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28984. /**
  28985. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28986. * @param iterations total number of iterations
  28987. * @param syncedIterations number of synchronous iterations in each async iteration.
  28988. * @param fn the function to call each iteration.
  28989. * @param callback a success call back that will be called when iterating stops.
  28990. * @param breakFunction a break condition (optional)
  28991. * @param timeout timeout settings for the setTimeout function. default - 0.
  28992. * @constructor
  28993. */
  28994. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28995. }
  28996. }
  28997. declare module BABYLON {
  28998. /**
  28999. * Defines the potential axis of a Joystick
  29000. */
  29001. enum JoystickAxis {
  29002. /** X axis */
  29003. X = 0,
  29004. /** Y axis */
  29005. Y = 1,
  29006. /** Z axis */
  29007. Z = 2,
  29008. }
  29009. /**
  29010. * Class used to define virtual joystick (used in touch mode)
  29011. */
  29012. class VirtualJoystick {
  29013. /**
  29014. * Gets or sets a boolean indicating that left and right values must be inverted
  29015. */
  29016. reverseLeftRight: boolean;
  29017. /**
  29018. * Gets or sets a boolean indicating that up and down values must be inverted
  29019. */
  29020. reverseUpDown: boolean;
  29021. /**
  29022. * Gets the offset value for the position (ie. the change of the position value)
  29023. */
  29024. deltaPosition: Vector3;
  29025. /**
  29026. * Gets a boolean indicating if the virtual joystick was pressed
  29027. */
  29028. pressed: boolean;
  29029. private static _globalJoystickIndex;
  29030. private static vjCanvas;
  29031. private static vjCanvasContext;
  29032. private static vjCanvasWidth;
  29033. private static vjCanvasHeight;
  29034. private static halfWidth;
  29035. private _action;
  29036. private _axisTargetedByLeftAndRight;
  29037. private _axisTargetedByUpAndDown;
  29038. private _joystickSensibility;
  29039. private _inversedSensibility;
  29040. private _joystickPointerID;
  29041. private _joystickColor;
  29042. private _joystickPointerPos;
  29043. private _joystickPreviousPointerPos;
  29044. private _joystickPointerStartPos;
  29045. private _deltaJoystickVector;
  29046. private _leftJoystick;
  29047. private _touches;
  29048. private _onPointerDownHandlerRef;
  29049. private _onPointerMoveHandlerRef;
  29050. private _onPointerUpHandlerRef;
  29051. private _onResize;
  29052. /**
  29053. * Creates a new virtual joystick
  29054. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29055. */
  29056. constructor(leftJoystick?: boolean);
  29057. /**
  29058. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29059. * @param newJoystickSensibility defines the new sensibility
  29060. */
  29061. setJoystickSensibility(newJoystickSensibility: number): void;
  29062. private _onPointerDown(e);
  29063. private _onPointerMove(e);
  29064. private _onPointerUp(e);
  29065. /**
  29066. * Change the color of the virtual joystick
  29067. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29068. */
  29069. setJoystickColor(newColor: string): void;
  29070. /**
  29071. * Defines a callback to call when the joystick is touched
  29072. * @param action defines the callback
  29073. */
  29074. setActionOnTouch(action: () => any): void;
  29075. /**
  29076. * Defines which axis you'd like to control for left & right
  29077. * @param axis defines the axis to use
  29078. */
  29079. setAxisForLeftRight(axis: JoystickAxis): void;
  29080. /**
  29081. * Defines which axis you'd like to control for up & down
  29082. * @param axis defines the axis to use
  29083. */
  29084. setAxisForUpDown(axis: JoystickAxis): void;
  29085. private _drawVirtualJoystick();
  29086. /**
  29087. * Release internal HTML canvas
  29088. */
  29089. releaseCanvas(): void;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * Helper class to push actions to a pool of workers.
  29095. */
  29096. class WorkerPool implements IDisposable {
  29097. private _workerInfos;
  29098. private _pendingActions;
  29099. /**
  29100. * Constructor
  29101. * @param workers Array of workers to use for actions
  29102. */
  29103. constructor(workers: Array<Worker>);
  29104. /**
  29105. * Terminates all workers and clears any pending actions.
  29106. */
  29107. dispose(): void;
  29108. /**
  29109. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29110. * pended until a worker has completed its action.
  29111. * @param action The action to perform. Call onComplete when the action is complete.
  29112. */
  29113. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29114. private _execute(workerInfo, action);
  29115. }
  29116. }
  29117. declare module BABYLON {
  29118. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29119. readonly name: string;
  29120. private _zoomStopsAnimation;
  29121. private _idleRotationSpeed;
  29122. private _idleRotationWaitTime;
  29123. private _idleRotationSpinupTime;
  29124. /**
  29125. * Gets the flag that indicates if user zooming should stop animation.
  29126. */
  29127. /**
  29128. * Sets the flag that indicates if user zooming should stop animation.
  29129. */
  29130. zoomStopsAnimation: boolean;
  29131. /**
  29132. * Gets the default speed at which the camera rotates around the model.
  29133. */
  29134. /**
  29135. * Sets the default speed at which the camera rotates around the model.
  29136. */
  29137. idleRotationSpeed: number;
  29138. /**
  29139. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29140. */
  29141. /**
  29142. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29143. */
  29144. idleRotationWaitTime: number;
  29145. /**
  29146. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29147. */
  29148. /**
  29149. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29150. */
  29151. idleRotationSpinupTime: number;
  29152. /**
  29153. * Gets a value indicating if the camera is currently rotating because of this behavior
  29154. */
  29155. readonly rotationInProgress: boolean;
  29156. private _onPrePointerObservableObserver;
  29157. private _onAfterCheckInputsObserver;
  29158. private _attachedCamera;
  29159. private _isPointerDown;
  29160. private _lastFrameTime;
  29161. private _lastInteractionTime;
  29162. private _cameraRotationSpeed;
  29163. init(): void;
  29164. attach(camera: ArcRotateCamera): void;
  29165. detach(): void;
  29166. /**
  29167. * Returns true if user is scrolling.
  29168. * @return true if user is scrolling.
  29169. */
  29170. private _userIsZooming();
  29171. private _lastFrameRadius;
  29172. private _shouldAnimationStopForInteraction();
  29173. /**
  29174. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29175. */
  29176. private _applyUserInteraction();
  29177. private _userIsMoving();
  29178. }
  29179. }
  29180. declare module BABYLON {
  29181. /**
  29182. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29183. */
  29184. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29185. readonly name: string;
  29186. /**
  29187. * The easing function used by animations
  29188. */
  29189. static EasingFunction: BackEase;
  29190. /**
  29191. * The easing mode used by animations
  29192. */
  29193. static EasingMode: number;
  29194. /**
  29195. * The duration of the animation, in milliseconds
  29196. */
  29197. transitionDuration: number;
  29198. /**
  29199. * Length of the distance animated by the transition when lower radius is reached
  29200. */
  29201. lowerRadiusTransitionRange: number;
  29202. /**
  29203. * Length of the distance animated by the transition when upper radius is reached
  29204. */
  29205. upperRadiusTransitionRange: number;
  29206. private _autoTransitionRange;
  29207. /**
  29208. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29209. */
  29210. /**
  29211. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29212. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29213. */
  29214. autoTransitionRange: boolean;
  29215. private _attachedCamera;
  29216. private _onAfterCheckInputsObserver;
  29217. private _onMeshTargetChangedObserver;
  29218. init(): void;
  29219. attach(camera: ArcRotateCamera): void;
  29220. detach(): void;
  29221. private _radiusIsAnimating;
  29222. private _radiusBounceTransition;
  29223. private _animatables;
  29224. private _cachedWheelPrecision;
  29225. /**
  29226. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29227. * @param radiusLimit The limit to check against.
  29228. * @return Bool to indicate if at limit.
  29229. */
  29230. private _isRadiusAtLimit(radiusLimit);
  29231. /**
  29232. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29233. * @param radiusDelta The delta by which to animate to. Can be negative.
  29234. */
  29235. private _applyBoundRadiusAnimation(radiusDelta);
  29236. /**
  29237. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29238. */
  29239. protected _clearAnimationLocks(): void;
  29240. /**
  29241. * Stops and removes all animations that have been applied to the camera
  29242. */
  29243. stopAllAnimations(): void;
  29244. }
  29245. }
  29246. declare module BABYLON {
  29247. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29248. readonly name: string;
  29249. private _mode;
  29250. private _radiusScale;
  29251. private _positionScale;
  29252. private _defaultElevation;
  29253. private _elevationReturnTime;
  29254. private _elevationReturnWaitTime;
  29255. private _zoomStopsAnimation;
  29256. private _framingTime;
  29257. /**
  29258. * The easing function used by animations
  29259. */
  29260. static EasingFunction: ExponentialEase;
  29261. /**
  29262. * The easing mode used by animations
  29263. */
  29264. static EasingMode: number;
  29265. /**
  29266. * Gets current mode used by the behavior.
  29267. */
  29268. /**
  29269. * Sets the current mode used by the behavior
  29270. */
  29271. mode: number;
  29272. /**
  29273. * Gets the scale applied to the radius
  29274. */
  29275. /**
  29276. * Sets the scale applied to the radius (1 by default)
  29277. */
  29278. radiusScale: number;
  29279. /**
  29280. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29281. */
  29282. /**
  29283. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29284. */
  29285. positionScale: number;
  29286. /**
  29287. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29288. * behaviour is triggered, in radians.
  29289. */
  29290. /**
  29291. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29292. * behaviour is triggered, in radians.
  29293. */
  29294. defaultElevation: number;
  29295. /**
  29296. * Gets the time (in milliseconds) taken to return to the default beta position.
  29297. * Negative value indicates camera should not return to default.
  29298. */
  29299. /**
  29300. * Sets the time (in milliseconds) taken to return to the default beta position.
  29301. * Negative value indicates camera should not return to default.
  29302. */
  29303. elevationReturnTime: number;
  29304. /**
  29305. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29306. */
  29307. /**
  29308. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29309. */
  29310. elevationReturnWaitTime: number;
  29311. /**
  29312. * Gets the flag that indicates if user zooming should stop animation.
  29313. */
  29314. /**
  29315. * Sets the flag that indicates if user zooming should stop animation.
  29316. */
  29317. zoomStopsAnimation: boolean;
  29318. /**
  29319. * Gets the transition time when framing the mesh, in milliseconds
  29320. */
  29321. /**
  29322. * Sets the transition time when framing the mesh, in milliseconds
  29323. */
  29324. framingTime: number;
  29325. private _onPrePointerObservableObserver;
  29326. private _onAfterCheckInputsObserver;
  29327. private _onMeshTargetChangedObserver;
  29328. private _attachedCamera;
  29329. private _isPointerDown;
  29330. private _lastInteractionTime;
  29331. init(): void;
  29332. attach(camera: ArcRotateCamera): void;
  29333. detach(): void;
  29334. private _animatables;
  29335. private _betaIsAnimating;
  29336. private _betaTransition;
  29337. private _radiusTransition;
  29338. private _vectorTransition;
  29339. /**
  29340. * Targets the given mesh and updates zoom level accordingly.
  29341. * @param mesh The mesh to target.
  29342. * @param radius Optional. If a cached radius position already exists, overrides default.
  29343. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29346. */
  29347. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29348. /**
  29349. * Targets the given mesh with its children and updates zoom level accordingly.
  29350. * @param mesh The mesh to target.
  29351. * @param radius Optional. If a cached radius position already exists, overrides default.
  29352. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29355. */
  29356. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29357. /**
  29358. * Targets the given meshes with their children and updates zoom level accordingly.
  29359. * @param meshes The mesh to target.
  29360. * @param radius Optional. If a cached radius position already exists, overrides default.
  29361. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29362. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29363. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29364. */
  29365. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29366. /**
  29367. * Targets the given mesh and updates zoom level accordingly.
  29368. * @param mesh The mesh to target.
  29369. * @param radius Optional. If a cached radius position already exists, overrides default.
  29370. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29371. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29372. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29373. */
  29374. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29375. /**
  29376. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29377. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29378. * frustum width.
  29379. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29380. * to fully enclose the mesh in the viewing frustum.
  29381. */
  29382. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29383. /**
  29384. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29385. * is automatically returned to its default position (expected to be above ground plane).
  29386. */
  29387. private _maintainCameraAboveGround();
  29388. /**
  29389. * Returns the frustum slope based on the canvas ratio and camera FOV
  29390. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29391. */
  29392. private _getFrustumSlope();
  29393. /**
  29394. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29395. */
  29396. private _clearAnimationLocks();
  29397. /**
  29398. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29399. */
  29400. private _applyUserInteraction();
  29401. /**
  29402. * Stops and removes all animations that have been applied to the camera
  29403. */
  29404. stopAllAnimations(): void;
  29405. /**
  29406. * Gets a value indicating if the user is moving the camera
  29407. */
  29408. readonly isUserIsMoving: boolean;
  29409. /**
  29410. * The camera can move all the way towards the mesh.
  29411. */
  29412. static IgnoreBoundsSizeMode: number;
  29413. /**
  29414. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29415. */
  29416. static FitFrustumSidesMode: number;
  29417. }
  29418. }
  29419. declare module BABYLON {
  29420. /**
  29421. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  29422. */
  29423. class PointerDragBehavior implements Behavior<Mesh> {
  29424. private options;
  29425. private _attachedNode;
  29426. private _dragPlane;
  29427. private _scene;
  29428. private _pointerObserver;
  29429. private static _planeScene;
  29430. private _draggingID;
  29431. /**
  29432. * Fires each time the attached mesh is dragged with the pointer
  29433. */
  29434. onDragObservable: Observable<{
  29435. delta: Vector3;
  29436. dragPlanePoint: Vector3;
  29437. }>;
  29438. /**
  29439. * Fires each time a drag begins (eg. mouse down on mesh)
  29440. */
  29441. onDragStartObservable: Observable<{
  29442. dragPlanePoint: Vector3;
  29443. }>;
  29444. /**
  29445. * Fires each time a drag ends (eg. mouse release after drag)
  29446. */
  29447. onDragEndObservable: Observable<{
  29448. dragPlanePoint: Vector3;
  29449. }>;
  29450. /**
  29451. * If the attached mesh should be moved when dragged
  29452. */
  29453. moveAttached: boolean;
  29454. /**
  29455. * Mesh with the position where the drag plane should be placed
  29456. */
  29457. /**
  29458. * If the drag behavior will react to drag events
  29459. */
  29460. enabled: boolean;
  29461. /**
  29462. * Creates a pointer drag behavior that can be attached to a mesh
  29463. * @param options The drag axis or normal of the plane that will be dragged across. pointerObservableScene can be used to listen to drag events from another scene(eg. if the attached mesh is in an overlay scene).
  29464. */
  29465. constructor(options: {
  29466. dragAxis?: Vector3;
  29467. dragPlaneNormal?: Vector3;
  29468. pointerObservableScene?: Scene;
  29469. });
  29470. /**
  29471. * The name of the behavior
  29472. */
  29473. readonly name: string;
  29474. /**
  29475. * Initializes the behavior
  29476. */
  29477. init(): void;
  29478. /**
  29479. * Attaches the drag behavior the passed in mesh
  29480. * @param ownerNode The mesh that will be dragged around once attached
  29481. */
  29482. attach(ownerNode: Mesh): void;
  29483. private _pickWithRayOnDragPlane(ray);
  29484. private _updateDragPlanePosition(ray);
  29485. /**
  29486. * Detaches the behavior from the mesh
  29487. */
  29488. detach(): void;
  29489. }
  29490. }
  29491. declare module BABYLON {
  29492. interface IOctreeContainer<T> {
  29493. blocks: Array<OctreeBlock<T>>;
  29494. }
  29495. class Octree<T> {
  29496. maxDepth: number;
  29497. blocks: Array<OctreeBlock<T>>;
  29498. dynamicContent: T[];
  29499. private _maxBlockCapacity;
  29500. private _selectionContent;
  29501. private _creationFunc;
  29502. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29503. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29504. addMesh(entry: T): void;
  29505. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29506. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29507. intersectsRay(ray: Ray): SmartArray<T>;
  29508. 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;
  29509. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29510. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29511. }
  29512. }
  29513. declare module BABYLON {
  29514. class OctreeBlock<T> {
  29515. entries: T[];
  29516. blocks: Array<OctreeBlock<T>>;
  29517. private _depth;
  29518. private _maxDepth;
  29519. private _capacity;
  29520. private _minPoint;
  29521. private _maxPoint;
  29522. private _boundingVectors;
  29523. private _creationFunc;
  29524. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29525. readonly capacity: number;
  29526. readonly minPoint: Vector3;
  29527. readonly maxPoint: Vector3;
  29528. addEntry(entry: T): void;
  29529. addEntries(entries: T[]): void;
  29530. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29531. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29532. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29533. createInnerBlocks(): void;
  29534. }
  29535. }
  29536. declare module BABYLON {
  29537. class VRCameraMetrics {
  29538. hResolution: number;
  29539. vResolution: number;
  29540. hScreenSize: number;
  29541. vScreenSize: number;
  29542. vScreenCenter: number;
  29543. eyeToScreenDistance: number;
  29544. lensSeparationDistance: number;
  29545. interpupillaryDistance: number;
  29546. distortionK: number[];
  29547. chromaAbCorrection: number[];
  29548. postProcessScaleFactor: number;
  29549. lensCenterOffset: number;
  29550. compensateDistortion: boolean;
  29551. readonly aspectRatio: number;
  29552. readonly aspectRatioFov: number;
  29553. readonly leftHMatrix: Matrix;
  29554. readonly rightHMatrix: Matrix;
  29555. readonly leftPreViewMatrix: Matrix;
  29556. readonly rightPreViewMatrix: Matrix;
  29557. static GetDefault(): VRCameraMetrics;
  29558. }
  29559. }
  29560. declare module BABYLON {
  29561. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29562. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29563. getClassName(): string;
  29564. }
  29565. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29567. getClassName(): string;
  29568. }
  29569. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29570. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29571. getClassName(): string;
  29572. }
  29573. }
  29574. declare module BABYLON {
  29575. /**
  29576. * Options to modify the vr teleportation behavior.
  29577. */
  29578. interface VRTeleportationOptions {
  29579. /**
  29580. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29581. */
  29582. floorMeshName?: string;
  29583. /**
  29584. * A list of meshes to be used as the teleportation floor. (default: empty)
  29585. */
  29586. floorMeshes?: Mesh[];
  29587. }
  29588. /**
  29589. * Options to modify the vr experience helper's behavior.
  29590. */
  29591. interface VRExperienceHelperOptions extends WebVROptions {
  29592. /**
  29593. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  29594. */
  29595. createDeviceOrientationCamera?: boolean;
  29596. /**
  29597. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  29598. */
  29599. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29600. /**
  29601. * Uses the main button on the controller to toggle the laser casted. (default: true)
  29602. */
  29603. laserToggle?: boolean;
  29604. /**
  29605. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  29606. */
  29607. floorMeshes?: Mesh[];
  29608. }
  29609. /**
  29610. * Helps to quickly add VR support to an existing scene.
  29611. * See http://doc.babylonjs.com/how_to/webvr_helper
  29612. */
  29613. class VRExperienceHelper {
  29614. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29615. private _scene;
  29616. private _position;
  29617. private _btnVR;
  29618. private _btnVRDisplayed;
  29619. private _webVRsupported;
  29620. private _webVRready;
  29621. private _webVRrequesting;
  29622. private _webVRpresenting;
  29623. private _fullscreenVRpresenting;
  29624. private _canvas;
  29625. private _webVRCamera;
  29626. private _vrDeviceOrientationCamera;
  29627. private _deviceOrientationCamera;
  29628. private _existingCamera;
  29629. private _onKeyDown;
  29630. private _onVrDisplayPresentChange;
  29631. private _onVRDisplayChanged;
  29632. private _onVRRequestPresentStart;
  29633. private _onVRRequestPresentComplete;
  29634. /**
  29635. * Observable raised when entering VR.
  29636. */
  29637. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29638. /**
  29639. * Observable raised when exiting VR.
  29640. */
  29641. onExitingVRObservable: Observable<VRExperienceHelper>;
  29642. /**
  29643. * Observable raised when controller mesh is loaded.
  29644. */
  29645. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29646. /** Return this.onEnteringVRObservable
  29647. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29648. */
  29649. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29650. /** Return this.onExitingVRObservable
  29651. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29652. */
  29653. readonly onExitingVR: Observable<VRExperienceHelper>;
  29654. /** Return this.onControllerMeshLoadedObservable
  29655. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29656. */
  29657. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29658. private _rayLength;
  29659. private _useCustomVRButton;
  29660. private _teleportationRequested;
  29661. private _teleportActive;
  29662. private _floorMeshName;
  29663. private _floorMeshesCollection;
  29664. private _rotationAllowed;
  29665. private _teleportBackwardsVector;
  29666. private _teleportationTarget;
  29667. private _isDefaultTeleportationTarget;
  29668. private _postProcessMove;
  29669. private _teleportationFillColor;
  29670. private _teleportationBorderColor;
  29671. private _rotationAngle;
  29672. private _haloCenter;
  29673. private _cameraGazer;
  29674. private _padSensibilityUp;
  29675. private _padSensibilityDown;
  29676. private leftController;
  29677. private rightController;
  29678. /**
  29679. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29680. */
  29681. onNewMeshSelected: Observable<AbstractMesh>;
  29682. /**
  29683. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29684. */
  29685. onNewMeshPicked: Observable<PickingInfo>;
  29686. private _circleEase;
  29687. /**
  29688. * Observable raised before camera teleportation
  29689. */
  29690. onBeforeCameraTeleport: Observable<Vector3>;
  29691. /**
  29692. * Observable raised after camera teleportation
  29693. */
  29694. onAfterCameraTeleport: Observable<Vector3>;
  29695. /**
  29696. * Observable raised when current selected mesh gets unselected
  29697. */
  29698. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29699. private _raySelectionPredicate;
  29700. /**
  29701. * To be optionaly changed by user to define custom ray selection
  29702. */
  29703. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29704. /**
  29705. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29706. */
  29707. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29708. /**
  29709. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29710. */
  29711. teleportationEnabled: boolean;
  29712. private _defaultHeight;
  29713. private _teleportationInitialized;
  29714. private _interactionsEnabled;
  29715. private _interactionsRequested;
  29716. private _displayGaze;
  29717. private _displayLaserPointer;
  29718. /**
  29719. * The mesh used to display where the user is going to teleport.
  29720. */
  29721. /**
  29722. * Sets the mesh to be used to display where the user is going to teleport.
  29723. */
  29724. teleportationTarget: Mesh;
  29725. /**
  29726. * The mesh used to display where the user is selecting,
  29727. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29728. * See http://doc.babylonjs.com/resources/baking_transformations
  29729. */
  29730. gazeTrackerMesh: Mesh;
  29731. /**
  29732. * If the ray of the gaze should be displayed.
  29733. */
  29734. /**
  29735. * Sets if the ray of the gaze should be displayed.
  29736. */
  29737. displayGaze: boolean;
  29738. /**
  29739. * If the ray of the LaserPointer should be displayed.
  29740. */
  29741. /**
  29742. * Sets if the ray of the LaserPointer should be displayed.
  29743. */
  29744. displayLaserPointer: boolean;
  29745. /**
  29746. * The deviceOrientationCamera used as the camera when not in VR.
  29747. */
  29748. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29749. /**
  29750. * Based on the current WebVR support, returns the current VR camera used.
  29751. */
  29752. readonly currentVRCamera: Nullable<Camera>;
  29753. /**
  29754. * The webVRCamera which is used when in VR.
  29755. */
  29756. readonly webVRCamera: WebVRFreeCamera;
  29757. /**
  29758. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29759. */
  29760. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29761. private readonly _teleportationRequestInitiated;
  29762. /**
  29763. * Instantiates a VRExperienceHelper.
  29764. * Helps to quickly add VR support to an existing scene.
  29765. * @param scene The scene the VRExperienceHelper belongs to.
  29766. * @param webVROptions Options to modify the vr experience helper's behavior.
  29767. */
  29768. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29769. private _onDefaultMeshLoaded(webVRController);
  29770. private _onResize;
  29771. private _onFullscreenChange;
  29772. /**
  29773. * Gets a value indicating if we are currently in VR mode.
  29774. */
  29775. readonly isInVRMode: boolean;
  29776. private onVrDisplayPresentChange();
  29777. private onVRDisplayChanged(eventArgs);
  29778. private moveButtonToBottomRight();
  29779. private displayVRButton();
  29780. private updateButtonVisibility();
  29781. /**
  29782. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29783. * Otherwise, will use the fullscreen API.
  29784. */
  29785. enterVR(): void;
  29786. /**
  29787. * Attempt to exit VR, or fullscreen.
  29788. */
  29789. exitVR(): void;
  29790. /**
  29791. * The position of the vr experience helper.
  29792. */
  29793. /**
  29794. * Sets the position of the vr experience helper.
  29795. */
  29796. position: Vector3;
  29797. /**
  29798. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29799. */
  29800. enableInteractions(): void;
  29801. private beforeRender;
  29802. private _isTeleportationFloor(mesh);
  29803. /**
  29804. * Adds a floor mesh to be used for teleportation.
  29805. * @param floorMesh the mesh to be used for teleportation.
  29806. */
  29807. addFloorMesh(floorMesh: Mesh): void;
  29808. /**
  29809. * Removes a floor mesh from being used for teleportation.
  29810. * @param floorMesh the mesh to be removed.
  29811. */
  29812. removeFloorMesh(floorMesh: Mesh): void;
  29813. /**
  29814. * Enables interactions and teleportation using the VR controllers and gaze.
  29815. * @param vrTeleportationOptions options to modify teleportation behavior.
  29816. */
  29817. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29818. private _onNewGamepadConnected;
  29819. private _tryEnableInteractionOnController;
  29820. private _onNewGamepadDisconnected;
  29821. private _enableInteractionOnController(controller);
  29822. private _checkTeleportWithRay(stateObject, gazer);
  29823. private _checkRotate(stateObject, gazer);
  29824. private _checkTeleportBackwards(stateObject, gazer);
  29825. private _enableTeleportationOnController(controller);
  29826. private _createTeleportationCircles();
  29827. private _displayTeleportationTarget();
  29828. private _hideTeleportationTarget();
  29829. private _rotateCamera(right);
  29830. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29831. private _workingVector;
  29832. private _workingQuaternion;
  29833. private _workingMatrix;
  29834. private _teleportCamera(location);
  29835. private _convertNormalToDirectionOfRay(normal, ray);
  29836. private _castRayAndSelectObject(gazer);
  29837. private _notifySelectedMeshUnselected(mesh);
  29838. /**
  29839. * Sets the color of the laser ray from the vr controllers.
  29840. * @param color new color for the ray.
  29841. */
  29842. changeLaserColor(color: Color3): void;
  29843. /**
  29844. * Sets the color of the ray from the vr headsets gaze.
  29845. * @param color new color for the ray.
  29846. */
  29847. changeGazeColor(color: Color3): void;
  29848. /**
  29849. * Exits VR and disposes of the vr experience helper
  29850. */
  29851. dispose(): void;
  29852. /**
  29853. * Gets the name of the VRExperienceHelper class
  29854. * @returns "VRExperienceHelper"
  29855. */
  29856. getClassName(): string;
  29857. }
  29858. }
  29859. declare module BABYLON {
  29860. /**
  29861. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29862. * IMPORTANT!! The data is right-hand data.
  29863. * @export
  29864. * @interface DevicePose
  29865. */
  29866. interface DevicePose {
  29867. /**
  29868. * The position of the device, values in array are [x,y,z].
  29869. */
  29870. readonly position: Nullable<Float32Array>;
  29871. /**
  29872. * The linearVelocity of the device, values in array are [x,y,z].
  29873. */
  29874. readonly linearVelocity: Nullable<Float32Array>;
  29875. /**
  29876. * The linearAcceleration of the device, values in array are [x,y,z].
  29877. */
  29878. readonly linearAcceleration: Nullable<Float32Array>;
  29879. /**
  29880. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29881. */
  29882. readonly orientation: Nullable<Float32Array>;
  29883. /**
  29884. * The angularVelocity of the device, values in array are [x,y,z].
  29885. */
  29886. readonly angularVelocity: Nullable<Float32Array>;
  29887. /**
  29888. * The angularAcceleration of the device, values in array are [x,y,z].
  29889. */
  29890. readonly angularAcceleration: Nullable<Float32Array>;
  29891. }
  29892. /**
  29893. * Interface representing a pose controlled object in Babylon.
  29894. * A pose controlled object has both regular pose values as well as pose values
  29895. * from an external device such as a VR head mounted display
  29896. */
  29897. interface PoseControlled {
  29898. /**
  29899. * The position of the object in babylon space.
  29900. */
  29901. position: Vector3;
  29902. /**
  29903. * The rotation quaternion of the object in babylon space.
  29904. */
  29905. rotationQuaternion: Quaternion;
  29906. /**
  29907. * The position of the device in babylon space.
  29908. */
  29909. devicePosition?: Vector3;
  29910. /**
  29911. * The rotation quaternion of the device in babylon space.
  29912. */
  29913. deviceRotationQuaternion: Quaternion;
  29914. /**
  29915. * The raw pose coming from the device.
  29916. */
  29917. rawPose: Nullable<DevicePose>;
  29918. /**
  29919. * The scale of the device to be used when translating from device space to babylon space.
  29920. */
  29921. deviceScaleFactor: number;
  29922. /**
  29923. * Updates the poseControlled values based on the input device pose.
  29924. * @param poseData the pose data to update the object with
  29925. */
  29926. updateFromDevice(poseData: DevicePose): void;
  29927. }
  29928. /**
  29929. * Set of options to customize the webVRCamera
  29930. */
  29931. interface WebVROptions {
  29932. /**
  29933. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29934. */
  29935. trackPosition?: boolean;
  29936. /**
  29937. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29938. */
  29939. positionScale?: number;
  29940. /**
  29941. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29942. */
  29943. displayName?: string;
  29944. /**
  29945. * Should the native controller meshes be initialized. (default: true)
  29946. */
  29947. controllerMeshes?: boolean;
  29948. /**
  29949. * Creating a default HemiLight only on controllers. (default: true)
  29950. */
  29951. defaultLightingOnControllers?: boolean;
  29952. /**
  29953. * If you don't want to use the default VR button of the helper. (default: false)
  29954. */
  29955. useCustomVRButton?: boolean;
  29956. /**
  29957. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29958. */
  29959. customVRButton?: HTMLButtonElement;
  29960. /**
  29961. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29962. */
  29963. rayLength?: number;
  29964. /**
  29965. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29966. */
  29967. defaultHeight?: number;
  29968. }
  29969. /**
  29970. * This represents a WebVR camera.
  29971. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29972. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29973. */
  29974. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29975. private webVROptions;
  29976. /**
  29977. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29978. */
  29979. /**
  29980. * The rawPose of the vrDevice.
  29981. */
  29982. rawPose: Nullable<DevicePose>;
  29983. private _onVREnabled;
  29984. private _specsVersion;
  29985. private _attached;
  29986. private _frameData;
  29987. protected _descendants: Array<Node>;
  29988. private _deviceRoomPosition;
  29989. private _deviceRoomRotationQuaternion;
  29990. private _standingMatrix;
  29991. /**
  29992. * Represents device position in babylon space.
  29993. */
  29994. devicePosition: Vector3;
  29995. /**
  29996. * Represents device rotation in babylon space.
  29997. */
  29998. deviceRotationQuaternion: Quaternion;
  29999. /**
  30000. * The scale of the device to be used when translating from device space to babylon space.
  30001. */
  30002. deviceScaleFactor: number;
  30003. private _deviceToWorld;
  30004. private _worldToDevice;
  30005. /**
  30006. * References to the webVR controllers for the vrDevice.
  30007. */
  30008. controllers: Array<WebVRController>;
  30009. /**
  30010. * Emits an event when a controller is attached.
  30011. */
  30012. onControllersAttachedObservable: Observable<WebVRController[]>;
  30013. /**
  30014. * Emits an event when a controller's mesh has been loaded;
  30015. */
  30016. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30017. /**
  30018. * If the rig cameras be used as parent instead of this camera.
  30019. */
  30020. rigParenting: boolean;
  30021. private _lightOnControllers;
  30022. private _defaultHeight?;
  30023. /**
  30024. * Instantiates a WebVRFreeCamera.
  30025. * @param name The name of the WebVRFreeCamera
  30026. * @param position The starting anchor position for the camera
  30027. * @param scene The scene the camera belongs to
  30028. * @param webVROptions a set of customizable options for the webVRCamera
  30029. */
  30030. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30031. /**
  30032. * Gets the device distance from the ground in meters.
  30033. * @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.
  30034. */
  30035. deviceDistanceToRoomGround(): number;
  30036. /**
  30037. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30038. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30039. */
  30040. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30041. /**
  30042. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30043. * @returns A promise with a boolean set to if the standing matrix is supported.
  30044. */
  30045. useStandingMatrixAsync(): Promise<boolean>;
  30046. /**
  30047. * Disposes the camera
  30048. */
  30049. dispose(): void;
  30050. /**
  30051. * Gets a vrController by name.
  30052. * @param name The name of the controller to retreive
  30053. * @returns the controller matching the name specified or null if not found
  30054. */
  30055. getControllerByName(name: string): Nullable<WebVRController>;
  30056. private _leftController;
  30057. /**
  30058. * The controller corrisponding to the users left hand.
  30059. */
  30060. readonly leftController: Nullable<WebVRController>;
  30061. private _rightController;
  30062. /**
  30063. * The controller corrisponding to the users right hand.
  30064. */
  30065. readonly rightController: Nullable<WebVRController>;
  30066. /**
  30067. * Casts a ray forward from the vrCamera's gaze.
  30068. * @param length Length of the ray (default: 100)
  30069. * @returns the ray corrisponding to the gaze
  30070. */
  30071. getForwardRay(length?: number): Ray;
  30072. /**
  30073. * Updates the camera based on device's frame data
  30074. */
  30075. /**
  30076. * Updates the poseControlled values based on the input device pose.
  30077. * @param poseData Pose coming from the device
  30078. */
  30079. updateFromDevice(poseData: DevicePose): void;
  30080. /**
  30081. * WebVR's attach control will start broadcasting frames to the device.
  30082. * Note that in certain browsers (chrome for example) this function must be called
  30083. * within a user-interaction callback. Example:
  30084. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30085. *
  30086. * @param element html element to attach the vrDevice to
  30087. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30088. */
  30089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30090. /**
  30091. * Detaches the camera from the html element and disables VR
  30092. *
  30093. * @param element html element to detach from
  30094. */
  30095. detachControl(element: HTMLElement): void;
  30096. /**
  30097. * @returns the name of this class
  30098. */
  30099. getClassName(): string;
  30100. /**
  30101. * Calls resetPose on the vrDisplay
  30102. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30103. */
  30104. resetToCurrentRotation(): void;
  30105. /**
  30106. * Updates the rig cameras (left and right eye)
  30107. */
  30108. private _workingVector;
  30109. private _oneVector;
  30110. private _workingMatrix;
  30111. private updateCacheCalled;
  30112. /**
  30113. * Updates the cached values of the camera
  30114. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30115. */
  30116. /**
  30117. * Updates the current device position and rotation in the babylon world
  30118. */
  30119. update(): void;
  30120. /**
  30121. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30122. * @returns an identity matrix
  30123. */
  30124. /**
  30125. * This function is called by the two RIG cameras.
  30126. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30127. */
  30128. protected _getWebVRViewMatrix(): Matrix;
  30129. protected _getWebVRProjectionMatrix(): Matrix;
  30130. private _onGamepadConnectedObserver;
  30131. private _onGamepadDisconnectedObserver;
  30132. /**
  30133. * Initializes the controllers and their meshes
  30134. */
  30135. initControllers(): void;
  30136. }
  30137. }
  30138. declare module BABYLON {
  30139. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  30140. camera: ArcRotateCamera;
  30141. gamepad: Nullable<Gamepad>;
  30142. private _onGamepadConnectedObserver;
  30143. private _onGamepadDisconnectedObserver;
  30144. gamepadRotationSensibility: number;
  30145. gamepadMoveSensibility: number;
  30146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30147. detachControl(element: Nullable<HTMLElement>): void;
  30148. checkInputs(): void;
  30149. getClassName(): string;
  30150. getSimpleName(): string;
  30151. }
  30152. }
  30153. declare module BABYLON {
  30154. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  30155. camera: ArcRotateCamera;
  30156. private _keys;
  30157. keysUp: number[];
  30158. keysDown: number[];
  30159. keysLeft: number[];
  30160. keysRight: number[];
  30161. keysReset: number[];
  30162. panningSensibility: number;
  30163. zoomingSensibility: number;
  30164. useAltToZoom: boolean;
  30165. private _ctrlPressed;
  30166. private _altPressed;
  30167. private _onCanvasBlurObserver;
  30168. private _onKeyboardObserver;
  30169. private _engine;
  30170. private _scene;
  30171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30172. detachControl(element: Nullable<HTMLElement>): void;
  30173. checkInputs(): void;
  30174. getClassName(): string;
  30175. getSimpleName(): string;
  30176. }
  30177. }
  30178. declare module BABYLON {
  30179. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  30180. camera: ArcRotateCamera;
  30181. private _wheel;
  30182. private _observer;
  30183. wheelPrecision: number;
  30184. /**
  30185. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  30186. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  30187. */
  30188. wheelDeltaPercentage: number;
  30189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30190. detachControl(element: Nullable<HTMLElement>): void;
  30191. getClassName(): string;
  30192. getSimpleName(): string;
  30193. }
  30194. }
  30195. declare module BABYLON {
  30196. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  30197. camera: ArcRotateCamera;
  30198. buttons: number[];
  30199. angularSensibilityX: number;
  30200. angularSensibilityY: number;
  30201. pinchPrecision: number;
  30202. /**
  30203. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  30204. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  30205. */
  30206. pinchDeltaPercentage: number;
  30207. panningSensibility: number;
  30208. multiTouchPanning: boolean;
  30209. multiTouchPanAndZoom: boolean;
  30210. private _isPanClick;
  30211. pinchInwards: boolean;
  30212. private _pointerInput;
  30213. private _observer;
  30214. private _onMouseMove;
  30215. private _onGestureStart;
  30216. private _onGesture;
  30217. private _MSGestureHandler;
  30218. private _onLostFocus;
  30219. private _onContextMenu;
  30220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30221. detachControl(element: Nullable<HTMLElement>): void;
  30222. getClassName(): string;
  30223. getSimpleName(): string;
  30224. }
  30225. }
  30226. declare module BABYLON {
  30227. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  30228. camera: ArcRotateCamera;
  30229. alphaCorrection: number;
  30230. betaCorrection: number;
  30231. gammaCorrection: number;
  30232. private _alpha;
  30233. private _gamma;
  30234. private _dirty;
  30235. private _deviceOrientationHandler;
  30236. constructor();
  30237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30238. checkInputs(): void;
  30239. detachControl(element: Nullable<HTMLElement>): void;
  30240. getClassName(): string;
  30241. getSimpleName(): string;
  30242. }
  30243. }
  30244. declare module BABYLON {
  30245. /**
  30246. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  30247. * Screen rotation is taken into account.
  30248. */
  30249. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  30250. private _camera;
  30251. private _screenOrientationAngle;
  30252. private _constantTranform;
  30253. private _screenQuaternion;
  30254. private _alpha;
  30255. private _beta;
  30256. private _gamma;
  30257. constructor();
  30258. camera: FreeCamera;
  30259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30260. private _orientationChanged;
  30261. private _deviceOrientation;
  30262. detachControl(element: Nullable<HTMLElement>): void;
  30263. checkInputs(): void;
  30264. getClassName(): string;
  30265. getSimpleName(): string;
  30266. }
  30267. }
  30268. declare module BABYLON {
  30269. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  30270. camera: FreeCamera;
  30271. gamepad: Nullable<Gamepad>;
  30272. private _onGamepadConnectedObserver;
  30273. private _onGamepadDisconnectedObserver;
  30274. gamepadAngularSensibility: number;
  30275. gamepadMoveSensibility: number;
  30276. private _cameraTransform;
  30277. private _deltaTransform;
  30278. private _vector3;
  30279. private _vector2;
  30280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30281. detachControl(element: Nullable<HTMLElement>): void;
  30282. checkInputs(): void;
  30283. getClassName(): string;
  30284. getSimpleName(): string;
  30285. }
  30286. }
  30287. declare module BABYLON {
  30288. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  30289. camera: FreeCamera;
  30290. private _keys;
  30291. private _onCanvasBlurObserver;
  30292. private _onKeyboardObserver;
  30293. private _engine;
  30294. private _scene;
  30295. keysUp: number[];
  30296. keysDown: number[];
  30297. keysLeft: number[];
  30298. keysRight: number[];
  30299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30300. detachControl(element: Nullable<HTMLElement>): void;
  30301. checkInputs(): void;
  30302. getClassName(): string;
  30303. getSimpleName(): string;
  30304. }
  30305. }
  30306. declare module BABYLON {
  30307. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  30308. touchEnabled: boolean;
  30309. camera: FreeCamera;
  30310. buttons: number[];
  30311. angularSensibility: number;
  30312. private _pointerInput;
  30313. private _onMouseMove;
  30314. private _observer;
  30315. private previousPosition;
  30316. constructor(touchEnabled?: boolean);
  30317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30318. detachControl(element: Nullable<HTMLElement>): void;
  30319. getClassName(): string;
  30320. getSimpleName(): string;
  30321. }
  30322. }
  30323. declare module BABYLON {
  30324. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  30325. camera: FreeCamera;
  30326. private _offsetX;
  30327. private _offsetY;
  30328. private _pointerPressed;
  30329. private _pointerInput;
  30330. private _observer;
  30331. private _onLostFocus;
  30332. touchAngularSensibility: number;
  30333. touchMoveSensibility: number;
  30334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30335. detachControl(element: Nullable<HTMLElement>): void;
  30336. checkInputs(): void;
  30337. getClassName(): string;
  30338. getSimpleName(): string;
  30339. }
  30340. }
  30341. declare module BABYLON {
  30342. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  30343. camera: FreeCamera;
  30344. private _leftjoystick;
  30345. private _rightjoystick;
  30346. getLeftJoystick(): VirtualJoystick;
  30347. getRightJoystick(): VirtualJoystick;
  30348. checkInputs(): void;
  30349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30350. detachControl(element: Nullable<HTMLElement>): void;
  30351. getClassName(): string;
  30352. getSimpleName(): string;
  30353. }
  30354. }
  30355. declare module BABYLON {
  30356. /**
  30357. * Google Daydream controller
  30358. */
  30359. class DaydreamController extends WebVRController {
  30360. /**
  30361. * Base Url for the controller model.
  30362. */
  30363. static MODEL_BASE_URL: string;
  30364. /**
  30365. * File name for the controller model.
  30366. */
  30367. static MODEL_FILENAME: string;
  30368. /**
  30369. * Gamepad Id prefix used to identify Daydream Controller.
  30370. */
  30371. static readonly GAMEPAD_ID_PREFIX: string;
  30372. /**
  30373. * Creates a new DaydreamController from a gamepad
  30374. * @param vrGamepad the gamepad that the controller should be created from
  30375. */
  30376. constructor(vrGamepad: any);
  30377. /**
  30378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30379. * @param scene scene in which to add meshes
  30380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30381. */
  30382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30383. /**
  30384. * Called once for each button that changed state since the last frame
  30385. * @param buttonIdx Which button index changed
  30386. * @param state New state of the button
  30387. * @param changes Which properties on the state changed since last frame
  30388. */
  30389. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30390. }
  30391. }
  30392. declare module BABYLON {
  30393. /**
  30394. * Gear VR Controller
  30395. */
  30396. class GearVRController extends WebVRController {
  30397. /**
  30398. * Base Url for the controller model.
  30399. */
  30400. static MODEL_BASE_URL: string;
  30401. /**
  30402. * File name for the controller model.
  30403. */
  30404. static MODEL_FILENAME: string;
  30405. /**
  30406. * Gamepad Id prefix used to identify this controller.
  30407. */
  30408. static readonly GAMEPAD_ID_PREFIX: string;
  30409. private readonly _buttonIndexToObservableNameMap;
  30410. /**
  30411. * Creates a new GearVRController from a gamepad
  30412. * @param vrGamepad the gamepad that the controller should be created from
  30413. */
  30414. constructor(vrGamepad: any);
  30415. /**
  30416. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30417. * @param scene scene in which to add meshes
  30418. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30419. */
  30420. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30421. /**
  30422. * Called once for each button that changed state since the last frame
  30423. * @param buttonIdx Which button index changed
  30424. * @param state New state of the button
  30425. * @param changes Which properties on the state changed since last frame
  30426. */
  30427. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30428. }
  30429. }
  30430. declare module BABYLON {
  30431. /**
  30432. * Generic Controller
  30433. */
  30434. class GenericController extends WebVRController {
  30435. /**
  30436. * Base Url for the controller model.
  30437. */
  30438. static readonly MODEL_BASE_URL: string;
  30439. /**
  30440. * File name for the controller model.
  30441. */
  30442. static readonly MODEL_FILENAME: string;
  30443. /**
  30444. * Creates a new GenericController from a gamepad
  30445. * @param vrGamepad the gamepad that the controller should be created from
  30446. */
  30447. constructor(vrGamepad: any);
  30448. /**
  30449. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30450. * @param scene scene in which to add meshes
  30451. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30452. */
  30453. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30454. /**
  30455. * Called once for each button that changed state since the last frame
  30456. * @param buttonIdx Which button index changed
  30457. * @param state New state of the button
  30458. * @param changes Which properties on the state changed since last frame
  30459. */
  30460. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30461. }
  30462. }
  30463. declare module BABYLON {
  30464. /**
  30465. * Oculus Touch Controller
  30466. */
  30467. class OculusTouchController extends WebVRController {
  30468. /**
  30469. * Base Url for the controller model.
  30470. */
  30471. static MODEL_BASE_URL: string;
  30472. /**
  30473. * File name for the left controller model.
  30474. */
  30475. static MODEL_LEFT_FILENAME: string;
  30476. /**
  30477. * File name for the right controller model.
  30478. */
  30479. static MODEL_RIGHT_FILENAME: string;
  30480. /**
  30481. * Fired when the secondary trigger on this controller is modified
  30482. */
  30483. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30484. /**
  30485. * Fired when the thumb rest on this controller is modified
  30486. */
  30487. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30488. /**
  30489. * Creates a new OculusTouchController from a gamepad
  30490. * @param vrGamepad the gamepad that the controller should be created from
  30491. */
  30492. constructor(vrGamepad: any);
  30493. /**
  30494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30495. * @param scene scene in which to add meshes
  30496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30497. */
  30498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30499. /**
  30500. * Fired when the A button on this controller is modified
  30501. */
  30502. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30503. /**
  30504. * Fired when the B button on this controller is modified
  30505. */
  30506. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30507. /**
  30508. * Fired when the X button on this controller is modified
  30509. */
  30510. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30511. /**
  30512. * Fired when the Y button on this controller is modified
  30513. */
  30514. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30515. /**
  30516. * Called once for each button that changed state since the last frame
  30517. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30518. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30519. * 2) secondary trigger (same)
  30520. * 3) A (right) X (left), touch, pressed = value
  30521. * 4) B / Y
  30522. * 5) thumb rest
  30523. * @param buttonIdx Which button index changed
  30524. * @param state New state of the button
  30525. * @param changes Which properties on the state changed since last frame
  30526. */
  30527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30528. }
  30529. }
  30530. declare module BABYLON {
  30531. /**
  30532. * Defines the types of pose enabled controllers that are supported
  30533. */
  30534. enum PoseEnabledControllerType {
  30535. /**
  30536. * HTC Vive
  30537. */
  30538. VIVE = 0,
  30539. /**
  30540. * Oculus Rift
  30541. */
  30542. OCULUS = 1,
  30543. /**
  30544. * Windows mixed reality
  30545. */
  30546. WINDOWS = 2,
  30547. /**
  30548. * Samsung gear VR
  30549. */
  30550. GEAR_VR = 3,
  30551. /**
  30552. * Google Daydream
  30553. */
  30554. DAYDREAM = 4,
  30555. /**
  30556. * Generic
  30557. */
  30558. GENERIC = 5,
  30559. }
  30560. /**
  30561. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30562. */
  30563. interface MutableGamepadButton {
  30564. /**
  30565. * Value of the button/trigger
  30566. */
  30567. value: number;
  30568. /**
  30569. * If the button/trigger is currently touched
  30570. */
  30571. touched: boolean;
  30572. /**
  30573. * If the button/trigger is currently pressed
  30574. */
  30575. pressed: boolean;
  30576. }
  30577. /**
  30578. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30579. * @hidden
  30580. */
  30581. interface ExtendedGamepadButton extends GamepadButton {
  30582. /**
  30583. * If the button/trigger is currently pressed
  30584. */
  30585. readonly pressed: boolean;
  30586. /**
  30587. * If the button/trigger is currently touched
  30588. */
  30589. readonly touched: boolean;
  30590. /**
  30591. * Value of the button/trigger
  30592. */
  30593. readonly value: number;
  30594. }
  30595. /**
  30596. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30597. */
  30598. class PoseEnabledControllerHelper {
  30599. /**
  30600. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30601. * @param vrGamepad the gamepad to initialized
  30602. * @returns a vr controller of the type the gamepad identified as
  30603. */
  30604. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30605. }
  30606. /**
  30607. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30608. */
  30609. class PoseEnabledController extends Gamepad implements PoseControlled {
  30610. private _deviceRoomPosition;
  30611. private _deviceRoomRotationQuaternion;
  30612. /**
  30613. * The device position in babylon space
  30614. */
  30615. devicePosition: Vector3;
  30616. /**
  30617. * The device rotation in babylon space
  30618. */
  30619. deviceRotationQuaternion: Quaternion;
  30620. /**
  30621. * The scale factor of the device in babylon space
  30622. */
  30623. deviceScaleFactor: number;
  30624. /**
  30625. * (Likely devicePosition should be used instead) The device position in its room space
  30626. */
  30627. position: Vector3;
  30628. /**
  30629. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30630. */
  30631. rotationQuaternion: Quaternion;
  30632. /**
  30633. * The type of controller (Eg. Windows mixed reality)
  30634. */
  30635. controllerType: PoseEnabledControllerType;
  30636. protected _calculatedPosition: Vector3;
  30637. private _calculatedRotation;
  30638. /**
  30639. * The raw pose from the device
  30640. */
  30641. rawPose: DevicePose;
  30642. /**
  30643. * Internal, the mesh attached to the controller
  30644. */
  30645. private _poseControlledCamera;
  30646. private _leftHandSystemQuaternion;
  30647. /**
  30648. * Internal, matrix used to convert room space to babylon space
  30649. */
  30650. /**
  30651. * Node to be used when casting a ray from the controller
  30652. */
  30653. /**
  30654. * Name of the child mesh that can be used to cast a ray from the controller
  30655. */
  30656. static readonly POINTING_POSE: string;
  30657. /**
  30658. * Creates a new PoseEnabledController from a gamepad
  30659. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30660. */
  30661. constructor(browserGamepad: any);
  30662. private _workingMatrix;
  30663. /**
  30664. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30665. */
  30666. update(): void;
  30667. /**
  30668. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30669. * @param poseData raw pose fromthe device
  30670. */
  30671. updateFromDevice(poseData: DevicePose): void;
  30672. /**
  30673. * @hidden
  30674. */
  30675. /**
  30676. * Attaches a mesh to the controller
  30677. * @param mesh the mesh to be attached
  30678. */
  30679. attachToMesh(mesh: AbstractMesh): void;
  30680. /**
  30681. * Attaches the controllers mesh to a camera
  30682. * @param camera the camera the mesh should be attached to
  30683. */
  30684. attachToPoseControlledCamera(camera: TargetCamera): void;
  30685. /**
  30686. * Disposes of the controller
  30687. */
  30688. dispose(): void;
  30689. /**
  30690. * The mesh that is attached to the controller
  30691. */
  30692. readonly mesh: Nullable<AbstractMesh>;
  30693. /**
  30694. * Gets the ray of the controller in the direction the controller is pointing
  30695. * @param length the length the resulting ray should be
  30696. * @returns a ray in the direction the controller is pointing
  30697. */
  30698. getForwardRay(length?: number): Ray;
  30699. }
  30700. }
  30701. declare module BABYLON {
  30702. /**
  30703. * Vive Controller
  30704. */
  30705. class ViveController extends WebVRController {
  30706. /**
  30707. * Base Url for the controller model.
  30708. */
  30709. static MODEL_BASE_URL: string;
  30710. /**
  30711. * File name for the controller model.
  30712. */
  30713. static MODEL_FILENAME: string;
  30714. /**
  30715. * Creates a new ViveController from a gamepad
  30716. * @param vrGamepad the gamepad that the controller should be created from
  30717. */
  30718. constructor(vrGamepad: any);
  30719. /**
  30720. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30721. * @param scene scene in which to add meshes
  30722. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30723. */
  30724. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30725. /**
  30726. * Fired when the left button on this controller is modified
  30727. */
  30728. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30729. /**
  30730. * Fired when the right button on this controller is modified
  30731. */
  30732. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30733. /**
  30734. * Fired when the menu button on this controller is modified
  30735. */
  30736. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30737. /**
  30738. * Called once for each button that changed state since the last frame
  30739. * Vive mapping:
  30740. * 0: touchpad
  30741. * 1: trigger
  30742. * 2: left AND right buttons
  30743. * 3: menu button
  30744. * @param buttonIdx Which button index changed
  30745. * @param state New state of the button
  30746. * @param changes Which properties on the state changed since last frame
  30747. */
  30748. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30749. }
  30750. }
  30751. declare module BABYLON {
  30752. /**
  30753. * Defines the WebVRController object that represents controllers tracked in 3D space
  30754. */
  30755. abstract class WebVRController extends PoseEnabledController {
  30756. /**
  30757. * Internal, the default controller model for the controller
  30758. */
  30759. protected _defaultModel: AbstractMesh;
  30760. /**
  30761. * Fired when the trigger state has changed
  30762. */
  30763. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30764. /**
  30765. * Fired when the main button state has changed
  30766. */
  30767. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30768. /**
  30769. * Fired when the secondary button state has changed
  30770. */
  30771. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30772. /**
  30773. * Fired when the pad state has changed
  30774. */
  30775. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30776. /**
  30777. * Fired when controllers stick values have changed
  30778. */
  30779. onPadValuesChangedObservable: Observable<StickValues>;
  30780. /**
  30781. * Array of button availible on the controller
  30782. */
  30783. protected _buttons: Array<MutableGamepadButton>;
  30784. private _onButtonStateChange;
  30785. /**
  30786. * Fired when a controller button's state has changed
  30787. * @param callback the callback containing the button that was modified
  30788. */
  30789. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30790. /**
  30791. * X and Y axis corrisponding to the controllers joystick
  30792. */
  30793. pad: StickValues;
  30794. /**
  30795. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30796. */
  30797. hand: string;
  30798. /**
  30799. * The default controller model for the controller
  30800. */
  30801. readonly defaultModel: AbstractMesh;
  30802. /**
  30803. * Creates a new WebVRController from a gamepad
  30804. * @param vrGamepad the gamepad that the WebVRController should be created from
  30805. */
  30806. constructor(vrGamepad: any);
  30807. /**
  30808. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30809. */
  30810. update(): void;
  30811. /**
  30812. * Function to be called when a button is modified
  30813. */
  30814. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30815. /**
  30816. * Loads a mesh and attaches it to the controller
  30817. * @param scene the scene the mesh should be added to
  30818. * @param meshLoaded callback for when the mesh has been loaded
  30819. */
  30820. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30821. private _setButtonValue(newState, currentState, buttonIndex);
  30822. private _changes;
  30823. private _checkChanges(newState, currentState);
  30824. /**
  30825. * Disposes of th webVRCOntroller
  30826. */
  30827. dispose(): void;
  30828. }
  30829. }
  30830. declare module BABYLON {
  30831. /**
  30832. * Defines the WindowsMotionController object that the state of the windows motion controller
  30833. */
  30834. class WindowsMotionController extends WebVRController {
  30835. /**
  30836. * The base url used to load the left and right controller models
  30837. */
  30838. static MODEL_BASE_URL: string;
  30839. /**
  30840. * The name of the left controller model file
  30841. */
  30842. static MODEL_LEFT_FILENAME: string;
  30843. /**
  30844. * The name of the right controller model file
  30845. */
  30846. static MODEL_RIGHT_FILENAME: string;
  30847. /**
  30848. * The controller name prefix for this controller type
  30849. */
  30850. static readonly GAMEPAD_ID_PREFIX: string;
  30851. /**
  30852. * The controller id pattern for this controller type
  30853. */
  30854. private static readonly GAMEPAD_ID_PATTERN;
  30855. private _loadedMeshInfo;
  30856. private readonly _mapping;
  30857. /**
  30858. * Fired when the trackpad on this controller is clicked
  30859. */
  30860. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30861. /**
  30862. * Fired when the trackpad on this controller is modified
  30863. */
  30864. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30865. /**
  30866. * The current x and y values of this controller's trackpad
  30867. */
  30868. trackpad: StickValues;
  30869. /**
  30870. * Creates a new WindowsMotionController from a gamepad
  30871. * @param vrGamepad the gamepad that the controller should be created from
  30872. */
  30873. constructor(vrGamepad: any);
  30874. /**
  30875. * Fired when the trigger on this controller is modified
  30876. */
  30877. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30878. /**
  30879. * Fired when the menu button on this controller is modified
  30880. */
  30881. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30882. /**
  30883. * Fired when the grip button on this controller is modified
  30884. */
  30885. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30886. /**
  30887. * Fired when the thumbstick button on this controller is modified
  30888. */
  30889. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30890. /**
  30891. * Fired when the touchpad button on this controller is modified
  30892. */
  30893. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30894. /**
  30895. * Fired when the touchpad values on this controller are modified
  30896. */
  30897. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30898. /**
  30899. * Called once per frame by the engine.
  30900. */
  30901. update(): void;
  30902. /**
  30903. * Called once for each button that changed state since the last frame
  30904. * @param buttonIdx Which button index changed
  30905. * @param state New state of the button
  30906. * @param changes Which properties on the state changed since last frame
  30907. */
  30908. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30909. /**
  30910. * Moves the buttons on the controller mesh based on their current state
  30911. * @param buttonName the name of the button to move
  30912. * @param buttonValue the value of the button which determines the buttons new position
  30913. */
  30914. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30915. /**
  30916. * Moves the axis on the controller mesh based on its current state
  30917. * @param axis the index of the axis
  30918. * @param axisValue the value of the axis which determines the meshes new position
  30919. * @hidden
  30920. */
  30921. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30922. /**
  30923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30924. * @param scene scene in which to add meshes
  30925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30926. */
  30927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30928. /**
  30929. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30930. * can be transformed by button presses and axes values, based on this._mapping.
  30931. *
  30932. * @param scene scene in which the meshes exist
  30933. * @param meshes list of meshes that make up the controller model to process
  30934. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30935. */
  30936. private processModel(scene, meshes);
  30937. private createMeshInfo(rootNode);
  30938. /**
  30939. * Gets the ray of the controller in the direction the controller is pointing
  30940. * @param length the length the resulting ray should be
  30941. * @returns a ray in the direction the controller is pointing
  30942. */
  30943. getForwardRay(length?: number): Ray;
  30944. /**
  30945. * Disposes of the controller
  30946. */
  30947. dispose(): void;
  30948. }
  30949. }
  30950. declare module BABYLON {
  30951. /**
  30952. * Interface to implement to create a shadow generator compatible with BJS.
  30953. */
  30954. interface IShadowGenerator {
  30955. /**
  30956. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30957. * @returns The render target texture if present otherwise, null
  30958. */
  30959. getShadowMap(): Nullable<RenderTargetTexture>;
  30960. /**
  30961. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30962. * @returns The render target texture if the shadow map is present otherwise, null
  30963. */
  30964. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30965. /**
  30966. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30967. * @param subMesh The submesh we want to render in the shadow map
  30968. * @param useInstances Defines wether will draw in the map using instances
  30969. * @returns true if ready otherwise, false
  30970. */
  30971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30972. /**
  30973. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30974. * @param defines Defines of the material we want to update
  30975. * @param lightIndex Index of the light in the enabled light list of the material
  30976. */
  30977. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30978. /**
  30979. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30980. * defined in the generator but impacting the effect).
  30981. * It implies the unifroms available on the materials are the standard BJS ones.
  30982. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30983. * @param effect The effect we are binfing the information for
  30984. */
  30985. bindShadowLight(lightIndex: string, effect: Effect): void;
  30986. /**
  30987. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30988. * (eq to shadow prjection matrix * light transform matrix)
  30989. * @returns The transform matrix used to create the shadow map
  30990. */
  30991. getTransformMatrix(): Matrix;
  30992. /**
  30993. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30994. * Cube and 2D textures for instance.
  30995. */
  30996. recreateShadowMap(): void;
  30997. /**
  30998. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30999. * @param onCompiled Callback triggered at the and of the effects compilation
  31000. * @param options Sets of optional options forcing the compilation with different modes
  31001. */
  31002. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31003. useInstances: boolean;
  31004. }>): void;
  31005. /**
  31006. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31007. * @param options Sets of optional options forcing the compilation with different modes
  31008. * @returns A promise that resolves when the compilation completes
  31009. */
  31010. forceCompilationAsync(options?: Partial<{
  31011. useInstances: boolean;
  31012. }>): Promise<void>;
  31013. /**
  31014. * Serializes the shadow generator setup to a json object.
  31015. * @returns The serialized JSON object
  31016. */
  31017. serialize(): any;
  31018. /**
  31019. * Disposes the Shadow map and related Textures and effects.
  31020. */
  31021. dispose(): void;
  31022. }
  31023. /**
  31024. * Default implementation IShadowGenerator.
  31025. * This is the main object responsible of generating shadows in the framework.
  31026. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31027. */
  31028. class ShadowGenerator implements IShadowGenerator {
  31029. /**
  31030. * Shadow generator mode None: no filtering applied.
  31031. */
  31032. static readonly FILTER_NONE: number;
  31033. /**
  31034. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31035. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31036. */
  31037. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31038. /**
  31039. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31040. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31041. */
  31042. static readonly FILTER_POISSONSAMPLING: number;
  31043. /**
  31044. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31045. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31046. */
  31047. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31048. /**
  31049. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31050. * edge artifacts on steep falloff.
  31051. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31052. */
  31053. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31054. /**
  31055. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31056. * edge artifacts on steep falloff.
  31057. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31058. */
  31059. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31060. /**
  31061. * Shadow generator mode PCF: Percentage Closer Filtering
  31062. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31063. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31064. */
  31065. static readonly FILTER_PCF: number;
  31066. /**
  31067. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31068. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31069. * Contact Hardening
  31070. */
  31071. static readonly FILTER_PCSS: number;
  31072. /**
  31073. * Reserved for PCF and PCSS
  31074. * Highest Quality.
  31075. *
  31076. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31077. *
  31078. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31079. */
  31080. static readonly QUALITY_HIGH: number;
  31081. /**
  31082. * Reserved for PCF and PCSS
  31083. * Good tradeoff for quality/perf cross devices
  31084. *
  31085. * Execute PCF on a 3*3 kernel.
  31086. *
  31087. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31088. */
  31089. static readonly QUALITY_MEDIUM: number;
  31090. /**
  31091. * Reserved for PCF and PCSS
  31092. * The lowest quality but the fastest.
  31093. *
  31094. * Execute PCF on a 1*1 kernel.
  31095. *
  31096. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31097. */
  31098. static readonly QUALITY_LOW: number;
  31099. private _bias;
  31100. /**
  31101. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31102. */
  31103. /**
  31104. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31105. */
  31106. bias: number;
  31107. private _normalBias;
  31108. /**
  31109. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31110. */
  31111. /**
  31112. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31113. */
  31114. normalBias: number;
  31115. private _blurBoxOffset;
  31116. /**
  31117. * Gets the blur box offset: offset applied during the blur pass.
  31118. * Only usefull if useKernelBlur = false
  31119. */
  31120. /**
  31121. * Sets the blur box offset: offset applied during the blur pass.
  31122. * Only usefull if useKernelBlur = false
  31123. */
  31124. blurBoxOffset: number;
  31125. private _blurScale;
  31126. /**
  31127. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31128. * 2 means half of the size.
  31129. */
  31130. /**
  31131. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31132. * 2 means half of the size.
  31133. */
  31134. blurScale: number;
  31135. private _blurKernel;
  31136. /**
  31137. * Gets the blur kernel: kernel size of the blur pass.
  31138. * Only usefull if useKernelBlur = true
  31139. */
  31140. /**
  31141. * Sets the blur kernel: kernel size of the blur pass.
  31142. * Only usefull if useKernelBlur = true
  31143. */
  31144. blurKernel: number;
  31145. private _useKernelBlur;
  31146. /**
  31147. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31148. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31149. */
  31150. /**
  31151. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31152. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31153. */
  31154. useKernelBlur: boolean;
  31155. private _depthScale;
  31156. /**
  31157. * Gets the depth scale used in ESM mode.
  31158. */
  31159. /**
  31160. * Sets the depth scale used in ESM mode.
  31161. * This can override the scale stored on the light.
  31162. */
  31163. depthScale: number;
  31164. private _filter;
  31165. /**
  31166. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31167. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31168. */
  31169. /**
  31170. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31171. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31172. */
  31173. filter: number;
  31174. /**
  31175. * Gets if the current filter is set to Poisson Sampling.
  31176. */
  31177. /**
  31178. * Sets the current filter to Poisson Sampling.
  31179. */
  31180. usePoissonSampling: boolean;
  31181. /**
  31182. * Gets if the current filter is set to VSM.
  31183. * DEPRECATED. Should use useExponentialShadowMap instead.
  31184. */
  31185. /**
  31186. * Sets the current filter is to VSM.
  31187. * DEPRECATED. Should use useExponentialShadowMap instead.
  31188. */
  31189. useVarianceShadowMap: boolean;
  31190. /**
  31191. * Gets if the current filter is set to blurred VSM.
  31192. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31193. */
  31194. /**
  31195. * Sets the current filter is to blurred VSM.
  31196. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31197. */
  31198. useBlurVarianceShadowMap: boolean;
  31199. /**
  31200. * Gets if the current filter is set to ESM.
  31201. */
  31202. /**
  31203. * Sets the current filter is to ESM.
  31204. */
  31205. useExponentialShadowMap: boolean;
  31206. /**
  31207. * Gets if the current filter is set to filtered ESM.
  31208. */
  31209. /**
  31210. * Gets if the current filter is set to filtered ESM.
  31211. */
  31212. useBlurExponentialShadowMap: boolean;
  31213. /**
  31214. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31215. * exponential to prevent steep falloff artifacts).
  31216. */
  31217. /**
  31218. * Sets the current filter to "close ESM" (using the inverse of the
  31219. * exponential to prevent steep falloff artifacts).
  31220. */
  31221. useCloseExponentialShadowMap: boolean;
  31222. /**
  31223. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31224. * exponential to prevent steep falloff artifacts).
  31225. */
  31226. /**
  31227. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31228. * exponential to prevent steep falloff artifacts).
  31229. */
  31230. useBlurCloseExponentialShadowMap: boolean;
  31231. /**
  31232. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31233. */
  31234. /**
  31235. * Sets the current filter to "PCF" (percentage closer filtering).
  31236. */
  31237. usePercentageCloserFiltering: boolean;
  31238. private _filteringQuality;
  31239. /**
  31240. * Gets the PCF or PCSS Quality.
  31241. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31242. */
  31243. /**
  31244. * Sets the PCF or PCSS Quality.
  31245. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31246. */
  31247. filteringQuality: number;
  31248. /**
  31249. * Gets if the current filter is set to "PCSS" (contact hardening).
  31250. */
  31251. /**
  31252. * Sets the current filter to "PCSS" (contact hardening).
  31253. */
  31254. useContactHardeningShadow: boolean;
  31255. private _contactHardeningLightSizeUVRatio;
  31256. /**
  31257. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31258. * Using a ratio helps keeping shape stability independently of the map size.
  31259. *
  31260. * It does not account for the light projection as it was having too much
  31261. * instability during the light setup or during light position changes.
  31262. *
  31263. * Only valid if useContactHardeningShadow is true.
  31264. */
  31265. /**
  31266. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31267. * Using a ratio helps keeping shape stability independently of the map size.
  31268. *
  31269. * It does not account for the light projection as it was having too much
  31270. * instability during the light setup or during light position changes.
  31271. *
  31272. * Only valid if useContactHardeningShadow is true.
  31273. */
  31274. contactHardeningLightSizeUVRatio: number;
  31275. private _darkness;
  31276. /**
  31277. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31278. * 0 means strongest and 1 would means no shadow.
  31279. * @returns the darkness.
  31280. */
  31281. getDarkness(): number;
  31282. /**
  31283. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31284. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31285. * @returns the shadow generator allowing fluent coding.
  31286. */
  31287. setDarkness(darkness: number): ShadowGenerator;
  31288. private _transparencyShadow;
  31289. /**
  31290. * Sets the ability to have transparent shadow (boolean).
  31291. * @param transparent True if transparent else False
  31292. * @returns the shadow generator allowing fluent coding
  31293. */
  31294. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31295. private _shadowMap;
  31296. private _shadowMap2;
  31297. /**
  31298. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31299. * @returns The render target texture if present otherwise, null
  31300. */
  31301. getShadowMap(): Nullable<RenderTargetTexture>;
  31302. /**
  31303. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31304. * @returns The render target texture if the shadow map is present otherwise, null
  31305. */
  31306. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31307. /**
  31308. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31309. * @param mesh Mesh to add
  31310. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31311. * @returns the Shadow Generator itself
  31312. */
  31313. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31314. /**
  31315. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31316. * @param mesh Mesh to remove
  31317. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31318. * @returns the Shadow Generator itself
  31319. */
  31320. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31321. /**
  31322. * Controls the extent to which the shadows fade out at the edge of the frustum
  31323. * Used only by directionals and spots
  31324. */
  31325. frustumEdgeFalloff: number;
  31326. private _light;
  31327. /**
  31328. * Returns the associated light object.
  31329. * @returns the light generating the shadow
  31330. */
  31331. getLight(): IShadowLight;
  31332. /**
  31333. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31334. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31335. * It might on the other hand introduce peter panning.
  31336. */
  31337. forceBackFacesOnly: boolean;
  31338. private _scene;
  31339. private _lightDirection;
  31340. private _effect;
  31341. private _viewMatrix;
  31342. private _projectionMatrix;
  31343. private _transformMatrix;
  31344. private _cachedPosition;
  31345. private _cachedDirection;
  31346. private _cachedDefines;
  31347. private _currentRenderID;
  31348. private _boxBlurPostprocess;
  31349. private _kernelBlurXPostprocess;
  31350. private _kernelBlurYPostprocess;
  31351. private _blurPostProcesses;
  31352. private _mapSize;
  31353. private _currentFaceIndex;
  31354. private _currentFaceIndexCache;
  31355. private _textureType;
  31356. private _defaultTextureMatrix;
  31357. /**
  31358. * Creates a ShadowGenerator object.
  31359. * A ShadowGenerator is the required tool to use the shadows.
  31360. * Each light casting shadows needs to use its own ShadowGenerator.
  31361. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31362. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31363. * @param light The light object generating the shadows.
  31364. * @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.
  31365. */
  31366. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31367. private _initializeGenerator();
  31368. private _initializeShadowMap();
  31369. private _initializeBlurRTTAndPostProcesses();
  31370. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31371. private _renderSubMeshForShadowMap(subMesh);
  31372. private _applyFilterValues();
  31373. /**
  31374. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31375. * @param onCompiled Callback triggered at the and of the effects compilation
  31376. * @param options Sets of optional options forcing the compilation with different modes
  31377. */
  31378. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31379. useInstances: boolean;
  31380. }>): void;
  31381. /**
  31382. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31383. * @param options Sets of optional options forcing the compilation with different modes
  31384. * @returns A promise that resolves when the compilation completes
  31385. */
  31386. forceCompilationAsync(options?: Partial<{
  31387. useInstances: boolean;
  31388. }>): Promise<void>;
  31389. /**
  31390. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31391. * @param subMesh The submesh we want to render in the shadow map
  31392. * @param useInstances Defines wether will draw in the map using instances
  31393. * @returns true if ready otherwise, false
  31394. */
  31395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31396. /**
  31397. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31398. * @param defines Defines of the material we want to update
  31399. * @param lightIndex Index of the light in the enabled light list of the material
  31400. */
  31401. prepareDefines(defines: any, lightIndex: number): void;
  31402. /**
  31403. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31404. * defined in the generator but impacting the effect).
  31405. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31406. * @param effect The effect we are binfing the information for
  31407. */
  31408. bindShadowLight(lightIndex: string, effect: Effect): void;
  31409. /**
  31410. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31411. * (eq to shadow prjection matrix * light transform matrix)
  31412. * @returns The transform matrix used to create the shadow map
  31413. */
  31414. getTransformMatrix(): Matrix;
  31415. /**
  31416. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31417. * Cube and 2D textures for instance.
  31418. */
  31419. recreateShadowMap(): void;
  31420. private _disposeBlurPostProcesses();
  31421. private _disposeRTTandPostProcesses();
  31422. /**
  31423. * Disposes the ShadowGenerator.
  31424. * Returns nothing.
  31425. */
  31426. dispose(): void;
  31427. /**
  31428. * Serializes the shadow generator setup to a json object.
  31429. * @returns The serialized JSON object
  31430. */
  31431. serialize(): any;
  31432. /**
  31433. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31434. * @param parsedShadowGenerator The JSON object to parse
  31435. * @param scene The scene to create the shadow map for
  31436. * @returns The parsed shadow generator
  31437. */
  31438. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31439. }
  31440. }
  31441. declare module BABYLON {
  31442. }
  31443. declare module BABYLON {
  31444. /**
  31445. * Background material used to create an efficient environement around your scene.
  31446. */
  31447. class BackgroundMaterial extends PushMaterial {
  31448. /**
  31449. * Standard reflectance value at parallel view angle.
  31450. */
  31451. static StandardReflectance0: number;
  31452. /**
  31453. * Standard reflectance value at grazing angle.
  31454. */
  31455. static StandardReflectance90: number;
  31456. protected _primaryColor: Color3;
  31457. /**
  31458. * Key light Color (multiply against the environement texture)
  31459. */
  31460. primaryColor: Color3;
  31461. protected __perceptualColor: Nullable<Color3>;
  31462. /**
  31463. * Experimental Internal Use Only.
  31464. *
  31465. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31466. * This acts as a helper to set the primary color to a more "human friendly" value.
  31467. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31468. * output color as close as possible from the chosen value.
  31469. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31470. * part of lighting setup.)
  31471. */
  31472. protected _primaryColorShadowLevel: float;
  31473. /**
  31474. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31475. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31476. */
  31477. primaryColorShadowLevel: float;
  31478. protected _primaryColorHighlightLevel: float;
  31479. /**
  31480. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31481. * The primary color is used at the level chosen to define what the white area would look.
  31482. */
  31483. primaryColorHighlightLevel: float;
  31484. protected _reflectionTexture: Nullable<BaseTexture>;
  31485. /**
  31486. * Reflection Texture used in the material.
  31487. * Should be author in a specific way for the best result (refer to the documentation).
  31488. */
  31489. reflectionTexture: Nullable<BaseTexture>;
  31490. protected _reflectionBlur: float;
  31491. /**
  31492. * Reflection Texture level of blur.
  31493. *
  31494. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31495. * texture twice.
  31496. */
  31497. reflectionBlur: float;
  31498. protected _diffuseTexture: Nullable<BaseTexture>;
  31499. /**
  31500. * Diffuse Texture used in the material.
  31501. * Should be author in a specific way for the best result (refer to the documentation).
  31502. */
  31503. diffuseTexture: Nullable<BaseTexture>;
  31504. protected _shadowLights: Nullable<IShadowLight[]>;
  31505. /**
  31506. * Specify the list of lights casting shadow on the material.
  31507. * All scene shadow lights will be included if null.
  31508. */
  31509. shadowLights: Nullable<IShadowLight[]>;
  31510. protected _shadowLevel: float;
  31511. /**
  31512. * Helps adjusting the shadow to a softer level if required.
  31513. * 0 means black shadows and 1 means no shadows.
  31514. */
  31515. shadowLevel: float;
  31516. protected _sceneCenter: Vector3;
  31517. /**
  31518. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31519. * It is usually zero but might be interesting to modify according to your setup.
  31520. */
  31521. sceneCenter: Vector3;
  31522. protected _opacityFresnel: boolean;
  31523. /**
  31524. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31525. * This helps ensuring a nice transition when the camera goes under the ground.
  31526. */
  31527. opacityFresnel: boolean;
  31528. protected _reflectionFresnel: boolean;
  31529. /**
  31530. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31531. * This helps adding a mirror texture on the ground.
  31532. */
  31533. reflectionFresnel: boolean;
  31534. protected _reflectionFalloffDistance: number;
  31535. /**
  31536. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31537. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31538. */
  31539. reflectionFalloffDistance: number;
  31540. protected _reflectionAmount: number;
  31541. /**
  31542. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31543. */
  31544. reflectionAmount: number;
  31545. protected _reflectionReflectance0: number;
  31546. /**
  31547. * This specifies the weight of the reflection at grazing angle.
  31548. */
  31549. reflectionReflectance0: number;
  31550. protected _reflectionReflectance90: number;
  31551. /**
  31552. * This specifies the weight of the reflection at a perpendicular point of view.
  31553. */
  31554. reflectionReflectance90: number;
  31555. /**
  31556. * Sets the reflection reflectance fresnel values according to the default standard
  31557. * empirically know to work well :-)
  31558. */
  31559. reflectionStandardFresnelWeight: number;
  31560. protected _useRGBColor: boolean;
  31561. /**
  31562. * Helps to directly use the maps channels instead of their level.
  31563. */
  31564. useRGBColor: boolean;
  31565. protected _enableNoise: boolean;
  31566. /**
  31567. * This helps reducing the banding effect that could occur on the background.
  31568. */
  31569. enableNoise: boolean;
  31570. /**
  31571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31572. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31573. * Recommended to be keep at 1.0 except for special cases.
  31574. */
  31575. fovMultiplier: number;
  31576. private _fovMultiplier;
  31577. /**
  31578. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31579. */
  31580. useEquirectangularFOV: boolean;
  31581. private _maxSimultaneousLights;
  31582. /**
  31583. * Number of Simultaneous lights allowed on the material.
  31584. */
  31585. maxSimultaneousLights: int;
  31586. /**
  31587. * Default configuration related to image processing available in the Background Material.
  31588. */
  31589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31590. /**
  31591. * Keep track of the image processing observer to allow dispose and replace.
  31592. */
  31593. private _imageProcessingObserver;
  31594. /**
  31595. * Attaches a new image processing configuration to the PBR Material.
  31596. * @param configuration (if null the scene configuration will be use)
  31597. */
  31598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31599. /**
  31600. * Gets the image processing configuration used either in this material.
  31601. */
  31602. /**
  31603. * Sets the Default image processing configuration used either in the this material.
  31604. *
  31605. * If sets to null, the scene one is in use.
  31606. */
  31607. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31608. /**
  31609. * Gets wether the color curves effect is enabled.
  31610. */
  31611. /**
  31612. * Sets wether the color curves effect is enabled.
  31613. */
  31614. cameraColorCurvesEnabled: boolean;
  31615. /**
  31616. * Gets wether the color grading effect is enabled.
  31617. */
  31618. /**
  31619. * Gets wether the color grading effect is enabled.
  31620. */
  31621. cameraColorGradingEnabled: boolean;
  31622. /**
  31623. * Gets wether tonemapping is enabled or not.
  31624. */
  31625. /**
  31626. * Sets wether tonemapping is enabled or not
  31627. */
  31628. cameraToneMappingEnabled: boolean;
  31629. /**
  31630. * The camera exposure used on this material.
  31631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31632. * This corresponds to a photographic exposure.
  31633. */
  31634. /**
  31635. * The camera exposure used on this material.
  31636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31637. * This corresponds to a photographic exposure.
  31638. */
  31639. cameraExposure: float;
  31640. /**
  31641. * Gets The camera contrast used on this material.
  31642. */
  31643. /**
  31644. * Sets The camera contrast used on this material.
  31645. */
  31646. cameraContrast: float;
  31647. /**
  31648. * Gets the Color Grading 2D Lookup Texture.
  31649. */
  31650. /**
  31651. * Sets the Color Grading 2D Lookup Texture.
  31652. */
  31653. cameraColorGradingTexture: Nullable<BaseTexture>;
  31654. /**
  31655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31657. * 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;
  31658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31659. */
  31660. /**
  31661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31663. * 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;
  31664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31665. */
  31666. cameraColorCurves: Nullable<ColorCurves>;
  31667. /**
  31668. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31669. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31670. */
  31671. switchToBGR: boolean;
  31672. private _renderTargets;
  31673. private _reflectionControls;
  31674. private _white;
  31675. private _primaryShadowColor;
  31676. private _primaryHighlightColor;
  31677. /**
  31678. * Instantiates a Background Material in the given scene
  31679. * @param name The friendly name of the material
  31680. * @param scene The scene to add the material to
  31681. */
  31682. constructor(name: string, scene: Scene);
  31683. /**
  31684. * The entire material has been created in order to prevent overdraw.
  31685. * @returns false
  31686. */
  31687. needAlphaTesting(): boolean;
  31688. /**
  31689. * The entire material has been created in order to prevent overdraw.
  31690. * @returns true if blending is enable
  31691. */
  31692. needAlphaBlending(): boolean;
  31693. /**
  31694. * Checks wether the material is ready to be rendered for a given mesh.
  31695. * @param mesh The mesh to render
  31696. * @param subMesh The submesh to check against
  31697. * @param useInstances Specify wether or not the material is used with instances
  31698. * @returns true if all the dependencies are ready (Textures, Effects...)
  31699. */
  31700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31701. /**
  31702. * Compute the primary color according to the chosen perceptual color.
  31703. */
  31704. private _computePrimaryColorFromPerceptualColor();
  31705. /**
  31706. * Compute the highlights and shadow colors according to their chosen levels.
  31707. */
  31708. private _computePrimaryColors();
  31709. /**
  31710. * Build the uniform buffer used in the material.
  31711. */
  31712. buildUniformLayout(): void;
  31713. /**
  31714. * Unbind the material.
  31715. */
  31716. unbind(): void;
  31717. /**
  31718. * Bind only the world matrix to the material.
  31719. * @param world The world matrix to bind.
  31720. */
  31721. bindOnlyWorldMatrix(world: Matrix): void;
  31722. /**
  31723. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31724. * @param world The world matrix to bind.
  31725. * @param subMesh The submesh to bind for.
  31726. */
  31727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31728. /**
  31729. * Dispose the material.
  31730. * @param forceDisposeEffect Force disposal of the associated effect.
  31731. * @param forceDisposeTextures Force disposal of the associated textures.
  31732. */
  31733. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31734. /**
  31735. * Clones the material.
  31736. * @param name The cloned name.
  31737. * @returns The cloned material.
  31738. */
  31739. clone(name: string): BackgroundMaterial;
  31740. /**
  31741. * Serializes the current material to its JSON representation.
  31742. * @returns The JSON representation.
  31743. */
  31744. serialize(): any;
  31745. /**
  31746. * Gets the class name of the material
  31747. * @returns "BackgroundMaterial"
  31748. */
  31749. getClassName(): string;
  31750. /**
  31751. * Parse a JSON input to create back a background material.
  31752. * @param source The JSON data to parse
  31753. * @param scene The scene to create the parsed material in
  31754. * @param rootUrl The root url of the assets the material depends upon
  31755. * @returns the instantiated BackgroundMaterial.
  31756. */
  31757. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31758. }
  31759. }
  31760. declare module BABYLON {
  31761. /**
  31762. * The Physically based material base class of BJS.
  31763. *
  31764. * This offers the main features of a standard PBR material.
  31765. * For more information, please refer to the documentation :
  31766. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31767. */
  31768. abstract class PBRBaseMaterial extends PushMaterial {
  31769. /**
  31770. * Intensity of the direct lights e.g. the four lights available in your scene.
  31771. * This impacts both the direct diffuse and specular highlights.
  31772. */
  31773. protected _directIntensity: number;
  31774. /**
  31775. * Intensity of the emissive part of the material.
  31776. * This helps controlling the emissive effect without modifying the emissive color.
  31777. */
  31778. protected _emissiveIntensity: number;
  31779. /**
  31780. * Intensity of the environment e.g. how much the environment will light the object
  31781. * either through harmonics for rough material or through the refelction for shiny ones.
  31782. */
  31783. protected _environmentIntensity: number;
  31784. /**
  31785. * This is a special control allowing the reduction of the specular highlights coming from the
  31786. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31787. */
  31788. protected _specularIntensity: number;
  31789. /**
  31790. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31791. */
  31792. private _lightingInfos;
  31793. /**
  31794. * Debug Control allowing disabling the bump map on this material.
  31795. */
  31796. protected _disableBumpMap: boolean;
  31797. /**
  31798. * AKA Diffuse Texture in standard nomenclature.
  31799. */
  31800. protected _albedoTexture: BaseTexture;
  31801. /**
  31802. * AKA Occlusion Texture in other nomenclature.
  31803. */
  31804. protected _ambientTexture: BaseTexture;
  31805. /**
  31806. * AKA Occlusion Texture Intensity in other nomenclature.
  31807. */
  31808. protected _ambientTextureStrength: number;
  31809. /**
  31810. * Stores the alpha values in a texture.
  31811. */
  31812. protected _opacityTexture: BaseTexture;
  31813. /**
  31814. * Stores the reflection values in a texture.
  31815. */
  31816. protected _reflectionTexture: BaseTexture;
  31817. /**
  31818. * Stores the refraction values in a texture.
  31819. */
  31820. protected _refractionTexture: BaseTexture;
  31821. /**
  31822. * Stores the emissive values in a texture.
  31823. */
  31824. protected _emissiveTexture: BaseTexture;
  31825. /**
  31826. * AKA Specular texture in other nomenclature.
  31827. */
  31828. protected _reflectivityTexture: BaseTexture;
  31829. /**
  31830. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31831. */
  31832. protected _metallicTexture: BaseTexture;
  31833. /**
  31834. * Specifies the metallic scalar of the metallic/roughness workflow.
  31835. * Can also be used to scale the metalness values of the metallic texture.
  31836. */
  31837. protected _metallic: number;
  31838. /**
  31839. * Specifies the roughness scalar of the metallic/roughness workflow.
  31840. * Can also be used to scale the roughness values of the metallic texture.
  31841. */
  31842. protected _roughness: number;
  31843. /**
  31844. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31845. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31846. */
  31847. protected _microSurfaceTexture: BaseTexture;
  31848. /**
  31849. * Stores surface normal data used to displace a mesh in a texture.
  31850. */
  31851. protected _bumpTexture: BaseTexture;
  31852. /**
  31853. * Stores the pre-calculated light information of a mesh in a texture.
  31854. */
  31855. protected _lightmapTexture: BaseTexture;
  31856. /**
  31857. * The color of a material in ambient lighting.
  31858. */
  31859. protected _ambientColor: Color3;
  31860. /**
  31861. * AKA Diffuse Color in other nomenclature.
  31862. */
  31863. protected _albedoColor: Color3;
  31864. /**
  31865. * AKA Specular Color in other nomenclature.
  31866. */
  31867. protected _reflectivityColor: Color3;
  31868. /**
  31869. * The color applied when light is reflected from a material.
  31870. */
  31871. protected _reflectionColor: Color3;
  31872. /**
  31873. * The color applied when light is emitted from a material.
  31874. */
  31875. protected _emissiveColor: Color3;
  31876. /**
  31877. * AKA Glossiness in other nomenclature.
  31878. */
  31879. protected _microSurface: number;
  31880. /**
  31881. * source material index of refraction (IOR)' / 'destination material IOR.
  31882. */
  31883. protected _indexOfRefraction: number;
  31884. /**
  31885. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31886. */
  31887. protected _invertRefractionY: boolean;
  31888. /**
  31889. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31890. * Materials half opaque for instance using refraction could benefit from this control.
  31891. */
  31892. protected _linkRefractionWithTransparency: boolean;
  31893. /**
  31894. * Specifies that the material will use the light map as a show map.
  31895. */
  31896. protected _useLightmapAsShadowmap: boolean;
  31897. /**
  31898. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31899. * makes the reflect vector face the model (under horizon).
  31900. */
  31901. protected _useHorizonOcclusion: boolean;
  31902. /**
  31903. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31904. * too much the area relying on ambient texture to define their ambient occlusion.
  31905. */
  31906. protected _useRadianceOcclusion: boolean;
  31907. /**
  31908. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31909. */
  31910. protected _useAlphaFromAlbedoTexture: boolean;
  31911. /**
  31912. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31913. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31914. */
  31915. protected _useSpecularOverAlpha: boolean;
  31916. /**
  31917. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31918. */
  31919. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31920. /**
  31921. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31922. */
  31923. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31924. /**
  31925. * Specifies if the metallic texture contains the roughness information in its green channel.
  31926. */
  31927. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31928. /**
  31929. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31930. */
  31931. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31932. /**
  31933. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31934. */
  31935. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31936. /**
  31937. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31938. */
  31939. protected _useAmbientInGrayScale: boolean;
  31940. /**
  31941. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31942. * The material will try to infer what glossiness each pixel should be.
  31943. */
  31944. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31945. /**
  31946. * BJS is using an harcoded light falloff based on a manually sets up range.
  31947. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31948. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31949. */
  31950. protected _usePhysicalLightFalloff: boolean;
  31951. /**
  31952. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31953. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31954. */
  31955. protected _useRadianceOverAlpha: boolean;
  31956. /**
  31957. * Allows using an object space normal map (instead of tangent space).
  31958. */
  31959. protected _useObjectSpaceNormalMap: boolean;
  31960. /**
  31961. * Allows using the bump map in parallax mode.
  31962. */
  31963. protected _useParallax: boolean;
  31964. /**
  31965. * Allows using the bump map in parallax occlusion mode.
  31966. */
  31967. protected _useParallaxOcclusion: boolean;
  31968. /**
  31969. * Controls the scale bias of the parallax mode.
  31970. */
  31971. protected _parallaxScaleBias: number;
  31972. /**
  31973. * If sets to true, disables all the lights affecting the material.
  31974. */
  31975. protected _disableLighting: boolean;
  31976. /**
  31977. * Number of Simultaneous lights allowed on the material.
  31978. */
  31979. protected _maxSimultaneousLights: number;
  31980. /**
  31981. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31982. */
  31983. protected _invertNormalMapX: boolean;
  31984. /**
  31985. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31986. */
  31987. protected _invertNormalMapY: boolean;
  31988. /**
  31989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31990. */
  31991. protected _twoSidedLighting: boolean;
  31992. /**
  31993. * Defines the alpha limits in alpha test mode.
  31994. */
  31995. protected _alphaCutOff: number;
  31996. /**
  31997. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31998. */
  31999. protected _forceAlphaTest: boolean;
  32000. /**
  32001. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32002. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32003. */
  32004. protected _useAlphaFresnel: boolean;
  32005. /**
  32006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32007. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32008. */
  32009. protected _useLinearAlphaFresnel: boolean;
  32010. /**
  32011. * The transparency mode of the material.
  32012. */
  32013. protected _transparencyMode: Nullable<number>;
  32014. /**
  32015. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32016. * from cos thetav and roughness:
  32017. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32018. */
  32019. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32020. /**
  32021. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32022. */
  32023. protected _forceIrradianceInFragment: boolean;
  32024. /**
  32025. * Force normal to face away from face.
  32026. */
  32027. protected _forceNormalForward: boolean;
  32028. /**
  32029. * Enables specular anti aliasing in the PBR shader.
  32030. * It will both interacts on the Geometry for analytical and IBL lighting.
  32031. * It also prefilter the roughness map based on the bump values.
  32032. */
  32033. protected _enableSpecularAntiAliasing: boolean;
  32034. /**
  32035. * Default configuration related to image processing available in the PBR Material.
  32036. */
  32037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32038. /**
  32039. * Keep track of the image processing observer to allow dispose and replace.
  32040. */
  32041. private _imageProcessingObserver;
  32042. /**
  32043. * Attaches a new image processing configuration to the PBR Material.
  32044. * @param configuration
  32045. */
  32046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32047. /**
  32048. * Stores the available render targets.
  32049. */
  32050. private _renderTargets;
  32051. /**
  32052. * Sets the global ambient color for the material used in lighting calculations.
  32053. */
  32054. private _globalAmbientColor;
  32055. /**
  32056. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32057. */
  32058. private _useLogarithmicDepth;
  32059. /**
  32060. * If set to true, no lighting calculations will be applied.
  32061. */
  32062. private _unlit;
  32063. /**
  32064. * Instantiates a new PBRMaterial instance.
  32065. *
  32066. * @param name The material name
  32067. * @param scene The scene the material will be use in.
  32068. */
  32069. constructor(name: string, scene: Scene);
  32070. /**
  32071. * Gets the name of the material class.
  32072. */
  32073. getClassName(): string;
  32074. /**
  32075. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32076. */
  32077. /**
  32078. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32079. */
  32080. useLogarithmicDepth: boolean;
  32081. /**
  32082. * Gets the current transparency mode.
  32083. */
  32084. /**
  32085. * Sets the transparency mode of the material.
  32086. *
  32087. * | Value | Type | Description |
  32088. * | ----- | ----------------------------------- | ----------- |
  32089. * | 0 | OPAQUE | |
  32090. * | 1 | ALPHATEST | |
  32091. * | 2 | ALPHABLEND | |
  32092. * | 3 | ALPHATESTANDBLEND | |
  32093. *
  32094. */
  32095. transparencyMode: Nullable<number>;
  32096. /**
  32097. * Returns true if alpha blending should be disabled.
  32098. */
  32099. private readonly _disableAlphaBlending;
  32100. /**
  32101. * Specifies whether or not this material should be rendered in alpha blend mode.
  32102. */
  32103. needAlphaBlending(): boolean;
  32104. /**
  32105. * Specifies if the mesh will require alpha blending.
  32106. * @param mesh - BJS mesh.
  32107. */
  32108. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32109. /**
  32110. * Specifies whether or not this material should be rendered in alpha test mode.
  32111. */
  32112. needAlphaTesting(): boolean;
  32113. /**
  32114. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32115. */
  32116. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32117. /**
  32118. * Gets the texture used for the alpha test.
  32119. */
  32120. getAlphaTestTexture(): BaseTexture;
  32121. /**
  32122. * Stores the reflectivity values based on metallic roughness workflow.
  32123. */
  32124. private static _scaledReflectivity;
  32125. /**
  32126. * Specifies that the submesh is ready to be used.
  32127. * @param mesh - BJS mesh.
  32128. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32129. * @param useInstances - Specifies that instances should be used.
  32130. * @returns - boolean indicating that the submesh is ready or not.
  32131. */
  32132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32133. /**
  32134. * Specifies if the material uses metallic roughness workflow.
  32135. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32136. */
  32137. isMetallicWorkflow(): boolean;
  32138. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32139. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32140. /**
  32141. * Force shader compilation
  32142. */
  32143. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32144. clipPlane: boolean;
  32145. }>): void;
  32146. /**
  32147. * Initializes the uniform buffer layout for the shader.
  32148. */
  32149. buildUniformLayout(): void;
  32150. /**
  32151. * Unbinds the textures.
  32152. */
  32153. unbind(): void;
  32154. /**
  32155. * Binds the submesh data.
  32156. * @param world - The world matrix.
  32157. * @param mesh - The BJS mesh.
  32158. * @param subMesh - A submesh of the BJS mesh.
  32159. */
  32160. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32161. /**
  32162. * Returns the animatable textures.
  32163. * @returns - Array of animatable textures.
  32164. */
  32165. getAnimatables(): IAnimatable[];
  32166. /**
  32167. * Returns the texture used for reflections.
  32168. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32169. */
  32170. private _getReflectionTexture();
  32171. /**
  32172. * Returns the texture used for refraction or null if none is used.
  32173. * @returns - Refection texture if present. If no refraction texture and refraction
  32174. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32175. */
  32176. private _getRefractionTexture();
  32177. /**
  32178. * Disposes the resources of the material.
  32179. * @param forceDisposeEffect - Forces the disposal of effects.
  32180. * @param forceDisposeTextures - Forces the disposal of all textures.
  32181. */
  32182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32183. }
  32184. }
  32185. declare module BABYLON {
  32186. /**
  32187. * The Physically based simple base material of BJS.
  32188. *
  32189. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32190. * It is used as the base class for both the specGloss and metalRough conventions.
  32191. */
  32192. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32193. /**
  32194. * Number of Simultaneous lights allowed on the material.
  32195. */
  32196. maxSimultaneousLights: number;
  32197. /**
  32198. * If sets to true, disables all the lights affecting the material.
  32199. */
  32200. disableLighting: boolean;
  32201. /**
  32202. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32203. */
  32204. environmentTexture: BaseTexture;
  32205. /**
  32206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32207. */
  32208. invertNormalMapX: boolean;
  32209. /**
  32210. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32211. */
  32212. invertNormalMapY: boolean;
  32213. /**
  32214. * Normal map used in the model.
  32215. */
  32216. normalTexture: BaseTexture;
  32217. /**
  32218. * Emissivie color used to self-illuminate the model.
  32219. */
  32220. emissiveColor: Color3;
  32221. /**
  32222. * Emissivie texture used to self-illuminate the model.
  32223. */
  32224. emissiveTexture: BaseTexture;
  32225. /**
  32226. * Occlusion Channel Strenght.
  32227. */
  32228. occlusionStrength: number;
  32229. /**
  32230. * Occlusion Texture of the material (adding extra occlusion effects).
  32231. */
  32232. occlusionTexture: BaseTexture;
  32233. /**
  32234. * Defines the alpha limits in alpha test mode.
  32235. */
  32236. alphaCutOff: number;
  32237. /**
  32238. * Gets the current double sided mode.
  32239. */
  32240. /**
  32241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32242. */
  32243. doubleSided: boolean;
  32244. lightmapTexture: BaseTexture;
  32245. useLightmapAsShadowmap: boolean;
  32246. /**
  32247. * Return the active textures of the material.
  32248. */
  32249. getActiveTextures(): BaseTexture[];
  32250. hasTexture(texture: BaseTexture): boolean;
  32251. /**
  32252. * Instantiates a new PBRMaterial instance.
  32253. *
  32254. * @param name The material name
  32255. * @param scene The scene the material will be use in.
  32256. */
  32257. constructor(name: string, scene: Scene);
  32258. getClassName(): string;
  32259. }
  32260. }
  32261. declare module BABYLON {
  32262. /**
  32263. * The Physically based material of BJS.
  32264. *
  32265. * This offers the main features of a standard PBR material.
  32266. * For more information, please refer to the documentation :
  32267. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32268. */
  32269. class PBRMaterial extends PBRBaseMaterial {
  32270. private static _PBRMATERIAL_OPAQUE;
  32271. /**
  32272. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32273. */
  32274. static readonly PBRMATERIAL_OPAQUE: number;
  32275. /**
  32276. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32277. */
  32278. private static _PBRMATERIAL_ALPHATEST;
  32279. /**
  32280. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32281. */
  32282. static readonly PBRMATERIAL_ALPHATEST: number;
  32283. /**
  32284. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32285. */
  32286. private static _PBRMATERIAL_ALPHABLEND;
  32287. /**
  32288. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32289. */
  32290. static readonly PBRMATERIAL_ALPHABLEND: number;
  32291. /**
  32292. * 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.
  32293. * They are also discarded below the alpha cutoff threshold to improve performances.
  32294. */
  32295. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32296. /**
  32297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32298. * They are also discarded below the alpha cutoff threshold to improve performances.
  32299. */
  32300. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32301. /**
  32302. * Intensity of the direct lights e.g. the four lights available in your scene.
  32303. * This impacts both the direct diffuse and specular highlights.
  32304. */
  32305. directIntensity: number;
  32306. /**
  32307. * Intensity of the emissive part of the material.
  32308. * This helps controlling the emissive effect without modifying the emissive color.
  32309. */
  32310. emissiveIntensity: number;
  32311. /**
  32312. * Intensity of the environment e.g. how much the environment will light the object
  32313. * either through harmonics for rough material or through the refelction for shiny ones.
  32314. */
  32315. environmentIntensity: number;
  32316. /**
  32317. * This is a special control allowing the reduction of the specular highlights coming from the
  32318. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32319. */
  32320. specularIntensity: number;
  32321. /**
  32322. * Debug Control allowing disabling the bump map on this material.
  32323. */
  32324. disableBumpMap: boolean;
  32325. /**
  32326. * AKA Diffuse Texture in standard nomenclature.
  32327. */
  32328. albedoTexture: BaseTexture;
  32329. /**
  32330. * AKA Occlusion Texture in other nomenclature.
  32331. */
  32332. ambientTexture: BaseTexture;
  32333. /**
  32334. * AKA Occlusion Texture Intensity in other nomenclature.
  32335. */
  32336. ambientTextureStrength: number;
  32337. /**
  32338. * Stores the alpha values in a texture.
  32339. */
  32340. opacityTexture: BaseTexture;
  32341. /**
  32342. * Stores the reflection values in a texture.
  32343. */
  32344. reflectionTexture: Nullable<BaseTexture>;
  32345. /**
  32346. * Stores the emissive values in a texture.
  32347. */
  32348. emissiveTexture: BaseTexture;
  32349. /**
  32350. * AKA Specular texture in other nomenclature.
  32351. */
  32352. reflectivityTexture: BaseTexture;
  32353. /**
  32354. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32355. */
  32356. metallicTexture: BaseTexture;
  32357. /**
  32358. * Specifies the metallic scalar of the metallic/roughness workflow.
  32359. * Can also be used to scale the metalness values of the metallic texture.
  32360. */
  32361. metallic: number;
  32362. /**
  32363. * Specifies the roughness scalar of the metallic/roughness workflow.
  32364. * Can also be used to scale the roughness values of the metallic texture.
  32365. */
  32366. roughness: number;
  32367. /**
  32368. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32369. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32370. */
  32371. microSurfaceTexture: BaseTexture;
  32372. /**
  32373. * Stores surface normal data used to displace a mesh in a texture.
  32374. */
  32375. bumpTexture: BaseTexture;
  32376. /**
  32377. * Stores the pre-calculated light information of a mesh in a texture.
  32378. */
  32379. lightmapTexture: BaseTexture;
  32380. /**
  32381. * Stores the refracted light information in a texture.
  32382. */
  32383. refractionTexture: BaseTexture;
  32384. /**
  32385. * The color of a material in ambient lighting.
  32386. */
  32387. ambientColor: Color3;
  32388. /**
  32389. * AKA Diffuse Color in other nomenclature.
  32390. */
  32391. albedoColor: Color3;
  32392. /**
  32393. * AKA Specular Color in other nomenclature.
  32394. */
  32395. reflectivityColor: Color3;
  32396. /**
  32397. * The color reflected from the material.
  32398. */
  32399. reflectionColor: Color3;
  32400. /**
  32401. * The color emitted from the material.
  32402. */
  32403. emissiveColor: Color3;
  32404. /**
  32405. * AKA Glossiness in other nomenclature.
  32406. */
  32407. microSurface: number;
  32408. /**
  32409. * source material index of refraction (IOR)' / 'destination material IOR.
  32410. */
  32411. indexOfRefraction: number;
  32412. /**
  32413. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32414. */
  32415. invertRefractionY: boolean;
  32416. /**
  32417. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32418. * Materials half opaque for instance using refraction could benefit from this control.
  32419. */
  32420. linkRefractionWithTransparency: boolean;
  32421. useLightmapAsShadowmap: boolean;
  32422. /**
  32423. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32424. */
  32425. useAlphaFromAlbedoTexture: boolean;
  32426. /**
  32427. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32428. */
  32429. forceAlphaTest: boolean;
  32430. /**
  32431. * Defines the alpha limits in alpha test mode.
  32432. */
  32433. alphaCutOff: number;
  32434. /**
  32435. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32436. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32437. */
  32438. useSpecularOverAlpha: boolean;
  32439. /**
  32440. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32441. */
  32442. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32443. /**
  32444. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32445. */
  32446. useRoughnessFromMetallicTextureAlpha: boolean;
  32447. /**
  32448. * Specifies if the metallic texture contains the roughness information in its green channel.
  32449. */
  32450. useRoughnessFromMetallicTextureGreen: boolean;
  32451. /**
  32452. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32453. */
  32454. useMetallnessFromMetallicTextureBlue: boolean;
  32455. /**
  32456. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32457. */
  32458. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32459. /**
  32460. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32461. */
  32462. useAmbientInGrayScale: boolean;
  32463. /**
  32464. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32465. * The material will try to infer what glossiness each pixel should be.
  32466. */
  32467. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32468. /**
  32469. * BJS is using an harcoded light falloff based on a manually sets up range.
  32470. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32471. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32472. */
  32473. usePhysicalLightFalloff: boolean;
  32474. /**
  32475. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32476. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32477. */
  32478. useRadianceOverAlpha: boolean;
  32479. /**
  32480. * Allows using an object space normal map (instead of tangent space).
  32481. */
  32482. useObjectSpaceNormalMap: boolean;
  32483. /**
  32484. * Allows using the bump map in parallax mode.
  32485. */
  32486. useParallax: boolean;
  32487. /**
  32488. * Allows using the bump map in parallax occlusion mode.
  32489. */
  32490. useParallaxOcclusion: boolean;
  32491. /**
  32492. * Controls the scale bias of the parallax mode.
  32493. */
  32494. parallaxScaleBias: number;
  32495. /**
  32496. * If sets to true, disables all the lights affecting the material.
  32497. */
  32498. disableLighting: boolean;
  32499. /**
  32500. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32501. */
  32502. forceIrradianceInFragment: boolean;
  32503. /**
  32504. * Number of Simultaneous lights allowed on the material.
  32505. */
  32506. maxSimultaneousLights: number;
  32507. /**
  32508. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32509. */
  32510. invertNormalMapX: boolean;
  32511. /**
  32512. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32513. */
  32514. invertNormalMapY: boolean;
  32515. /**
  32516. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32517. */
  32518. twoSidedLighting: boolean;
  32519. /**
  32520. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32521. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32522. */
  32523. useAlphaFresnel: boolean;
  32524. /**
  32525. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32526. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32527. */
  32528. useLinearAlphaFresnel: boolean;
  32529. /**
  32530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32531. * And/Or occlude the blended part.
  32532. */
  32533. environmentBRDFTexture: Nullable<BaseTexture>;
  32534. /**
  32535. * Force normal to face away from face.
  32536. */
  32537. forceNormalForward: boolean;
  32538. /**
  32539. * Enables specular anti aliasing in the PBR shader.
  32540. * It will both interacts on the Geometry for analytical and IBL lighting.
  32541. * It also prefilter the roughness map based on the bump values.
  32542. */
  32543. enableSpecularAntiAliasing: boolean;
  32544. /**
  32545. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32546. * makes the reflect vector face the model (under horizon).
  32547. */
  32548. useHorizonOcclusion: boolean;
  32549. /**
  32550. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32551. * too much the area relying on ambient texture to define their ambient occlusion.
  32552. */
  32553. useRadianceOcclusion: boolean;
  32554. /**
  32555. * If set to true, no lighting calculations will be applied.
  32556. */
  32557. unlit: boolean;
  32558. /**
  32559. * Gets the image processing configuration used either in this material.
  32560. */
  32561. /**
  32562. * Sets the Default image processing configuration used either in the this material.
  32563. *
  32564. * If sets to null, the scene one is in use.
  32565. */
  32566. imageProcessingConfiguration: ImageProcessingConfiguration;
  32567. /**
  32568. * Gets wether the color curves effect is enabled.
  32569. */
  32570. /**
  32571. * Sets wether the color curves effect is enabled.
  32572. */
  32573. cameraColorCurvesEnabled: boolean;
  32574. /**
  32575. * Gets wether the color grading effect is enabled.
  32576. */
  32577. /**
  32578. * Gets wether the color grading effect is enabled.
  32579. */
  32580. cameraColorGradingEnabled: boolean;
  32581. /**
  32582. * Gets wether tonemapping is enabled or not.
  32583. */
  32584. /**
  32585. * Sets wether tonemapping is enabled or not
  32586. */
  32587. cameraToneMappingEnabled: boolean;
  32588. /**
  32589. * The camera exposure used on this material.
  32590. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32591. * This corresponds to a photographic exposure.
  32592. */
  32593. /**
  32594. * The camera exposure used on this material.
  32595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32596. * This corresponds to a photographic exposure.
  32597. */
  32598. cameraExposure: number;
  32599. /**
  32600. * Gets The camera contrast used on this material.
  32601. */
  32602. /**
  32603. * Sets The camera contrast used on this material.
  32604. */
  32605. cameraContrast: number;
  32606. /**
  32607. * Gets the Color Grading 2D Lookup Texture.
  32608. */
  32609. /**
  32610. * Sets the Color Grading 2D Lookup Texture.
  32611. */
  32612. cameraColorGradingTexture: Nullable<BaseTexture>;
  32613. /**
  32614. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32615. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32616. * 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;
  32617. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32618. */
  32619. /**
  32620. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32622. * 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;
  32623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32624. */
  32625. cameraColorCurves: Nullable<ColorCurves>;
  32626. /**
  32627. * Instantiates a new PBRMaterial instance.
  32628. *
  32629. * @param name The material name
  32630. * @param scene The scene the material will be use in.
  32631. */
  32632. constructor(name: string, scene: Scene);
  32633. /**
  32634. * Returns the name of this material class.
  32635. */
  32636. getClassName(): string;
  32637. /**
  32638. * Returns an array of the actively used textures.
  32639. * @returns - Array of BaseTextures
  32640. */
  32641. getActiveTextures(): BaseTexture[];
  32642. /**
  32643. * Checks to see if a texture is used in the material.
  32644. * @param texture - Base texture to use.
  32645. * @returns - Boolean specifying if a texture is used in the material.
  32646. */
  32647. hasTexture(texture: BaseTexture): boolean;
  32648. /**
  32649. * Makes a duplicate of the current material.
  32650. * @param name - name to use for the new material.
  32651. */
  32652. clone(name: string): PBRMaterial;
  32653. /**
  32654. * Serializes this PBR Material.
  32655. * @returns - An object with the serialized material.
  32656. */
  32657. serialize(): any;
  32658. /**
  32659. * Parses a PBR Material from a serialized object.
  32660. * @param source - Serialized object.
  32661. * @param scene - BJS scene instance.
  32662. * @param rootUrl - url for the scene object
  32663. * @returns - PBRMaterial
  32664. */
  32665. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32666. }
  32667. }
  32668. declare module BABYLON {
  32669. /**
  32670. * The PBR material of BJS following the metal roughness convention.
  32671. *
  32672. * This fits to the PBR convention in the GLTF definition:
  32673. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32674. */
  32675. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32676. /**
  32677. * The base color has two different interpretations depending on the value of metalness.
  32678. * When the material is a metal, the base color is the specific measured reflectance value
  32679. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32680. * of the material.
  32681. */
  32682. baseColor: Color3;
  32683. /**
  32684. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32685. * well as opacity information in the alpha channel.
  32686. */
  32687. baseTexture: BaseTexture;
  32688. /**
  32689. * Specifies the metallic scalar value of the material.
  32690. * Can also be used to scale the metalness values of the metallic texture.
  32691. */
  32692. metallic: number;
  32693. /**
  32694. * Specifies the roughness scalar value of the material.
  32695. * Can also be used to scale the roughness values of the metallic texture.
  32696. */
  32697. roughness: number;
  32698. /**
  32699. * Texture containing both the metallic value in the B channel and the
  32700. * roughness value in the G channel to keep better precision.
  32701. */
  32702. metallicRoughnessTexture: BaseTexture;
  32703. /**
  32704. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32705. *
  32706. * @param name The material name
  32707. * @param scene The scene the material will be use in.
  32708. */
  32709. constructor(name: string, scene: Scene);
  32710. /**
  32711. * Return the currrent class name of the material.
  32712. */
  32713. getClassName(): string;
  32714. /**
  32715. * Return the active textures of the material.
  32716. */
  32717. getActiveTextures(): BaseTexture[];
  32718. /**
  32719. * Checks to see if a texture is used in the material.
  32720. * @param texture - Base texture to use.
  32721. * @returns - Boolean specifying if a texture is used in the material.
  32722. */
  32723. hasTexture(texture: BaseTexture): boolean;
  32724. /**
  32725. * Makes a duplicate of the current material.
  32726. * @param name - name to use for the new material.
  32727. */
  32728. clone(name: string): PBRMetallicRoughnessMaterial;
  32729. /**
  32730. * Serialize the material to a parsable JSON object.
  32731. */
  32732. serialize(): any;
  32733. /**
  32734. * Parses a JSON object correponding to the serialize function.
  32735. */
  32736. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32737. }
  32738. }
  32739. declare module BABYLON {
  32740. /**
  32741. * The PBR material of BJS following the specular glossiness convention.
  32742. *
  32743. * This fits to the PBR convention in the GLTF definition:
  32744. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32745. */
  32746. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32747. /**
  32748. * Specifies the diffuse color of the material.
  32749. */
  32750. diffuseColor: Color3;
  32751. /**
  32752. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32753. * channel.
  32754. */
  32755. diffuseTexture: BaseTexture;
  32756. /**
  32757. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32758. */
  32759. specularColor: Color3;
  32760. /**
  32761. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32762. */
  32763. glossiness: number;
  32764. /**
  32765. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32766. */
  32767. specularGlossinessTexture: BaseTexture;
  32768. /**
  32769. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32770. *
  32771. * @param name The material name
  32772. * @param scene The scene the material will be use in.
  32773. */
  32774. constructor(name: string, scene: Scene);
  32775. /**
  32776. * Return the currrent class name of the material.
  32777. */
  32778. getClassName(): string;
  32779. /**
  32780. * Return the active textures of the material.
  32781. */
  32782. getActiveTextures(): BaseTexture[];
  32783. /**
  32784. * Checks to see if a texture is used in the material.
  32785. * @param texture - Base texture to use.
  32786. * @returns - Boolean specifying if a texture is used in the material.
  32787. */
  32788. hasTexture(texture: BaseTexture): boolean;
  32789. /**
  32790. * Makes a duplicate of the current material.
  32791. * @param name - name to use for the new material.
  32792. */
  32793. clone(name: string): PBRSpecularGlossinessMaterial;
  32794. /**
  32795. * Serialize the material to a parsable JSON object.
  32796. */
  32797. serialize(): any;
  32798. /**
  32799. * Parses a JSON object correponding to the serialize function.
  32800. */
  32801. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32802. }
  32803. }
  32804. declare module BABYLON {
  32805. class BaseTexture {
  32806. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32807. name: string;
  32808. private _hasAlpha;
  32809. hasAlpha: boolean;
  32810. getAlphaFromRGB: boolean;
  32811. level: number;
  32812. coordinatesIndex: number;
  32813. private _coordinatesMode;
  32814. /**
  32815. * How a texture is mapped.
  32816. *
  32817. * | Value | Type | Description |
  32818. * | ----- | ----------------------------------- | ----------- |
  32819. * | 0 | EXPLICIT_MODE | |
  32820. * | 1 | SPHERICAL_MODE | |
  32821. * | 2 | PLANAR_MODE | |
  32822. * | 3 | CUBIC_MODE | |
  32823. * | 4 | PROJECTION_MODE | |
  32824. * | 5 | SKYBOX_MODE | |
  32825. * | 6 | INVCUBIC_MODE | |
  32826. * | 7 | EQUIRECTANGULAR_MODE | |
  32827. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32828. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32829. */
  32830. coordinatesMode: number;
  32831. /**
  32832. * | Value | Type | Description |
  32833. * | ----- | ------------------ | ----------- |
  32834. * | 0 | CLAMP_ADDRESSMODE | |
  32835. * | 1 | WRAP_ADDRESSMODE | |
  32836. * | 2 | MIRROR_ADDRESSMODE | |
  32837. */
  32838. wrapU: number;
  32839. /**
  32840. * | Value | Type | Description |
  32841. * | ----- | ------------------ | ----------- |
  32842. * | 0 | CLAMP_ADDRESSMODE | |
  32843. * | 1 | WRAP_ADDRESSMODE | |
  32844. * | 2 | MIRROR_ADDRESSMODE | |
  32845. */
  32846. wrapV: number;
  32847. /**
  32848. * | Value | Type | Description |
  32849. * | ----- | ------------------ | ----------- |
  32850. * | 0 | CLAMP_ADDRESSMODE | |
  32851. * | 1 | WRAP_ADDRESSMODE | |
  32852. * | 2 | MIRROR_ADDRESSMODE | |
  32853. */
  32854. wrapR: number;
  32855. anisotropicFilteringLevel: number;
  32856. isCube: boolean;
  32857. is3D: boolean;
  32858. gammaSpace: boolean;
  32859. invertZ: boolean;
  32860. lodLevelInAlpha: boolean;
  32861. lodGenerationOffset: number;
  32862. lodGenerationScale: number;
  32863. isRenderTarget: boolean;
  32864. readonly uid: string;
  32865. toString(): string;
  32866. getClassName(): string;
  32867. animations: Animation[];
  32868. /**
  32869. * An event triggered when the texture is disposed.
  32870. */
  32871. onDisposeObservable: Observable<BaseTexture>;
  32872. private _onDisposeObserver;
  32873. onDispose: () => void;
  32874. delayLoadState: number;
  32875. private _scene;
  32876. private _uid;
  32877. readonly isBlocking: boolean;
  32878. constructor(scene: Nullable<Scene>);
  32879. getScene(): Nullable<Scene>;
  32880. getTextureMatrix(): Matrix;
  32881. getReflectionTextureMatrix(): Matrix;
  32882. getInternalTexture(): Nullable<InternalTexture>;
  32883. isReadyOrNotBlocking(): boolean;
  32884. isReady(): boolean;
  32885. getSize(): ISize;
  32886. getBaseSize(): ISize;
  32887. scale(ratio: number): void;
  32888. readonly canRescale: boolean;
  32889. delayLoad(): void;
  32890. clone(): Nullable<BaseTexture>;
  32891. readonly textureType: number;
  32892. readonly textureFormat: number;
  32893. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32894. releaseInternalTexture(): void;
  32895. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32896. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  32897. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  32898. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  32899. dispose(): void;
  32900. serialize(): any;
  32901. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32902. }
  32903. }
  32904. declare module BABYLON {
  32905. /**
  32906. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32907. * It can help converting any input color in a desired output one. This can then be used to create effects
  32908. * from sepia, black and white to sixties or futuristic rendering...
  32909. *
  32910. * The only supported format is currently 3dl.
  32911. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32912. */
  32913. class ColorGradingTexture extends BaseTexture {
  32914. /**
  32915. * The current texture matrix. (will always be identity in color grading texture)
  32916. */
  32917. private _textureMatrix;
  32918. /**
  32919. * The texture URL.
  32920. */
  32921. url: string;
  32922. /**
  32923. * Empty line regex stored for GC.
  32924. */
  32925. private static _noneEmptyLineRegex;
  32926. private _engine;
  32927. /**
  32928. * Instantiates a ColorGradingTexture from the following parameters.
  32929. *
  32930. * @param url The location of the color gradind data (currently only supporting 3dl)
  32931. * @param scene The scene the texture will be used in
  32932. */
  32933. constructor(url: string, scene: Scene);
  32934. /**
  32935. * Returns the texture matrix used in most of the material.
  32936. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32937. */
  32938. getTextureMatrix(): Matrix;
  32939. /**
  32940. * Occurs when the file being loaded is a .3dl LUT file.
  32941. */
  32942. private load3dlTexture();
  32943. /**
  32944. * Starts the loading process of the texture.
  32945. */
  32946. private loadTexture();
  32947. /**
  32948. * Clones the color gradind texture.
  32949. */
  32950. clone(): ColorGradingTexture;
  32951. /**
  32952. * Called during delayed load for textures.
  32953. */
  32954. delayLoad(): void;
  32955. /**
  32956. * Parses a color grading texture serialized by Babylon.
  32957. * @param parsedTexture The texture information being parsedTexture
  32958. * @param scene The scene to load the texture in
  32959. * @param rootUrl The root url of the data assets to load
  32960. * @return A color gradind texture
  32961. */
  32962. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32963. /**
  32964. * Serializes the LUT texture to json format.
  32965. */
  32966. serialize(): any;
  32967. }
  32968. }
  32969. declare module BABYLON {
  32970. class CubeTexture extends BaseTexture {
  32971. url: string;
  32972. coordinatesMode: number;
  32973. /**
  32974. * Gets or sets the center of the bounding box associated with the cube texture
  32975. * It must define where the camera used to render the texture was set
  32976. */
  32977. boundingBoxPosition: Vector3;
  32978. private _boundingBoxSize;
  32979. /**
  32980. * Gets or sets the size of the bounding box associated with the cube texture
  32981. * When defined, the cubemap will switch to local mode
  32982. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32983. * @example https://www.babylonjs-playground.com/#RNASML
  32984. */
  32985. boundingBoxSize: Vector3;
  32986. protected _rotationY: number;
  32987. /**
  32988. * Gets texture matrix rotation angle around Y axis radians.
  32989. */
  32990. /**
  32991. * Sets texture matrix rotation angle around Y axis in radians.
  32992. */
  32993. rotationY: number;
  32994. private _noMipmap;
  32995. private _files;
  32996. private _extensions;
  32997. private _textureMatrix;
  32998. private _format;
  32999. private _prefiltered;
  33000. private _createPolynomials;
  33001. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33002. /**
  33003. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33004. * @param url defines the url of the prefiltered texture
  33005. * @param scene defines the scene the texture is attached to
  33006. * @param forcedExtension defines the extension of the file if different from the url
  33007. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33008. * @return the prefiltered texture
  33009. */
  33010. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33011. /**
  33012. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33013. * as prefiltered data.
  33014. * @param rootUrl defines the url of the texture or the root name of the six images
  33015. * @param scene defines the scene the texture is attached to
  33016. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33017. * @param noMipmap defines if mipmaps should be created or not
  33018. * @param files defines the six files to load for the different faces
  33019. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33020. * @param onError defines a callback triggered in case of error during load
  33021. * @param format defines the internal format to use for the texture once loaded
  33022. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33023. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33024. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33025. * @return the cube texture
  33026. */
  33027. 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);
  33028. delayLoad(): void;
  33029. getReflectionTextureMatrix(): Matrix;
  33030. setReflectionTextureMatrix(value: Matrix): void;
  33031. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33032. clone(): CubeTexture;
  33033. }
  33034. }
  33035. declare module BABYLON {
  33036. /**
  33037. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33038. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33039. */
  33040. class DynamicTexture extends Texture {
  33041. private _generateMipMaps;
  33042. private _canvas;
  33043. private _context;
  33044. private _engine;
  33045. /**
  33046. * Creates a {BABYLON.DynamicTexture}
  33047. * @param name defines the name of the texture
  33048. * @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
  33049. * @param scene defines the scene where you want the texture
  33050. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33051. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33052. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33053. */
  33054. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33055. /**
  33056. * Gets the current state of canRescale
  33057. */
  33058. readonly canRescale: boolean;
  33059. private _recreate(textureSize);
  33060. /**
  33061. * Scales the texture
  33062. * @param ratio the scale factor to apply to both width and height
  33063. */
  33064. scale(ratio: number): void;
  33065. /**
  33066. * Resizes the texture
  33067. * @param width the new width
  33068. * @param height the new height
  33069. */
  33070. scaleTo(width: number, height: number): void;
  33071. /**
  33072. * Gets the context of the canvas used by the texture
  33073. * @returns the canvas context of the dynamic texture
  33074. */
  33075. getContext(): CanvasRenderingContext2D;
  33076. /**
  33077. * Clears the texture
  33078. */
  33079. clear(): void;
  33080. /**
  33081. * Updates the texture
  33082. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33083. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33084. */
  33085. update(invertY?: boolean, premulAlpha?: boolean): void;
  33086. /**
  33087. * Draws text onto the texture
  33088. * @param text defines the text to be drawn
  33089. * @param x defines the placement of the text from the left
  33090. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33091. * @param font defines the font to be used with font-style, font-size, font-name
  33092. * @param color defines the color used for the text
  33093. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33094. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33095. * @param update defines whether texture is immediately update (default is true)
  33096. */
  33097. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33098. /**
  33099. * Clones the texture
  33100. * @returns the clone of the texture.
  33101. */
  33102. clone(): DynamicTexture;
  33103. /** @hidden */
  33104. }
  33105. }
  33106. declare module BABYLON {
  33107. /**
  33108. * This represents a texture coming from an HDR input.
  33109. *
  33110. * The only supported format is currently panorama picture stored in RGBE format.
  33111. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33112. */
  33113. class HDRCubeTexture extends BaseTexture {
  33114. private static _facesMapping;
  33115. private _generateHarmonics;
  33116. private _noMipmap;
  33117. private _textureMatrix;
  33118. private _size;
  33119. private _onLoad;
  33120. private _onError;
  33121. /**
  33122. * The texture URL.
  33123. */
  33124. url: string;
  33125. /**
  33126. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33127. */
  33128. coordinatesMode: number;
  33129. protected _isBlocking: boolean;
  33130. /**
  33131. * Gets wether or not the texture is blocking during loading.
  33132. */
  33133. /**
  33134. * Sets wether or not the texture is blocking during loading.
  33135. */
  33136. isBlocking: boolean;
  33137. protected _rotationY: number;
  33138. /**
  33139. * Gets texture matrix rotation angle around Y axis radians.
  33140. */
  33141. /**
  33142. * Sets texture matrix rotation angle around Y axis in radians.
  33143. */
  33144. rotationY: number;
  33145. /**
  33146. * Gets or sets the center of the bounding box associated with the cube texture
  33147. * It must define where the camera used to render the texture was set
  33148. */
  33149. boundingBoxPosition: Vector3;
  33150. private _boundingBoxSize;
  33151. /**
  33152. * Gets or sets the size of the bounding box associated with the cube texture
  33153. * When defined, the cubemap will switch to local mode
  33154. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33155. * @example https://www.babylonjs-playground.com/#RNASML
  33156. */
  33157. boundingBoxSize: Vector3;
  33158. /**
  33159. * Instantiates an HDRTexture from the following parameters.
  33160. *
  33161. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33162. * @param scene The scene the texture will be used in
  33163. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33164. * @param noMipmap Forces to not generate the mipmap if true
  33165. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33166. * @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)
  33167. * @param reserved Reserved flag for internal use.
  33168. */
  33169. 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>);
  33170. /**
  33171. * Occurs when the file is raw .hdr file.
  33172. */
  33173. private loadTexture();
  33174. clone(): HDRCubeTexture;
  33175. delayLoad(): void;
  33176. getReflectionTextureMatrix(): Matrix;
  33177. setReflectionTextureMatrix(value: Matrix): void;
  33178. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33179. serialize(): any;
  33180. }
  33181. }
  33182. declare module BABYLON {
  33183. /**
  33184. * Class used to store data associated with WebGL texture data for the engine
  33185. * This class should not be used directly
  33186. */
  33187. class InternalTexture implements IInternalTextureTracker {
  33188. /**
  33189. * The source of the texture data is unknown
  33190. */
  33191. static DATASOURCE_UNKNOWN: number;
  33192. /**
  33193. * Texture data comes from an URL
  33194. */
  33195. static DATASOURCE_URL: number;
  33196. /**
  33197. * Texture data is only used for temporary storage
  33198. */
  33199. static DATASOURCE_TEMP: number;
  33200. /**
  33201. * Texture data comes from raw data (ArrayBuffer)
  33202. */
  33203. static DATASOURCE_RAW: number;
  33204. /**
  33205. * Texture content is dynamic (video or dynamic texture)
  33206. */
  33207. static DATASOURCE_DYNAMIC: number;
  33208. /**
  33209. * Texture content is generated by rendering to it
  33210. */
  33211. static DATASOURCE_RENDERTARGET: number;
  33212. /**
  33213. * Texture content is part of a multi render target process
  33214. */
  33215. static DATASOURCE_MULTIRENDERTARGET: number;
  33216. /**
  33217. * Texture data comes from a cube data file
  33218. */
  33219. static DATASOURCE_CUBE: number;
  33220. /**
  33221. * Texture data comes from a raw cube data
  33222. */
  33223. static DATASOURCE_CUBERAW: number;
  33224. /**
  33225. * Texture data come from a prefiltered cube data file
  33226. */
  33227. static DATASOURCE_CUBEPREFILTERED: number;
  33228. /**
  33229. * Texture content is raw 3D data
  33230. */
  33231. static DATASOURCE_RAW3D: number;
  33232. /**
  33233. * Texture content is a depth texture
  33234. */
  33235. static DATASOURCE_DEPTHTEXTURE: number;
  33236. /**
  33237. * Defines if the texture is ready
  33238. */
  33239. isReady: boolean;
  33240. /**
  33241. * Defines if the texture is a cube texture
  33242. */
  33243. isCube: boolean;
  33244. /**
  33245. * Defines if the texture contains 3D data
  33246. */
  33247. is3D: boolean;
  33248. /**
  33249. * Gets the URL used to load this texture
  33250. */
  33251. url: string;
  33252. /**
  33253. * Gets the sampling mode of the texture
  33254. */
  33255. samplingMode: number;
  33256. /**
  33257. * Gets a boolean indicating if the texture needs mipmaps generation
  33258. */
  33259. generateMipMaps: boolean;
  33260. /**
  33261. * Gets the number of samples used by the texture (WebGL2+ only)
  33262. */
  33263. samples: number;
  33264. /**
  33265. * Gets the type of the texture
  33266. */
  33267. type: number;
  33268. /**
  33269. * Gets the format of the texture
  33270. */
  33271. format: number;
  33272. /**
  33273. * Observable called when the texture is loaded
  33274. */
  33275. onLoadedObservable: Observable<InternalTexture>;
  33276. /**
  33277. * Gets the width of the texture
  33278. */
  33279. width: number;
  33280. /**
  33281. * Gets the height of the texture
  33282. */
  33283. height: number;
  33284. /**
  33285. * Gets the depth of the texture
  33286. */
  33287. depth: number;
  33288. /**
  33289. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33290. */
  33291. baseWidth: number;
  33292. /**
  33293. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33294. */
  33295. baseHeight: number;
  33296. /**
  33297. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33298. */
  33299. baseDepth: number;
  33300. /**
  33301. * Gets a boolean indicating if the texture is inverted on Y axis
  33302. */
  33303. invertY: boolean;
  33304. /**
  33305. * Gets or set the previous tracker in the list
  33306. */
  33307. previous: Nullable<IInternalTextureTracker>;
  33308. /**
  33309. * Gets or set the next tracker in the list
  33310. */
  33311. next: Nullable<IInternalTextureTracker>;
  33312. /** @hidden */
  33313. /** @hidden */
  33314. /** @hidden */
  33315. /** @hidden */
  33316. /** @hidden */
  33317. /** @hidden */
  33318. /** @hidden */
  33319. /** @hidden */
  33320. /** @hidden */
  33321. /** @hidden */
  33322. /** @hidden */
  33323. /** @hidden */
  33324. /** @hidden */
  33325. /** @hidden */
  33326. /** @hidden */
  33327. /** @hidden */
  33328. /** @hidden */
  33329. /** @hidden */
  33330. /** @hidden */
  33331. /** @hidden */
  33332. /** @hidden */
  33333. /** @hidden */
  33334. /** @hidden */
  33335. /** @hidden */
  33336. /** @hidden */
  33337. /** @hidden */
  33338. /** @hidden */
  33339. /** @hidden */
  33340. /** @hidden */
  33341. /** @hidden */
  33342. /** @hidden */
  33343. /** @hidden */
  33344. /** @hidden */
  33345. /** @hidden */
  33346. private _engine;
  33347. /**
  33348. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33349. */
  33350. readonly dataSource: number;
  33351. /**
  33352. * Creates a new InternalTexture
  33353. * @param engine defines the engine to use
  33354. * @param dataSource defines the type of data that will be used
  33355. */
  33356. constructor(engine: Engine, dataSource: number);
  33357. /**
  33358. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33359. */
  33360. incrementReferences(): void;
  33361. /**
  33362. * Change the size of the texture (not the size of the content)
  33363. * @param width defines the new width
  33364. * @param height defines the new height
  33365. * @param depth defines the new depth (1 by default)
  33366. */
  33367. updateSize(width: int, height: int, depth?: int): void;
  33368. /** @hidden */
  33369. private _swapAndDie(target);
  33370. /**
  33371. * Dispose the current allocated resources
  33372. */
  33373. dispose(): void;
  33374. }
  33375. }
  33376. declare module BABYLON {
  33377. /**
  33378. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33379. */
  33380. interface IInternalTextureTracker {
  33381. /**
  33382. * Gets or set the previous tracker in the list
  33383. */
  33384. previous: Nullable<IInternalTextureTracker>;
  33385. /**
  33386. * Gets or set the next tracker in the list
  33387. */
  33388. next: Nullable<IInternalTextureTracker>;
  33389. }
  33390. /**
  33391. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33392. */
  33393. class DummyInternalTextureTracker {
  33394. /**
  33395. * Gets or set the previous tracker in the list
  33396. */
  33397. previous: Nullable<IInternalTextureTracker>;
  33398. /**
  33399. * Gets or set the next tracker in the list
  33400. */
  33401. next: Nullable<IInternalTextureTracker>;
  33402. }
  33403. }
  33404. declare module BABYLON {
  33405. class MirrorTexture extends RenderTargetTexture {
  33406. private scene;
  33407. mirrorPlane: Plane;
  33408. private _transformMatrix;
  33409. private _mirrorMatrix;
  33410. private _savedViewMatrix;
  33411. private _blurX;
  33412. private _blurY;
  33413. private _adaptiveBlurKernel;
  33414. private _blurKernelX;
  33415. private _blurKernelY;
  33416. private _blurRatio;
  33417. blurRatio: number;
  33418. adaptiveBlurKernel: number;
  33419. blurKernel: number;
  33420. blurKernelX: number;
  33421. blurKernelY: number;
  33422. private _autoComputeBlurKernel();
  33423. protected _onRatioRescale(): void;
  33424. private _updateGammaSpace();
  33425. private _imageProcessingConfigChangeObserver;
  33426. constructor(name: string, size: number | {
  33427. width: number;
  33428. height: number;
  33429. } | {
  33430. ratio: number;
  33431. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33432. private _preparePostProcesses();
  33433. clone(): MirrorTexture;
  33434. serialize(): any;
  33435. dispose(): void;
  33436. }
  33437. }
  33438. declare module BABYLON {
  33439. interface IMultiRenderTargetOptions {
  33440. generateMipMaps?: boolean;
  33441. types?: number[];
  33442. samplingModes?: number[];
  33443. generateDepthBuffer?: boolean;
  33444. generateStencilBuffer?: boolean;
  33445. generateDepthTexture?: boolean;
  33446. textureCount?: number;
  33447. doNotChangeAspectRatio?: boolean;
  33448. defaultType?: number;
  33449. }
  33450. class MultiRenderTarget extends RenderTargetTexture {
  33451. private _internalTextures;
  33452. private _textures;
  33453. readonly isSupported: boolean;
  33454. private _multiRenderTargetOptions;
  33455. readonly textures: Texture[];
  33456. readonly depthTexture: Texture;
  33457. wrapU: number;
  33458. wrapV: number;
  33459. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33460. private _createInternalTextures();
  33461. private _createTextures();
  33462. samples: number;
  33463. resize(size: any): void;
  33464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33465. dispose(): void;
  33466. releaseInternalTextures(): void;
  33467. }
  33468. }
  33469. declare module BABYLON {
  33470. class RawTexture extends Texture {
  33471. format: number;
  33472. private _engine;
  33473. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33474. update(data: ArrayBufferView): void;
  33475. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33476. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33477. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33478. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33479. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33480. }
  33481. }
  33482. declare module BABYLON {
  33483. /**
  33484. * Class used to store 3D textures containing user data
  33485. */
  33486. class RawTexture3D extends Texture {
  33487. /** Gets or sets the texture format to use */
  33488. format: number;
  33489. private _engine;
  33490. /**
  33491. * Create a new RawTexture3D
  33492. * @param data defines the data of the texture
  33493. * @param width defines the width of the texture
  33494. * @param height defines the height of the texture
  33495. * @param depth defines the depth of the texture
  33496. * @param format defines the texture format to use
  33497. * @param scene defines the hosting scene
  33498. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33499. * @param invertY defines if texture must be stored with Y axis inverted
  33500. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33501. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33502. */
  33503. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33504. /** Gets or sets the texture format to use */
  33505. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  33506. /**
  33507. * Update the texture with new data
  33508. * @param data defines the data to store in the texture
  33509. */
  33510. update(data: ArrayBufferView): void;
  33511. }
  33512. }
  33513. declare module BABYLON {
  33514. /**
  33515. * Creates a refraction texture used by refraction channel of the standard material.
  33516. * @param name the texture name
  33517. * @param size size of the underlying texture
  33518. * @param scene root scene
  33519. */
  33520. class RefractionTexture extends RenderTargetTexture {
  33521. refractionPlane: Plane;
  33522. depth: number;
  33523. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33524. clone(): RefractionTexture;
  33525. serialize(): any;
  33526. }
  33527. }
  33528. declare module BABYLON {
  33529. class RenderTargetTexture extends Texture {
  33530. isCube: boolean;
  33531. private static _REFRESHRATE_RENDER_ONCE: number;
  33532. private static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33533. private static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33534. static readonly REFRESHRATE_RENDER_ONCE: number;
  33535. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33536. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33537. /**
  33538. * Use this predicate to dynamically define the list of mesh you want to render.
  33539. * If set, the renderList property will be overwritten.
  33540. */
  33541. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33542. /**
  33543. * Use this list to define the list of mesh you want to render.
  33544. */
  33545. renderList: Nullable<Array<AbstractMesh>>;
  33546. renderParticles: boolean;
  33547. renderSprites: boolean;
  33548. coordinatesMode: number;
  33549. activeCamera: Nullable<Camera>;
  33550. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33551. useCameraPostProcesses: boolean;
  33552. ignoreCameraViewport: boolean;
  33553. private _postProcessManager;
  33554. private _postProcesses;
  33555. private _resizeObserver;
  33556. /**
  33557. * An event triggered when the texture is unbind.
  33558. */
  33559. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33560. /**
  33561. * An event triggered when the texture is unbind.
  33562. */
  33563. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33564. private _onAfterUnbindObserver;
  33565. onAfterUnbind: () => void;
  33566. /**
  33567. * An event triggered before rendering the texture
  33568. */
  33569. onBeforeRenderObservable: Observable<number>;
  33570. private _onBeforeRenderObserver;
  33571. onBeforeRender: (faceIndex: number) => void;
  33572. /**
  33573. * An event triggered after rendering the texture
  33574. */
  33575. onAfterRenderObservable: Observable<number>;
  33576. private _onAfterRenderObserver;
  33577. onAfterRender: (faceIndex: number) => void;
  33578. /**
  33579. * An event triggered after the texture clear
  33580. */
  33581. onClearObservable: Observable<Engine>;
  33582. private _onClearObserver;
  33583. onClear: (Engine: Engine) => void;
  33584. clearColor: Color4;
  33585. protected _size: number | {
  33586. width: number;
  33587. height: number;
  33588. };
  33589. protected _initialSizeParameter: number | {
  33590. width: number;
  33591. height: number;
  33592. } | {
  33593. ratio: number;
  33594. };
  33595. protected _sizeRatio: Nullable<number>;
  33596. protected _renderingManager: RenderingManager;
  33597. protected _doNotChangeAspectRatio: boolean;
  33598. protected _currentRefreshId: number;
  33599. protected _refreshRate: number;
  33600. protected _textureMatrix: Matrix;
  33601. protected _samples: number;
  33602. protected _renderTargetOptions: RenderTargetCreationOptions;
  33603. readonly renderTargetOptions: RenderTargetCreationOptions;
  33604. protected _engine: Engine;
  33605. protected _onRatioRescale(): void;
  33606. /**
  33607. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33608. * It must define where the camera used to render the texture is set
  33609. */
  33610. boundingBoxPosition: Vector3;
  33611. private _boundingBoxSize;
  33612. /**
  33613. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33614. * When defined, the cubemap will switch to local mode
  33615. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33616. * @example https://www.babylonjs-playground.com/#RNASML
  33617. */
  33618. boundingBoxSize: Vector3;
  33619. /**
  33620. * In case the RTT has been created with a depth texture, get the associated
  33621. * depth texture.
  33622. * Otherwise, return null.
  33623. */
  33624. depthStencilTexture: Nullable<InternalTexture>;
  33625. /**
  33626. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33627. * or used a shadow, depth texture...
  33628. * @param name The friendly name of the texture
  33629. * @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)
  33630. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33631. * @param generateMipMaps True if mip maps need to be generated after render.
  33632. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33633. * @param type The type of the buffer in the RTT (int, half float, float...)
  33634. * @param isCube True if a cube texture needs to be created
  33635. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33636. * @param generateDepthBuffer True to generate a depth buffer
  33637. * @param generateStencilBuffer True to generate a stencil buffer
  33638. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33639. */
  33640. constructor(name: string, size: number | {
  33641. width: number;
  33642. height: number;
  33643. } | {
  33644. ratio: number;
  33645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33646. /**
  33647. * Creates a depth stencil texture.
  33648. * This is only available in WebGL 2 or with the depth texture extension available.
  33649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33652. */
  33653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33654. private _processSizeParameter(size);
  33655. samples: number;
  33656. resetRefreshCounter(): void;
  33657. refreshRate: number;
  33658. addPostProcess(postProcess: PostProcess): void;
  33659. clearPostProcesses(dispose?: boolean): void;
  33660. removePostProcess(postProcess: PostProcess): void;
  33661. getRenderSize(): number;
  33662. getRenderWidth(): number;
  33663. getRenderHeight(): number;
  33664. readonly canRescale: boolean;
  33665. scale(ratio: number): void;
  33666. getReflectionTextureMatrix(): Matrix;
  33667. resize(size: number | {
  33668. width: number;
  33669. height: number;
  33670. } | {
  33671. ratio: number;
  33672. }): void;
  33673. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33674. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33675. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33676. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33677. /**
  33678. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33679. * This allowed control for front to back rendering or reversly depending of the special needs.
  33680. *
  33681. * @param renderingGroupId The rendering group id corresponding to its index
  33682. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33683. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33684. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33685. */
  33686. 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;
  33687. /**
  33688. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33689. *
  33690. * @param renderingGroupId The rendering group id corresponding to its index
  33691. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33692. */
  33693. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33694. clone(): RenderTargetTexture;
  33695. serialize(): any;
  33696. disposeFramebufferObjects(): void;
  33697. dispose(): void;
  33698. /**
  33699. * Clear the info related to rendering groups preventing retention point in material dispose.
  33700. */
  33701. freeRenderingGroups(): void;
  33702. }
  33703. }
  33704. declare module BABYLON {
  33705. class Texture extends BaseTexture {
  33706. static NEAREST_SAMPLINGMODE: number;
  33707. static NEAREST_NEAREST_MIPLINEAR: number;
  33708. static BILINEAR_SAMPLINGMODE: number;
  33709. static LINEAR_LINEAR_MIPNEAREST: number;
  33710. static TRILINEAR_SAMPLINGMODE: number;
  33711. static LINEAR_LINEAR_MIPLINEAR: number;
  33712. static NEAREST_NEAREST_MIPNEAREST: number;
  33713. static NEAREST_LINEAR_MIPNEAREST: number;
  33714. static NEAREST_LINEAR_MIPLINEAR: number;
  33715. static NEAREST_LINEAR: number;
  33716. static NEAREST_NEAREST: number;
  33717. static LINEAR_NEAREST_MIPNEAREST: number;
  33718. static LINEAR_NEAREST_MIPLINEAR: number;
  33719. static LINEAR_LINEAR: number;
  33720. static LINEAR_NEAREST: number;
  33721. static EXPLICIT_MODE: number;
  33722. static SPHERICAL_MODE: number;
  33723. static PLANAR_MODE: number;
  33724. static CUBIC_MODE: number;
  33725. static PROJECTION_MODE: number;
  33726. static SKYBOX_MODE: number;
  33727. static INVCUBIC_MODE: number;
  33728. static EQUIRECTANGULAR_MODE: number;
  33729. static FIXED_EQUIRECTANGULAR_MODE: number;
  33730. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33731. static CLAMP_ADDRESSMODE: number;
  33732. static WRAP_ADDRESSMODE: number;
  33733. static MIRROR_ADDRESSMODE: number;
  33734. /**
  33735. * 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
  33736. */
  33737. static UseSerializedUrlIfAny: boolean;
  33738. url: Nullable<string>;
  33739. uOffset: number;
  33740. vOffset: number;
  33741. uScale: number;
  33742. vScale: number;
  33743. uAng: number;
  33744. vAng: number;
  33745. wAng: number;
  33746. /**
  33747. * Defines the center of rotation (U)
  33748. */
  33749. uRotationCenter: number;
  33750. /**
  33751. * Defines the center of rotation (V)
  33752. */
  33753. vRotationCenter: number;
  33754. /**
  33755. * Defines the center of rotation (W)
  33756. */
  33757. wRotationCenter: number;
  33758. readonly noMipmap: boolean;
  33759. private _noMipmap;
  33760. private _rowGenerationMatrix;
  33761. private _cachedTextureMatrix;
  33762. private _projectionModeMatrix;
  33763. private _t0;
  33764. private _t1;
  33765. private _t2;
  33766. private _cachedUOffset;
  33767. private _cachedVOffset;
  33768. private _cachedUScale;
  33769. private _cachedVScale;
  33770. private _cachedUAng;
  33771. private _cachedVAng;
  33772. private _cachedWAng;
  33773. private _cachedProjectionMatrixId;
  33774. private _cachedCoordinatesMode;
  33775. /** @hidden */
  33776. private _deleteBuffer;
  33777. protected _format: Nullable<number>;
  33778. private _delayedOnLoad;
  33779. private _delayedOnError;
  33780. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33781. protected _isBlocking: boolean;
  33782. isBlocking: boolean;
  33783. readonly samplingMode: number;
  33784. 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);
  33785. /**
  33786. * Update the url (and optional buffer) of this texture if url was null during construction.
  33787. * @param url the url of the texture
  33788. * @param buffer the buffer of the texture (defaults to null)
  33789. */
  33790. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  33791. delayLoad(): void;
  33792. updateSamplingMode(samplingMode: number): void;
  33793. private _prepareRowForTextureGeneration(x, y, z, t);
  33794. getTextureMatrix(): Matrix;
  33795. getReflectionTextureMatrix(): Matrix;
  33796. clone(): Texture;
  33797. readonly onLoadObservable: Observable<Texture>;
  33798. serialize(): any;
  33799. getClassName(): string;
  33800. dispose(): void;
  33801. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33803. 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;
  33804. }
  33805. }
  33806. declare module BABYLON {
  33807. /**
  33808. * Settings for finer control over video usage
  33809. */
  33810. interface VideoTextureSettings {
  33811. /**
  33812. * Applies `autoplay` to video, if specified
  33813. */
  33814. autoPlay?: boolean;
  33815. /**
  33816. * Applies `loop` to video, if specified
  33817. */
  33818. loop?: boolean;
  33819. /**
  33820. * Automatically updates internal texture from video at every frame in the render loop
  33821. */
  33822. autoUpdateTexture: boolean;
  33823. }
  33824. class VideoTexture extends Texture {
  33825. /**
  33826. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33827. */
  33828. readonly autoUpdateTexture: boolean;
  33829. /**
  33830. * The video instance used by the texture internally
  33831. */
  33832. readonly video: HTMLVideoElement;
  33833. private _generateMipMaps;
  33834. private _engine;
  33835. private _stillImageCaptured;
  33836. /**
  33837. * Creates a video texture.
  33838. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33839. * @param {string | null} name optional name, will detect from video source, if not defined
  33840. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33841. * @param {BABYLON.Scene} scene is obviously the current scene.
  33842. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33843. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33844. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33845. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33846. */
  33847. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33848. private _getName(src);
  33849. private _getVideo(src);
  33850. private _createInternalTexture;
  33851. private reset;
  33852. /**
  33853. * Internal method to initiate `update`.
  33854. */
  33855. /**
  33856. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33857. */
  33858. update(): void;
  33859. /**
  33860. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33861. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33862. */
  33863. updateTexture(isVisible: boolean): void;
  33864. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33865. /**
  33866. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33867. * @param url New url.
  33868. */
  33869. updateURL(url: string): void;
  33870. dispose(): void;
  33871. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33872. minWidth: number;
  33873. maxWidth: number;
  33874. minHeight: number;
  33875. maxHeight: number;
  33876. deviceId: string;
  33877. }): void;
  33878. }
  33879. }
  33880. declare module BABYLON {
  33881. /**
  33882. * Particle emitter emitting particles from the inside of a box.
  33883. * It emits the particles randomly between 2 given directions.
  33884. */
  33885. class BoxParticleEmitter implements IParticleEmitterType {
  33886. /**
  33887. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33888. */
  33889. direction1: Vector3;
  33890. /**
  33891. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33892. */
  33893. direction2: Vector3;
  33894. /**
  33895. * 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.
  33896. */
  33897. minEmitBox: Vector3;
  33898. /**
  33899. * 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.
  33900. */
  33901. maxEmitBox: Vector3;
  33902. /**
  33903. * Creates a new instance BoxParticleEmitter
  33904. */
  33905. constructor();
  33906. /**
  33907. * Called by the particle System when the direction is computed for the created particle.
  33908. * @param emitPower is the power of the particle (speed)
  33909. * @param worldMatrix is the world matrix of the particle system
  33910. * @param directionToUpdate is the direction vector to update with the result
  33911. * @param particle is the particle we are computed the direction for
  33912. */
  33913. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33914. /**
  33915. * Called by the particle System when the position is computed for the created particle.
  33916. * @param worldMatrix is the world matrix of the particle system
  33917. * @param positionToUpdate is the position vector to update with the result
  33918. * @param particle is the particle we are computed the position for
  33919. */
  33920. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33921. /**
  33922. * Clones the current emitter and returns a copy of it
  33923. * @returns the new emitter
  33924. */
  33925. clone(): BoxParticleEmitter;
  33926. /**
  33927. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33928. * @param effect defines the update shader
  33929. */
  33930. applyToShader(effect: Effect): void;
  33931. /**
  33932. * Returns a string to use to update the GPU particles update shader
  33933. * @returns a string containng the defines string
  33934. */
  33935. getEffectDefines(): string;
  33936. /**
  33937. * Returns the string "BoxEmitter"
  33938. * @returns a string containing the class name
  33939. */
  33940. getClassName(): string;
  33941. /**
  33942. * Serializes the particle system to a JSON object.
  33943. * @returns the JSON object
  33944. */
  33945. serialize(): any;
  33946. /**
  33947. * Parse properties from a JSON object
  33948. * @param serializationObject defines the JSON object
  33949. */
  33950. parse(serializationObject: any): void;
  33951. }
  33952. }
  33953. declare module BABYLON {
  33954. /**
  33955. * Particle emitter emitting particles from the inside of a cone.
  33956. * It emits the particles alongside the cone volume from the base to the particle.
  33957. * The emission direction might be randomized.
  33958. */
  33959. class ConeParticleEmitter implements IParticleEmitterType {
  33960. /**
  33961. * The radius of the emission cone.
  33962. */
  33963. angle: number;
  33964. /**
  33965. * The cone base angle.
  33966. */
  33967. directionRandomizer: number;
  33968. private _radius;
  33969. private _height;
  33970. /**
  33971. * Gets the radius of the emission cone.
  33972. */
  33973. /**
  33974. * Sets the radius of the emission cone.
  33975. */
  33976. radius: number;
  33977. /**
  33978. * Creates a new instance ConeParticleEmitter
  33979. * @param radius the radius of the emission cone (1 by default)
  33980. * @param angles the cone base angle (PI by default)
  33981. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33982. */
  33983. constructor(radius?: number,
  33984. /**
  33985. * The radius of the emission cone.
  33986. */
  33987. angle?: number,
  33988. /**
  33989. * The cone base angle.
  33990. */
  33991. directionRandomizer?: number);
  33992. /**
  33993. * Called by the particle System when the direction is computed for the created particle.
  33994. * @param emitPower is the power of the particle (speed)
  33995. * @param worldMatrix is the world matrix of the particle system
  33996. * @param directionToUpdate is the direction vector to update with the result
  33997. * @param particle is the particle we are computed the direction for
  33998. */
  33999. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34000. /**
  34001. * Called by the particle System when the position is computed for the created particle.
  34002. * @param worldMatrix is the world matrix of the particle system
  34003. * @param positionToUpdate is the position vector to update with the result
  34004. * @param particle is the particle we are computed the position for
  34005. */
  34006. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34007. /**
  34008. * Clones the current emitter and returns a copy of it
  34009. * @returns the new emitter
  34010. */
  34011. clone(): ConeParticleEmitter;
  34012. /**
  34013. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34014. * @param effect defines the update shader
  34015. */
  34016. applyToShader(effect: Effect): void;
  34017. /**
  34018. * Returns a string to use to update the GPU particles update shader
  34019. * @returns a string containng the defines string
  34020. */
  34021. getEffectDefines(): string;
  34022. /**
  34023. * Returns the string "BoxEmitter"
  34024. * @returns a string containing the class name
  34025. */
  34026. getClassName(): string;
  34027. /**
  34028. * Serializes the particle system to a JSON object.
  34029. * @returns the JSON object
  34030. */
  34031. serialize(): any;
  34032. /**
  34033. * Parse properties from a JSON object
  34034. * @param serializationObject defines the JSON object
  34035. */
  34036. parse(serializationObject: any): void;
  34037. }
  34038. }
  34039. declare module BABYLON {
  34040. /**
  34041. * Particle emitter represents a volume emitting particles.
  34042. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34043. */
  34044. interface IParticleEmitterType {
  34045. /**
  34046. * Called by the particle System when the direction is computed for the created particle.
  34047. * @param emitPower is the power of the particle (speed)
  34048. * @param worldMatrix is the world matrix of the particle system
  34049. * @param directionToUpdate is the direction vector to update with the result
  34050. * @param particle is the particle we are computed the direction for
  34051. */
  34052. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34053. /**
  34054. * Called by the particle System when the position is computed for the created particle.
  34055. * @param worldMatrix is the world matrix of the particle system
  34056. * @param positionToUpdate is the position vector to update with the result
  34057. * @param particle is the particle we are computed the position for
  34058. */
  34059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34060. /**
  34061. * Clones the current emitter and returns a copy of it
  34062. * @returns the new emitter
  34063. */
  34064. clone(): IParticleEmitterType;
  34065. /**
  34066. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34067. * @param effect defines the update shader
  34068. */
  34069. applyToShader(effect: Effect): void;
  34070. /**
  34071. * Returns a string to use to update the GPU particles update shader
  34072. * @returns the effect defines string
  34073. */
  34074. getEffectDefines(): string;
  34075. /**
  34076. * Returns a string representing the class name
  34077. * @returns a string containing the class name
  34078. */
  34079. getClassName(): string;
  34080. /**
  34081. * Serializes the particle system to a JSON object.
  34082. * @returns the JSON object
  34083. */
  34084. serialize(): any;
  34085. /**
  34086. * Parse properties from a JSON object
  34087. * @param serializationObject defines the JSON object
  34088. */
  34089. parse(serializationObject: any): void;
  34090. }
  34091. }
  34092. declare module BABYLON {
  34093. /**
  34094. * Particle emitter emitting particles from the inside of a sphere.
  34095. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34096. */
  34097. class SphereParticleEmitter implements IParticleEmitterType {
  34098. /**
  34099. * The radius of the emission sphere.
  34100. */
  34101. radius: number;
  34102. /**
  34103. * How much to randomize the particle direction [0-1].
  34104. */
  34105. directionRandomizer: number;
  34106. /**
  34107. * Creates a new instance SphereParticleEmitter
  34108. * @param radius the radius of the emission sphere (1 by default)
  34109. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34110. */
  34111. constructor(
  34112. /**
  34113. * The radius of the emission sphere.
  34114. */
  34115. radius?: number,
  34116. /**
  34117. * How much to randomize the particle direction [0-1].
  34118. */
  34119. directionRandomizer?: number);
  34120. /**
  34121. * Called by the particle System when the direction is computed for the created particle.
  34122. * @param emitPower is the power of the particle (speed)
  34123. * @param worldMatrix is the world matrix of the particle system
  34124. * @param directionToUpdate is the direction vector to update with the result
  34125. * @param particle is the particle we are computed the direction for
  34126. */
  34127. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34128. /**
  34129. * Called by the particle System when the position is computed for the created particle.
  34130. * @param worldMatrix is the world matrix of the particle system
  34131. * @param positionToUpdate is the position vector to update with the result
  34132. * @param particle is the particle we are computed the position for
  34133. */
  34134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34135. /**
  34136. * Clones the current emitter and returns a copy of it
  34137. * @returns the new emitter
  34138. */
  34139. clone(): SphereParticleEmitter;
  34140. /**
  34141. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34142. * @param effect defines the update shader
  34143. */
  34144. applyToShader(effect: Effect): void;
  34145. /**
  34146. * Returns a string to use to update the GPU particles update shader
  34147. * @returns a string containng the defines string
  34148. */
  34149. getEffectDefines(): string;
  34150. /**
  34151. * Returns the string "SphereParticleEmitter"
  34152. * @returns a string containing the class name
  34153. */
  34154. getClassName(): string;
  34155. /**
  34156. * Serializes the particle system to a JSON object.
  34157. * @returns the JSON object
  34158. */
  34159. serialize(): any;
  34160. /**
  34161. * Parse properties from a JSON object
  34162. * @param serializationObject defines the JSON object
  34163. */
  34164. parse(serializationObject: any): void;
  34165. }
  34166. /**
  34167. * Particle emitter emitting particles from the inside of a sphere.
  34168. * It emits the particles randomly between two vectors.
  34169. */
  34170. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34171. /**
  34172. * The min limit of the emission direction.
  34173. */
  34174. direction1: Vector3;
  34175. /**
  34176. * The max limit of the emission direction.
  34177. */
  34178. direction2: Vector3;
  34179. /**
  34180. * Creates a new instance SphereDirectedParticleEmitter
  34181. * @param radius the radius of the emission sphere (1 by default)
  34182. * @param direction1 the min limit of the emission direction (up vector by default)
  34183. * @param direction2 the max limit of the emission direction (up vector by default)
  34184. */
  34185. constructor(radius?: number,
  34186. /**
  34187. * The min limit of the emission direction.
  34188. */
  34189. direction1?: Vector3,
  34190. /**
  34191. * The max limit of the emission direction.
  34192. */
  34193. direction2?: Vector3);
  34194. /**
  34195. * Called by the particle System when the direction is computed for the created particle.
  34196. * @param emitPower is the power of the particle (speed)
  34197. * @param worldMatrix is the world matrix of the particle system
  34198. * @param directionToUpdate is the direction vector to update with the result
  34199. * @param particle is the particle we are computed the direction for
  34200. */
  34201. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34202. /**
  34203. * Clones the current emitter and returns a copy of it
  34204. * @returns the new emitter
  34205. */
  34206. clone(): SphereDirectedParticleEmitter;
  34207. /**
  34208. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34209. * @param effect defines the update shader
  34210. */
  34211. applyToShader(effect: Effect): void;
  34212. /**
  34213. * Returns a string to use to update the GPU particles update shader
  34214. * @returns a string containng the defines string
  34215. */
  34216. getEffectDefines(): string;
  34217. /**
  34218. * Returns the string "SphereDirectedParticleEmitter"
  34219. * @returns a string containing the class name
  34220. */
  34221. getClassName(): string;
  34222. /**
  34223. * Serializes the particle system to a JSON object.
  34224. * @returns the JSON object
  34225. */
  34226. serialize(): any;
  34227. /**
  34228. * Parse properties from a JSON object
  34229. * @param serializationObject defines the JSON object
  34230. */
  34231. parse(serializationObject: any): void;
  34232. }
  34233. }
  34234. declare var DracoDecoderModule: any;
  34235. declare var WebAssembly: any;
  34236. declare module BABYLON {
  34237. /**
  34238. * Configuration for Draco compression
  34239. */
  34240. interface IDracoCompressionConfiguration {
  34241. /**
  34242. * Configuration for the decoder.
  34243. */
  34244. decoder?: {
  34245. /**
  34246. * The url to the WebAssembly module.
  34247. */
  34248. wasmUrl?: string;
  34249. /**
  34250. * The url to the WebAssembly binary.
  34251. */
  34252. wasmBinaryUrl?: string;
  34253. /**
  34254. * The url to the fallback JavaScript module.
  34255. */
  34256. fallbackUrl?: string;
  34257. };
  34258. }
  34259. /**
  34260. * Draco compression (https://google.github.io/draco/)
  34261. *
  34262. * This class wraps the Draco module.
  34263. *
  34264. * **Encoder**
  34265. *
  34266. * The encoder is not currently implemented.
  34267. *
  34268. * **Decoder**
  34269. *
  34270. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34271. *
  34272. * To update the configuration, use the following code:
  34273. * ```javascript
  34274. * BABYLON.DracoCompression.Configuration = {
  34275. * decoder: {
  34276. * wasmUrl: "<url to the WebAssembly library>",
  34277. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34278. * fallbackUrl: "<url to the fallback JavaScript library>",
  34279. * }
  34280. * };
  34281. * ```
  34282. *
  34283. * 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.
  34284. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34285. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34286. *
  34287. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34288. * ```javascript
  34289. * var dracoCompression = new BABYLON.DracoCompression();
  34290. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34291. * [BABYLON.VertexBuffer.PositionKind]: 0
  34292. * });
  34293. * ```
  34294. *
  34295. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34296. */
  34297. class DracoCompression implements IDisposable {
  34298. private static _DecoderModulePromise;
  34299. /**
  34300. * The configuration. Defaults to the following urls:
  34301. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34302. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34303. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34304. */
  34305. static Configuration: IDracoCompressionConfiguration;
  34306. /**
  34307. * Returns true if the decoder is available.
  34308. */
  34309. static readonly DecoderAvailable: boolean;
  34310. /**
  34311. * Constructor
  34312. */
  34313. constructor();
  34314. /**
  34315. * Stop all async operations and release resources.
  34316. */
  34317. dispose(): void;
  34318. /**
  34319. * Decode Draco compressed mesh data to vertex data.
  34320. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34321. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34322. * @returns A promise that resolves with the decoded vertex data
  34323. */
  34324. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34325. [kind: string]: number;
  34326. }): Promise<VertexData>;
  34327. private static _GetDecoderModule();
  34328. private static _LoadScriptAsync(url);
  34329. private static _LoadFileAsync(url);
  34330. }
  34331. }
  34332. declare module BABYLON {
  34333. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34334. private _useDeltaForWorldStep;
  34335. world: any;
  34336. name: string;
  34337. private _physicsMaterials;
  34338. private _fixedTimeStep;
  34339. BJSCANNON: any;
  34340. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34341. setGravity(gravity: Vector3): void;
  34342. setTimeStep(timeStep: number): void;
  34343. getTimeStep(): number;
  34344. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34348. private _processChildMeshes(mainImpostor);
  34349. removePhysicsBody(impostor: PhysicsImpostor): void;
  34350. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34351. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34352. private _addMaterial(name, friction, restitution);
  34353. private _checkWithEpsilon(value);
  34354. private _createShape(impostor);
  34355. private _createHeightmap(object, pointDepth?);
  34356. private _minus90X;
  34357. private _plus90X;
  34358. private _tmpPosition;
  34359. private _tmpDeltaPosition;
  34360. private _tmpUnityRotation;
  34361. private _updatePhysicsBodyTransformation(impostor);
  34362. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34363. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34364. isSupported(): boolean;
  34365. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34366. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34367. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34368. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34369. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34370. getBodyMass(impostor: PhysicsImpostor): number;
  34371. getBodyFriction(impostor: PhysicsImpostor): number;
  34372. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34373. getBodyRestitution(impostor: PhysicsImpostor): number;
  34374. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34375. sleepBody(impostor: PhysicsImpostor): void;
  34376. wakeUpBody(impostor: PhysicsImpostor): void;
  34377. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34378. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34381. getRadius(impostor: PhysicsImpostor): number;
  34382. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34383. dispose(): void;
  34384. private _extendNamespace();
  34385. }
  34386. }
  34387. declare module BABYLON {
  34388. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34389. world: any;
  34390. name: string;
  34391. BJSOIMO: any;
  34392. constructor(iterations?: number);
  34393. setGravity(gravity: Vector3): void;
  34394. setTimeStep(timeStep: number): void;
  34395. getTimeStep(): number;
  34396. private _tmpImpostorsArray;
  34397. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34398. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34399. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34400. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34401. private _tmpPositionVector;
  34402. removePhysicsBody(impostor: PhysicsImpostor): void;
  34403. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34404. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34405. isSupported(): boolean;
  34406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34413. getBodyMass(impostor: PhysicsImpostor): number;
  34414. getBodyFriction(impostor: PhysicsImpostor): number;
  34415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34416. getBodyRestitution(impostor: PhysicsImpostor): number;
  34417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34418. sleepBody(impostor: PhysicsImpostor): void;
  34419. wakeUpBody(impostor: PhysicsImpostor): void;
  34420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34421. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34424. getRadius(impostor: PhysicsImpostor): number;
  34425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34426. dispose(): void;
  34427. }
  34428. }
  34429. declare module BABYLON {
  34430. /**
  34431. * This represents a set of one or more post processes in Babylon.
  34432. * A post process can be used to apply a shader to a texture after it is rendered.
  34433. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34434. */
  34435. class PostProcessRenderEffect {
  34436. private _postProcesses;
  34437. private _getPostProcesses;
  34438. private _singleInstance;
  34439. private _cameras;
  34440. private _indicesForCamera;
  34441. /**
  34442. * Name of the effect
  34443. */
  34444. /**
  34445. * Instantiates a post process render effect.
  34446. * A post process can be used to apply a shader to a texture after it is rendered.
  34447. * @param engine The engine the effect is tied to
  34448. * @param name The name of the effect
  34449. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34450. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34451. */
  34452. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34453. /**
  34454. * Checks if all the post processes in the effect are supported.
  34455. */
  34456. readonly isSupported: boolean;
  34457. /**
  34458. * Updates the current state of the effect
  34459. */
  34460. /**
  34461. * Attaches the effect on cameras
  34462. * @param cameras The camera to attach to.
  34463. */
  34464. /**
  34465. * Attaches the effect on cameras
  34466. * @param cameras The camera to attach to.
  34467. */
  34468. /**
  34469. * Detatches the effect on cameras
  34470. * @param cameras The camera to detatch from.
  34471. */
  34472. /**
  34473. * Detatches the effect on cameras
  34474. * @param cameras The camera to detatch from.
  34475. */
  34476. /**
  34477. * Enables the effect on given cameras
  34478. * @param cameras The camera to enable.
  34479. */
  34480. /**
  34481. * Enables the effect on given cameras
  34482. * @param cameras The camera to enable.
  34483. */
  34484. /**
  34485. * Disables the effect on the given cameras
  34486. * @param cameras The camera to disable.
  34487. */
  34488. /**
  34489. * Disables the effect on the given cameras
  34490. * @param cameras The camera to disable.
  34491. */
  34492. /**
  34493. * Gets a list of the post processes contained in the effect.
  34494. * @param camera The camera to get the post processes on.
  34495. * @returns The list of the post processes in the effect.
  34496. */
  34497. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34498. }
  34499. }
  34500. declare module BABYLON {
  34501. class PostProcessRenderPipeline {
  34502. private engine;
  34503. private _renderEffects;
  34504. private _renderEffectsForIsolatedPass;
  34505. protected _cameras: Camera[];
  34506. constructor(engine: Engine, name: string);
  34507. getClassName(): string;
  34508. readonly isSupported: boolean;
  34509. addEffect(renderEffect: PostProcessRenderEffect): void;
  34510. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34511. dispose(): void;
  34512. }
  34513. }
  34514. declare module BABYLON {
  34515. class PostProcessRenderPipelineManager {
  34516. private _renderPipelines;
  34517. constructor();
  34518. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34519. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34520. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34521. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34522. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34523. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34524. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34525. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34526. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34527. update(): void;
  34528. dispose(): void;
  34529. }
  34530. }
  34531. declare module BABYLON {
  34532. /**
  34533. * Helper class dealing with the extraction of spherical polynomial dataArray
  34534. * from a cube map.
  34535. */
  34536. class CubeMapToSphericalPolynomialTools {
  34537. private static FileFaces;
  34538. /**
  34539. * Converts a texture to the according Spherical Polynomial data.
  34540. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34541. *
  34542. * @param texture The texture to extract the information from.
  34543. * @return The Spherical Polynomial data.
  34544. */
  34545. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34546. /**
  34547. * Converts a cubemap to the according Spherical Polynomial data.
  34548. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34549. *
  34550. * @param cubeInfo The Cube map to extract the information from.
  34551. * @return The Spherical Polynomial data.
  34552. */
  34553. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34554. }
  34555. }
  34556. declare module BABYLON {
  34557. /**
  34558. * Header information of HDR texture files.
  34559. */
  34560. interface HDRInfo {
  34561. /**
  34562. * The height of the texture in pixels.
  34563. */
  34564. height: number;
  34565. /**
  34566. * The width of the texture in pixels.
  34567. */
  34568. width: number;
  34569. /**
  34570. * The index of the beginning of the data in the binary file.
  34571. */
  34572. dataPosition: number;
  34573. }
  34574. /**
  34575. * This groups tools to convert HDR texture to native colors array.
  34576. */
  34577. class HDRTools {
  34578. private static Ldexp(mantissa, exponent);
  34579. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34580. private static readStringLine(uint8array, startIndex);
  34581. /**
  34582. * Reads header information from an RGBE texture stored in a native array.
  34583. * More information on this format are available here:
  34584. * https://en.wikipedia.org/wiki/RGBE_image_format
  34585. *
  34586. * @param uint8array The binary file stored in native array.
  34587. * @return The header information.
  34588. */
  34589. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34590. /**
  34591. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34592. * This RGBE texture needs to store the information as a panorama.
  34593. *
  34594. * More information on this format are available here:
  34595. * https://en.wikipedia.org/wiki/RGBE_image_format
  34596. *
  34597. * @param buffer The binary file stored in an array buffer.
  34598. * @param size The expected size of the extracted cubemap.
  34599. * @return The Cube Map information.
  34600. */
  34601. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34602. /**
  34603. * Returns the pixels data extracted from an RGBE texture.
  34604. * This pixels will be stored left to right up to down in the R G B order in one array.
  34605. *
  34606. * More information on this format are available here:
  34607. * https://en.wikipedia.org/wiki/RGBE_image_format
  34608. *
  34609. * @param uint8array The binary file stored in an array buffer.
  34610. * @param hdrInfo The header information of the file.
  34611. * @return The pixels data in RGB right to left up to down order.
  34612. */
  34613. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34614. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34615. }
  34616. }
  34617. declare module BABYLON {
  34618. /**
  34619. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34620. */
  34621. interface CubeMapInfo {
  34622. /**
  34623. * The pixel array for the front face.
  34624. * This is stored in format, left to right, up to down format.
  34625. */
  34626. front: Nullable<ArrayBufferView>;
  34627. /**
  34628. * The pixel array for the back face.
  34629. * This is stored in format, left to right, up to down format.
  34630. */
  34631. back: Nullable<ArrayBufferView>;
  34632. /**
  34633. * The pixel array for the left face.
  34634. * This is stored in format, left to right, up to down format.
  34635. */
  34636. left: Nullable<ArrayBufferView>;
  34637. /**
  34638. * The pixel array for the right face.
  34639. * This is stored in format, left to right, up to down format.
  34640. */
  34641. right: Nullable<ArrayBufferView>;
  34642. /**
  34643. * The pixel array for the up face.
  34644. * This is stored in format, left to right, up to down format.
  34645. */
  34646. up: Nullable<ArrayBufferView>;
  34647. /**
  34648. * The pixel array for the down face.
  34649. * This is stored in format, left to right, up to down format.
  34650. */
  34651. down: Nullable<ArrayBufferView>;
  34652. /**
  34653. * The size of the cubemap stored.
  34654. *
  34655. * Each faces will be size * size pixels.
  34656. */
  34657. size: number;
  34658. /**
  34659. * The format of the texture.
  34660. *
  34661. * RGBA, RGB.
  34662. */
  34663. format: number;
  34664. /**
  34665. * The type of the texture data.
  34666. *
  34667. * UNSIGNED_INT, FLOAT.
  34668. */
  34669. type: number;
  34670. /**
  34671. * Specifies whether the texture is in gamma space.
  34672. */
  34673. gammaSpace: boolean;
  34674. }
  34675. /**
  34676. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34677. */
  34678. class PanoramaToCubeMapTools {
  34679. private static FACE_FRONT;
  34680. private static FACE_BACK;
  34681. private static FACE_RIGHT;
  34682. private static FACE_LEFT;
  34683. private static FACE_DOWN;
  34684. private static FACE_UP;
  34685. /**
  34686. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34687. *
  34688. * @param float32Array The source data.
  34689. * @param inputWidth The width of the input panorama.
  34690. * @param inputhHeight The height of the input panorama.
  34691. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34692. * @return The cubemap data
  34693. */
  34694. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34695. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34696. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34697. }
  34698. }
  34699. declare module BABYLON {
  34700. class CustomProceduralTexture extends ProceduralTexture {
  34701. private _animate;
  34702. private _time;
  34703. private _config;
  34704. private _texturePath;
  34705. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34706. private loadJson(jsonUrl);
  34707. isReady(): boolean;
  34708. render(useCameraPostProcess?: boolean): void;
  34709. updateTextures(): void;
  34710. updateShaderUniforms(): void;
  34711. animate: boolean;
  34712. }
  34713. }
  34714. declare module BABYLON {
  34715. class ProceduralTexture extends Texture {
  34716. isCube: boolean;
  34717. private _size;
  34718. isEnabled: boolean;
  34719. private _currentRefreshId;
  34720. private _refreshRate;
  34721. onGenerated: () => void;
  34722. private _vertexBuffers;
  34723. private _indexBuffer;
  34724. private _effect;
  34725. private _uniforms;
  34726. private _samplers;
  34727. private _fragment;
  34728. ;
  34729. private _floats;
  34730. private _floatsArrays;
  34731. private _colors3;
  34732. private _colors4;
  34733. private _vectors2;
  34734. private _vectors3;
  34735. private _matrices;
  34736. private _fallbackTexture;
  34737. private _fallbackTextureUsed;
  34738. private _engine;
  34739. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34740. private _createIndexBuffer();
  34741. reset(): void;
  34742. isReady(): boolean;
  34743. resetRefreshCounter(): void;
  34744. setFragment(fragment: any): void;
  34745. refreshRate: number;
  34746. getRenderSize(): number;
  34747. resize(size: number, generateMipMaps: boolean): void;
  34748. private _checkUniform(uniformName);
  34749. setTexture(name: string, texture: Texture): ProceduralTexture;
  34750. setFloat(name: string, value: number): ProceduralTexture;
  34751. setFloats(name: string, value: number[]): ProceduralTexture;
  34752. setColor3(name: string, value: Color3): ProceduralTexture;
  34753. setColor4(name: string, value: Color4): ProceduralTexture;
  34754. setVector2(name: string, value: Vector2): ProceduralTexture;
  34755. setVector3(name: string, value: Vector3): ProceduralTexture;
  34756. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34757. render(useCameraPostProcess?: boolean): void;
  34758. clone(): ProceduralTexture;
  34759. dispose(): void;
  34760. }
  34761. }
  34762. declare module BABYLON {
  34763. /**
  34764. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34765. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34766. */
  34767. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34768. private _scene;
  34769. private _originalCameras;
  34770. /**
  34771. * ID of the sharpen post process,
  34772. */
  34773. private readonly SharpenPostProcessId;
  34774. /**
  34775. * ID of the image processing post process;
  34776. */
  34777. readonly ImageProcessingPostProcessId: string;
  34778. /**
  34779. * ID of the Fast Approximate Anti-Aliasing post process;
  34780. */
  34781. readonly FxaaPostProcessId: string;
  34782. /**
  34783. * ID of the chromatic aberration post process,
  34784. */
  34785. private readonly ChromaticAberrationPostProcessId;
  34786. /**
  34787. * ID of the grain post process
  34788. */
  34789. private readonly GrainPostProcessId;
  34790. /**
  34791. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34792. */
  34793. sharpen: SharpenPostProcess;
  34794. private _sharpenEffect;
  34795. private bloom;
  34796. /**
  34797. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34798. */
  34799. depthOfField: DepthOfFieldEffect;
  34800. /**
  34801. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34802. */
  34803. fxaa: FxaaPostProcess;
  34804. /**
  34805. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34806. */
  34807. imageProcessing: ImageProcessingPostProcess;
  34808. /**
  34809. * Chromatic aberration post process which will shift rgb colors in the image
  34810. */
  34811. chromaticAberration: ChromaticAberrationPostProcess;
  34812. private _chromaticAberrationEffect;
  34813. /**
  34814. * Grain post process which add noise to the image
  34815. */
  34816. grain: GrainPostProcess;
  34817. private _grainEffect;
  34818. /**
  34819. * Glow post process which adds a glow to emmisive areas of the image
  34820. */
  34821. private _glowLayer;
  34822. /**
  34823. * Animations which can be used to tweak settings over a period of time
  34824. */
  34825. animations: Animation[];
  34826. private _imageProcessingConfigurationObserver;
  34827. private _sharpenEnabled;
  34828. private _bloomEnabled;
  34829. private _depthOfFieldEnabled;
  34830. private _depthOfFieldBlurLevel;
  34831. private _fxaaEnabled;
  34832. private _imageProcessingEnabled;
  34833. private _defaultPipelineTextureType;
  34834. private _bloomScale;
  34835. private _chromaticAberrationEnabled;
  34836. private _grainEnabled;
  34837. private _buildAllowed;
  34838. /**
  34839. * Enable or disable the sharpen process from the pipeline
  34840. */
  34841. sharpenEnabled: boolean;
  34842. private _resizeObserver;
  34843. private _hardwareScaleLevel;
  34844. private _bloomKernel;
  34845. /**
  34846. * Specifies the size of the bloom blur kernel, relative to the final output size
  34847. */
  34848. bloomKernel: number;
  34849. /**
  34850. * Specifies the weight of the bloom in the final rendering
  34851. */
  34852. private _bloomWeight;
  34853. /**
  34854. * Specifies the luma threshold for the area that will be blurred by the bloom
  34855. */
  34856. private _bloomThreshold;
  34857. private _hdr;
  34858. /**
  34859. * The strength of the bloom.
  34860. */
  34861. bloomWeight: number;
  34862. /**
  34863. * The strength of the bloom.
  34864. */
  34865. bloomThreshold: number;
  34866. /**
  34867. * The scale of the bloom, lower value will provide better performance.
  34868. */
  34869. bloomScale: number;
  34870. /**
  34871. * Enable or disable the bloom from the pipeline
  34872. */
  34873. bloomEnabled: boolean;
  34874. private _rebuildBloom();
  34875. /**
  34876. * If the depth of field is enabled.
  34877. */
  34878. depthOfFieldEnabled: boolean;
  34879. /**
  34880. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34881. */
  34882. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34883. /**
  34884. * If the anti aliasing is enabled.
  34885. */
  34886. fxaaEnabled: boolean;
  34887. private _samples;
  34888. /**
  34889. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34890. */
  34891. samples: number;
  34892. /**
  34893. * If image processing is enabled.
  34894. */
  34895. imageProcessingEnabled: boolean;
  34896. /**
  34897. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  34898. */
  34899. glowLayerEnabled: boolean;
  34900. /**
  34901. * Enable or disable the chromaticAberration process from the pipeline
  34902. */
  34903. chromaticAberrationEnabled: boolean;
  34904. /**
  34905. * Enable or disable the grain process from the pipeline
  34906. */
  34907. grainEnabled: boolean;
  34908. /**
  34909. * @constructor
  34910. * @param {string} name - The rendering pipeline name (default: "")
  34911. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  34912. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  34913. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  34914. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  34915. */
  34916. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34917. /**
  34918. * Force the compilation of the entire pipeline.
  34919. */
  34920. prepare(): void;
  34921. private _hasCleared;
  34922. private _prevPostProcess;
  34923. private _prevPrevPostProcess;
  34924. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34925. private _buildPipeline();
  34926. private _disposePostProcesses(disposeNonRecreated?);
  34927. /**
  34928. * Dispose of the pipeline and stop all post processes
  34929. */
  34930. dispose(): void;
  34931. /**
  34932. * Serialize the rendering pipeline (Used when exporting)
  34933. * @returns the serialized object
  34934. */
  34935. serialize(): any;
  34936. /**
  34937. * Parse the serialized pipeline
  34938. * @param source Source pipeline.
  34939. * @param scene The scene to load the pipeline to.
  34940. * @param rootUrl The URL of the serialized pipeline.
  34941. * @returns An instantiated pipeline from the serialized object.
  34942. */
  34943. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34944. }
  34945. }
  34946. declare module BABYLON {
  34947. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34948. /**
  34949. * The chromatic aberration PostProcess id in the pipeline
  34950. */
  34951. LensChromaticAberrationEffect: string;
  34952. /**
  34953. * The highlights enhancing PostProcess id in the pipeline
  34954. */
  34955. HighlightsEnhancingEffect: string;
  34956. /**
  34957. * The depth-of-field PostProcess id in the pipeline
  34958. */
  34959. LensDepthOfFieldEffect: string;
  34960. private _scene;
  34961. private _depthTexture;
  34962. private _grainTexture;
  34963. private _chromaticAberrationPostProcess;
  34964. private _highlightsPostProcess;
  34965. private _depthOfFieldPostProcess;
  34966. private _edgeBlur;
  34967. private _grainAmount;
  34968. private _chromaticAberration;
  34969. private _distortion;
  34970. private _highlightsGain;
  34971. private _highlightsThreshold;
  34972. private _dofDistance;
  34973. private _dofAperture;
  34974. private _dofDarken;
  34975. private _dofPentagon;
  34976. private _blurNoise;
  34977. /**
  34978. * @constructor
  34979. *
  34980. * Effect parameters are as follow:
  34981. * {
  34982. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34983. * edge_blur: number; // from 0 to x (1 for realism)
  34984. * distortion: number; // from 0 to x (1 for realism)
  34985. * grain_amount: number; // from 0 to 1
  34986. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34987. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34988. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34989. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34990. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34991. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34992. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34993. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34994. * }
  34995. * Note: if an effect parameter is unset, effect is disabled
  34996. *
  34997. * @param {string} name - The rendering pipeline name
  34998. * @param {object} parameters - An object containing all parameters (see above)
  34999. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35000. * @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)
  35001. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35002. */
  35003. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35004. setEdgeBlur(amount: number): void;
  35005. disableEdgeBlur(): void;
  35006. setGrainAmount(amount: number): void;
  35007. disableGrain(): void;
  35008. setChromaticAberration(amount: number): void;
  35009. disableChromaticAberration(): void;
  35010. setEdgeDistortion(amount: number): void;
  35011. disableEdgeDistortion(): void;
  35012. setFocusDistance(amount: number): void;
  35013. disableDepthOfField(): void;
  35014. setAperture(amount: number): void;
  35015. setDarkenOutOfFocus(amount: number): void;
  35016. enablePentagonBokeh(): void;
  35017. disablePentagonBokeh(): void;
  35018. enableNoiseBlur(): void;
  35019. disableNoiseBlur(): void;
  35020. setHighlightsGain(amount: number): void;
  35021. setHighlightsThreshold(amount: number): void;
  35022. disableHighlights(): void;
  35023. /**
  35024. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35025. */
  35026. dispose(disableDepthRender?: boolean): void;
  35027. private _createChromaticAberrationPostProcess(ratio);
  35028. private _createHighlightsPostProcess(ratio);
  35029. private _createDepthOfFieldPostProcess(ratio);
  35030. private _createGrainTexture();
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35035. /**
  35036. * The PassPostProcess id in the pipeline that contains the original scene color
  35037. */
  35038. SSAOOriginalSceneColorEffect: string;
  35039. /**
  35040. * The SSAO PostProcess id in the pipeline
  35041. */
  35042. SSAORenderEffect: string;
  35043. /**
  35044. * The horizontal blur PostProcess id in the pipeline
  35045. */
  35046. SSAOBlurHRenderEffect: string;
  35047. /**
  35048. * The vertical blur PostProcess id in the pipeline
  35049. */
  35050. SSAOBlurVRenderEffect: string;
  35051. /**
  35052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35053. */
  35054. SSAOCombineRenderEffect: string;
  35055. /**
  35056. * The output strength of the SSAO post-process. Default value is 1.0.
  35057. */
  35058. totalStrength: number;
  35059. /**
  35060. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35061. */
  35062. maxZ: number;
  35063. /**
  35064. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35065. */
  35066. minZAspect: number;
  35067. /**
  35068. * Number of samples used for the SSAO calculations. Default value is 8
  35069. */
  35070. private _samples;
  35071. /**
  35072. * Ratio object used for SSAO ratio and blur ratio
  35073. */
  35074. private _ratio;
  35075. /**
  35076. * Dynamically generated sphere sampler.
  35077. */
  35078. private _sampleSphere;
  35079. /**
  35080. * Blur filter offsets
  35081. */
  35082. private _samplerOffsets;
  35083. samples: number;
  35084. /**
  35085. * Are we using bilateral blur ?
  35086. */
  35087. private _expensiveBlur;
  35088. expensiveBlur: boolean;
  35089. /**
  35090. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35091. */
  35092. radius: number;
  35093. /**
  35094. * The base color of the SSAO post-process
  35095. * The final result is "base + ssao" between [0, 1]
  35096. */
  35097. base: number;
  35098. /**
  35099. * Support test.
  35100. */
  35101. static readonly IsSupported: boolean;
  35102. private _scene;
  35103. private _depthTexture;
  35104. private _normalTexture;
  35105. private _randomTexture;
  35106. private _originalColorPostProcess;
  35107. private _ssaoPostProcess;
  35108. private _blurHPostProcess;
  35109. private _blurVPostProcess;
  35110. private _ssaoCombinePostProcess;
  35111. private _firstUpdate;
  35112. /**
  35113. * @constructor
  35114. * @param {string} name - The rendering pipeline name
  35115. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35116. * @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 }
  35117. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35118. */
  35119. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35120. /**
  35121. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35122. */
  35123. dispose(disableGeometryBufferRenderer?: boolean): void;
  35124. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35125. private _generateHemisphere();
  35126. private _createSSAOPostProcess(ratio);
  35127. private _createSSAOCombinePostProcess(ratio);
  35128. private _createRandomTexture();
  35129. /**
  35130. * Serialize the rendering pipeline (Used when exporting)
  35131. * @returns the serialized object
  35132. */
  35133. serialize(): any;
  35134. /**
  35135. * Parse the serialized pipeline
  35136. * @param source Source pipeline.
  35137. * @param scene The scene to load the pipeline to.
  35138. * @param rootUrl The URL of the serialized pipeline.
  35139. * @returns An instantiated pipeline from the serialized object.
  35140. */
  35141. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35146. /**
  35147. * The PassPostProcess id in the pipeline that contains the original scene color
  35148. */
  35149. SSAOOriginalSceneColorEffect: string;
  35150. /**
  35151. * The SSAO PostProcess id in the pipeline
  35152. */
  35153. SSAORenderEffect: string;
  35154. /**
  35155. * The horizontal blur PostProcess id in the pipeline
  35156. */
  35157. SSAOBlurHRenderEffect: string;
  35158. /**
  35159. * The vertical blur PostProcess id in the pipeline
  35160. */
  35161. SSAOBlurVRenderEffect: string;
  35162. /**
  35163. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35164. */
  35165. SSAOCombineRenderEffect: string;
  35166. /**
  35167. * The output strength of the SSAO post-process. Default value is 1.0.
  35168. */
  35169. totalStrength: number;
  35170. /**
  35171. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35172. */
  35173. radius: number;
  35174. /**
  35175. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35176. * Must not be equal to fallOff and superior to fallOff.
  35177. * Default value is 0.975
  35178. */
  35179. area: number;
  35180. /**
  35181. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35182. * Must not be equal to area and inferior to area.
  35183. * Default value is 0.0
  35184. */
  35185. fallOff: number;
  35186. /**
  35187. * The base color of the SSAO post-process
  35188. * The final result is "base + ssao" between [0, 1]
  35189. */
  35190. base: number;
  35191. private _scene;
  35192. private _depthTexture;
  35193. private _randomTexture;
  35194. private _originalColorPostProcess;
  35195. private _ssaoPostProcess;
  35196. private _blurHPostProcess;
  35197. private _blurVPostProcess;
  35198. private _ssaoCombinePostProcess;
  35199. private _firstUpdate;
  35200. /**
  35201. * @constructor
  35202. * @param {string} name - The rendering pipeline name
  35203. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35204. * @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 }
  35205. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35206. */
  35207. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35208. /**
  35209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35210. */
  35211. dispose(disableDepthRender?: boolean): void;
  35212. private _createBlurPostProcess(ratio);
  35213. private _createSSAOPostProcess(ratio);
  35214. private _createSSAOCombinePostProcess(ratio);
  35215. private _createRandomTexture();
  35216. }
  35217. }
  35218. declare module BABYLON {
  35219. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35220. /**
  35221. * Public members
  35222. */
  35223. originalPostProcess: Nullable<PostProcess>;
  35224. downSampleX4PostProcess: Nullable<PostProcess>;
  35225. brightPassPostProcess: Nullable<PostProcess>;
  35226. blurHPostProcesses: PostProcess[];
  35227. blurVPostProcesses: PostProcess[];
  35228. textureAdderPostProcess: Nullable<PostProcess>;
  35229. volumetricLightPostProcess: Nullable<PostProcess>;
  35230. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  35231. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35232. volumetricLightMergePostProces: Nullable<PostProcess>;
  35233. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35234. luminancePostProcess: Nullable<PostProcess>;
  35235. luminanceDownSamplePostProcesses: PostProcess[];
  35236. hdrPostProcess: Nullable<PostProcess>;
  35237. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35238. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35239. hdrFinalPostProcess: Nullable<PostProcess>;
  35240. lensFlarePostProcess: Nullable<PostProcess>;
  35241. lensFlareComposePostProcess: Nullable<PostProcess>;
  35242. motionBlurPostProcess: Nullable<PostProcess>;
  35243. depthOfFieldPostProcess: Nullable<PostProcess>;
  35244. brightThreshold: number;
  35245. blurWidth: number;
  35246. horizontalBlur: boolean;
  35247. exposure: number;
  35248. lensTexture: Nullable<Texture>;
  35249. volumetricLightCoefficient: number;
  35250. volumetricLightPower: number;
  35251. volumetricLightBlurScale: number;
  35252. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35253. hdrMinimumLuminance: number;
  35254. hdrDecreaseRate: number;
  35255. hdrIncreaseRate: number;
  35256. lensColorTexture: Nullable<Texture>;
  35257. lensFlareStrength: number;
  35258. lensFlareGhostDispersal: number;
  35259. lensFlareHaloWidth: number;
  35260. lensFlareDistortionStrength: number;
  35261. lensStarTexture: Nullable<Texture>;
  35262. lensFlareDirtTexture: Nullable<Texture>;
  35263. depthOfFieldDistance: number;
  35264. depthOfFieldBlurWidth: number;
  35265. motionStrength: number;
  35266. animations: Animation[];
  35267. /**
  35268. * Private members
  35269. */
  35270. private _scene;
  35271. private _currentDepthOfFieldSource;
  35272. private _basePostProcess;
  35273. private _hdrCurrentLuminance;
  35274. private _floatTextureType;
  35275. private _ratio;
  35276. private _bloomEnabled;
  35277. private _depthOfFieldEnabled;
  35278. private _vlsEnabled;
  35279. private _lensFlareEnabled;
  35280. private _hdrEnabled;
  35281. private _motionBlurEnabled;
  35282. private _motionBlurSamples;
  35283. private _volumetricLightStepsCount;
  35284. BloomEnabled: boolean;
  35285. DepthOfFieldEnabled: boolean;
  35286. LensFlareEnabled: boolean;
  35287. HDREnabled: boolean;
  35288. VLSEnabled: boolean;
  35289. MotionBlurEnabled: boolean;
  35290. volumetricLightStepsCount: number;
  35291. motionBlurSamples: number;
  35292. /**
  35293. * @constructor
  35294. * @param {string} name - The rendering pipeline name
  35295. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35296. * @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)
  35297. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35298. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35299. */
  35300. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35301. private _buildPipeline();
  35302. private _createDownSampleX4PostProcess(scene, ratio);
  35303. private _createBrightPassPostProcess(scene, ratio);
  35304. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35305. private _createTextureAdderPostProcess(scene, ratio);
  35306. private _createVolumetricLightPostProcess(scene, ratio);
  35307. private _createLuminancePostProcesses(scene, textureType);
  35308. private _createHdrPostProcess(scene, ratio);
  35309. private _createLensFlarePostProcess(scene, ratio);
  35310. private _createDepthOfFieldPostProcess(scene, ratio);
  35311. private _createMotionBlurPostProcess(scene, ratio);
  35312. private _getDepthTexture();
  35313. private _disposePostProcesses();
  35314. /**
  35315. * Dispose of the pipeline and stop all post processes
  35316. */
  35317. dispose(): void;
  35318. /**
  35319. * Serialize the rendering pipeline (Used when exporting)
  35320. * @returns the serialized object
  35321. */
  35322. serialize(): any;
  35323. /**
  35324. * Parse the serialized pipeline
  35325. * @param source Source pipeline.
  35326. * @param scene The scene to load the pipeline to.
  35327. * @param rootUrl The URL of the serialized pipeline.
  35328. * @returns An instantiated pipeline from the serialized object.
  35329. */
  35330. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35331. static LuminanceSteps: number;
  35332. }
  35333. }
  35334. declare module BABYLON.GUI {
  35335. /**
  35336. * Define a style used by control to automatically setup properties based on a template.
  35337. * Only support font related properties so far
  35338. */
  35339. class Style implements BABYLON.IDisposable {
  35340. private _fontFamily;
  35341. private _fontStyle;
  35342. private _fontWeight;
  35343. /** @hidden */
  35344. /** @hidden */
  35345. /**
  35346. * Observable raised when the style values are changed
  35347. */
  35348. onChangedObservable: Observable<Style>;
  35349. /**
  35350. * Creates a new style object
  35351. * @param host defines the AdvancedDynamicTexture which hosts this style
  35352. */
  35353. constructor(host: AdvancedDynamicTexture);
  35354. /**
  35355. * Gets or sets the font size
  35356. */
  35357. fontSize: string | number;
  35358. /**
  35359. * Gets or sets the font family
  35360. */
  35361. fontFamily: string;
  35362. /**
  35363. * Gets or sets the font style
  35364. */
  35365. fontStyle: string;
  35366. /** Gets or sets font weight */
  35367. fontWeight: string;
  35368. /** Dispose all associated resources */
  35369. dispose(): void;
  35370. }
  35371. }
  35372. declare module BABYLON.GUI {
  35373. /**
  35374. * Class used to specific a value and its associated unit
  35375. */
  35376. class ValueAndUnit {
  35377. /** defines the unit to store */
  35378. unit: number;
  35379. /** defines a boolean indicating if the value can be negative */
  35380. negativeValueAllowed: boolean;
  35381. private _value;
  35382. /**
  35383. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  35384. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  35385. */
  35386. ignoreAdaptiveScaling: boolean;
  35387. /**
  35388. * Creates a new ValueAndUnit
  35389. * @param value defines the value to store
  35390. * @param unit defines the unit to store
  35391. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  35392. */
  35393. constructor(value: number,
  35394. /** defines the unit to store */
  35395. unit?: number,
  35396. /** defines a boolean indicating if the value can be negative */
  35397. negativeValueAllowed?: boolean);
  35398. /** Gets a boolean indicating if the value is a percentage */
  35399. readonly isPercentage: boolean;
  35400. /** Gets a boolean indicating if the value is store as pixel */
  35401. readonly isPixel: boolean;
  35402. /** Gets direct internal value */
  35403. readonly internalValue: number;
  35404. /**
  35405. * Gets value as pixel
  35406. * @param host defines the root host
  35407. * @param refValue defines the reference value for percentages
  35408. * @returns the value as pixel
  35409. */
  35410. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  35411. /**
  35412. * Gets the value accordingly to its unit
  35413. * @param host defines the root host
  35414. * @returns the value
  35415. */
  35416. getValue(host: AdvancedDynamicTexture): number;
  35417. /**
  35418. * Gets a string representation of the value
  35419. * @param host defines the root host
  35420. * @returns a string
  35421. */
  35422. toString(host: AdvancedDynamicTexture): string;
  35423. /**
  35424. * Store a value parsed from a string
  35425. * @param source defines the source string
  35426. * @returns true if the value was successfully parsed
  35427. */
  35428. fromString(source: string | number): boolean;
  35429. private static _Regex;
  35430. private static _UNITMODE_PERCENTAGE;
  35431. private static _UNITMODE_PIXEL;
  35432. /** UNITMODE_PERCENTAGE */
  35433. static readonly UNITMODE_PERCENTAGE: number;
  35434. /** UNITMODE_PIXEL */
  35435. static readonly UNITMODE_PIXEL: number;
  35436. }
  35437. }
  35438. /**
  35439. * This module hosts all controls for 2D and 3D GUIs
  35440. * @see http://doc.babylonjs.com/how_to/gui
  35441. */
  35442. declare module BABYLON.GUI {
  35443. /**
  35444. * Interface used to define a control that can receive focus
  35445. */
  35446. interface IFocusableControl {
  35447. /**
  35448. * Function called when the control receives the focus
  35449. */
  35450. onFocus(): void;
  35451. /**
  35452. * Function called when the control loses the focus
  35453. */
  35454. onBlur(): void;
  35455. /**
  35456. * Function called to let the control handle keyboard events
  35457. * @param evt defines the current keyboard event
  35458. */
  35459. processKeyboard(evt: KeyboardEvent): void;
  35460. }
  35461. /**
  35462. * Class used to create texture to support 2D GUI elements
  35463. * @see http://doc.babylonjs.com/how_to/gui
  35464. */
  35465. class AdvancedDynamicTexture extends DynamicTexture {
  35466. private _isDirty;
  35467. private _renderObserver;
  35468. private _resizeObserver;
  35469. private _preKeyboardObserver;
  35470. private _pointerMoveObserver;
  35471. private _pointerObserver;
  35472. private _canvasPointerOutObserver;
  35473. private _background;
  35474. /** @hidden */
  35475. /** @hidden */
  35476. /** @hidden */
  35477. ;
  35478. /** @hidden */
  35479. ;
  35480. /** @hidden */
  35481. ;
  35482. /** @hidden */
  35483. /** @hidden */
  35484. /** @hidden */
  35485. private _isFullscreen;
  35486. private _fullscreenViewport;
  35487. private _idealWidth;
  35488. private _idealHeight;
  35489. private _useSmallestIdeal;
  35490. private _renderAtIdealSize;
  35491. private _focusedControl;
  35492. private _blockNextFocusCheck;
  35493. private _renderScale;
  35494. /**
  35495. * Gets or sets a boolean defining if alpha is stored as premultiplied
  35496. */
  35497. premulAlpha: boolean;
  35498. /**
  35499. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  35500. * Useful when you want more antialiasing
  35501. */
  35502. renderScale: number;
  35503. /** Gets or sets the background color */
  35504. background: string;
  35505. /**
  35506. * Gets or sets the ideal width used to design controls.
  35507. * The GUI will then rescale everything accordingly
  35508. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  35509. */
  35510. idealWidth: number;
  35511. /**
  35512. * Gets or sets the ideal height used to design controls.
  35513. * The GUI will then rescale everything accordingly
  35514. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  35515. */
  35516. idealHeight: number;
  35517. /**
  35518. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  35519. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  35520. */
  35521. useSmallestIdeal: boolean;
  35522. /**
  35523. * Gets or sets a boolean indicating if adaptive scaling must be used
  35524. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  35525. */
  35526. renderAtIdealSize: boolean;
  35527. /**
  35528. * Gets the underlying layer used to render the texture when in fullscreen mode
  35529. */
  35530. readonly layer: Nullable<Layer>;
  35531. /**
  35532. * Gets the root container control
  35533. */
  35534. readonly rootContainer: Container;
  35535. /**
  35536. * Gets or sets the current focused control
  35537. */
  35538. focusedControl: Nullable<IFocusableControl>;
  35539. /**
  35540. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  35541. */
  35542. isForeground: boolean;
  35543. /**
  35544. * Creates a new AdvancedDynamicTexture
  35545. * @param name defines the name of the texture
  35546. * @param width defines the width of the texture
  35547. * @param height defines the height of the texture
  35548. * @param scene defines the hosting scene
  35549. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  35550. * @param samplingMode defines the texture sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35551. */
  35552. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  35553. /**
  35554. * Function used to execute a function on all controls
  35555. * @param func defines the function to execute
  35556. * @param container defines the container where controls belong. If null the root container will be used
  35557. */
  35558. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  35559. /**
  35560. * Marks the texture as dirty forcing a complete update
  35561. */
  35562. markAsDirty(): void;
  35563. /**
  35564. * Helper function used to create a new style
  35565. * @returns a new style
  35566. * @see http://doc.babylonjs.com/how_to/gui#styles
  35567. */
  35568. createStyle(): Style;
  35569. /**
  35570. * Adds a new control to the root container
  35571. * @param control defines the control to add
  35572. * @returns the current texture
  35573. */
  35574. addControl(control: Control): AdvancedDynamicTexture;
  35575. /**
  35576. * Removes a control from the root container
  35577. * @param control defines the control to remove
  35578. * @returns the current texture
  35579. */
  35580. removeControl(control: Control): AdvancedDynamicTexture;
  35581. /**
  35582. * Release all resources
  35583. */
  35584. dispose(): void;
  35585. private _onResize();
  35586. /** @hidden */
  35587. /**
  35588. * Get screen coordinates for a vector3
  35589. * @param position defines the position to project
  35590. * @param worldMatrix defines the world matrix to use
  35591. * @returns the projected position
  35592. */
  35593. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  35594. private _checkUpdate(camera);
  35595. private _render();
  35596. private _doPicking(x, y, type, pointerId, buttonIndex);
  35597. /** @hidden */
  35598. , control: Control): void;
  35599. /** @hidden */
  35600. /** Attach to all scene events required to support pointer events */
  35601. attach(): void;
  35602. /**
  35603. * Connect the texture to a hosting mesh to enable interactions
  35604. * @param mesh defines the mesh to attach to
  35605. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  35606. */
  35607. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  35608. /**
  35609. * Move the focus to a specific control
  35610. * @param control defines the control which will receive the focus
  35611. */
  35612. moveFocusToControl(control: IFocusableControl): void;
  35613. private _manageFocus();
  35614. private _attachToOnPointerOut(scene);
  35615. /**
  35616. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  35617. * @param mesh defines the mesh which will receive the texture
  35618. * @param width defines the texture width (1024 by default)
  35619. * @param height defines the texture height (1024 by default)
  35620. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  35621. * @returns a new AdvancedDynamicTexture
  35622. */
  35623. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  35624. /**
  35625. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  35626. * In this mode the texture will rely on a layer for its rendering.
  35627. * This allows it to be treated like any other layer.
  35628. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  35629. * LayerMask is set through advancedTexture.layer.layerMask
  35630. * @param name defines name for the texture
  35631. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  35632. * @param scene defines the hsoting scene
  35633. * @param sampling defines the texture sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35634. * @returns a new AdvancedDynamicTexture
  35635. */
  35636. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  35637. }
  35638. }
  35639. declare module BABYLON.GUI {
  35640. /**
  35641. * Class used to store 2D control sizes
  35642. */
  35643. class Measure {
  35644. /** defines left coordinate */
  35645. left: number;
  35646. /** defines top coordinate */
  35647. top: number;
  35648. /** defines width dimension */
  35649. width: number;
  35650. /** defines height dimension */
  35651. height: number;
  35652. /**
  35653. * Creates a new measure
  35654. * @param left defines left coordinate
  35655. * @param top defines top coordinate
  35656. * @param width defines width dimension
  35657. * @param height defines height dimension
  35658. */
  35659. constructor(
  35660. /** defines left coordinate */
  35661. left: number,
  35662. /** defines top coordinate */
  35663. top: number,
  35664. /** defines width dimension */
  35665. width: number,
  35666. /** defines height dimension */
  35667. height: number);
  35668. /**
  35669. * Copy from another measure
  35670. * @param other defines the other measure to copy from
  35671. */
  35672. copyFrom(other: Measure): void;
  35673. /**
  35674. * Check equality between this measure and another one
  35675. * @param other defines the other measures
  35676. * @returns true if both measures are equals
  35677. */
  35678. isEqualsTo(other: Measure): boolean;
  35679. /**
  35680. * Creates an empty measure
  35681. * @returns a new measure
  35682. */
  35683. static Empty(): Measure;
  35684. }
  35685. }
  35686. declare module BABYLON.GUI {
  35687. /**
  35688. * Class used to transport Vector2 information for pointer events
  35689. */
  35690. class Vector2WithInfo extends Vector2 {
  35691. /** defines the current mouse button index */
  35692. buttonIndex: number;
  35693. /**
  35694. * Creates a new Vector2WithInfo
  35695. * @param source defines the vector2 data to transport
  35696. * @param buttonIndex defines the current mouse button index
  35697. */
  35698. constructor(source: Vector2,
  35699. /** defines the current mouse button index */
  35700. buttonIndex?: number);
  35701. }
  35702. /** Class used to provide 2D matrix features */
  35703. class Matrix2D {
  35704. /** Gets the internal array of 6 floats used to store matrix data */
  35705. m: Float32Array;
  35706. /**
  35707. * Creates a new matrix
  35708. * @param m00 defines value for (0, 0)
  35709. * @param m01 defines value for (0, 1)
  35710. * @param m10 defines value for (1, 0)
  35711. * @param m11 defines value for (1, 1)
  35712. * @param m20 defines value for (2, 0)
  35713. * @param m21 defines value for (2, 1)
  35714. */
  35715. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  35716. /**
  35717. * Fills the matrix from direct values
  35718. * @param m00 defines value for (0, 0)
  35719. * @param m01 defines value for (0, 1)
  35720. * @param m10 defines value for (1, 0)
  35721. * @param m11 defines value for (1, 1)
  35722. * @param m20 defines value for (2, 0)
  35723. * @param m21 defines value for (2, 1)
  35724. * @returns the current modified matrix
  35725. */
  35726. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  35727. /**
  35728. * Gets matrix determinant
  35729. * @returns the determinant
  35730. */
  35731. determinant(): number;
  35732. /**
  35733. * Inverses the matrix and stores it in a target matrix
  35734. * @param result defines the target matrix
  35735. * @returns the current matrix
  35736. */
  35737. invertToRef(result: Matrix2D): Matrix2D;
  35738. /**
  35739. * Multiplies the current matrix with another one
  35740. * @param other defines the second operand
  35741. * @param result defines the target matrix
  35742. * @returns the current matrix
  35743. */
  35744. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  35745. /**
  35746. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  35747. * @param x defines the x coordinate to transform
  35748. * @param y defines the x coordinate to transform
  35749. * @param result defines the target vector2
  35750. * @returns the current matrix
  35751. */
  35752. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  35753. /**
  35754. * Creates an identity matrix
  35755. * @returns a new matrix
  35756. */
  35757. static Identity(): Matrix2D;
  35758. /**
  35759. * Creates a translation matrix and stores it in a target matrix
  35760. * @param x defines the x coordinate of the translation
  35761. * @param y defines the y coordinate of the translation
  35762. * @param result defines the target matrix
  35763. */
  35764. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  35765. /**
  35766. * Creates a scaling matrix and stores it in a target matrix
  35767. * @param x defines the x coordinate of the scaling
  35768. * @param y defines the y coordinate of the scaling
  35769. * @param result defines the target matrix
  35770. */
  35771. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  35772. /**
  35773. * Creates a rotation matrix and stores it in a target matrix
  35774. * @param angle defines the rotation angle
  35775. * @param result defines the target matrix
  35776. */
  35777. static RotationToRef(angle: number, result: Matrix2D): void;
  35778. private static _TempPreTranslationMatrix;
  35779. private static _TempPostTranslationMatrix;
  35780. private static _TempRotationMatrix;
  35781. private static _TempScalingMatrix;
  35782. private static _TempCompose0;
  35783. private static _TempCompose1;
  35784. private static _TempCompose2;
  35785. /**
  35786. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  35787. * @param tx defines the x coordinate of the translation
  35788. * @param ty defines the y coordinate of the translation
  35789. * @param angle defines the rotation angle
  35790. * @param scaleX defines the x coordinate of the scaling
  35791. * @param scaleY defines the y coordinate of the scaling
  35792. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  35793. * @param result defines the target matrix
  35794. */
  35795. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  35796. }
  35797. }
  35798. declare module BABYLON.GUI {
  35799. /**
  35800. * Class used to store a point for a MultiLine object.
  35801. * The point can be pure 2D coordinates, a mesh or a control
  35802. */
  35803. class MultiLinePoint {
  35804. private _multiLine;
  35805. private _x;
  35806. private _y;
  35807. private _control;
  35808. private _mesh;
  35809. private _controlObserver;
  35810. private _meshObserver;
  35811. /** @hidden */
  35812. /**
  35813. * Creates a new MultiLinePoint
  35814. * @param multiLine defines the source MultiLine object
  35815. */
  35816. constructor(multiLine: MultiLine);
  35817. /** Gets or sets x coordinate */
  35818. x: string | number;
  35819. /** Gets or sets y coordinate */
  35820. y: string | number;
  35821. /** Gets or sets the control associated with this point */
  35822. control: Nullable<Control>;
  35823. /** Gets or sets the mesh associated with this point */
  35824. mesh: Nullable<AbstractMesh>;
  35825. /**
  35826. * Gets a translation vector
  35827. * @returns the translation vector
  35828. */
  35829. translate(): Vector2;
  35830. private _translatePoint();
  35831. /** Release associated resources */
  35832. dispose(): void;
  35833. }
  35834. }
  35835. declare module BABYLON.GUI {
  35836. /**
  35837. * Root class used for all 2D controls
  35838. * @see http://doc.babylonjs.com/how_to/gui#controls
  35839. */
  35840. class Control {
  35841. /** defines the name of the control */
  35842. name: string | undefined;
  35843. private _alpha;
  35844. private _alphaSet;
  35845. private _zIndex;
  35846. /** @hidden */
  35847. /** @hidden */
  35848. /** Gets or sets the control parent */
  35849. parent: Nullable<Container>;
  35850. /** @hidden */
  35851. private _fontFamily;
  35852. private _fontStyle;
  35853. private _fontWeight;
  35854. private _fontSize;
  35855. private _font;
  35856. /** @hidden */
  35857. /** @hidden */
  35858. /** @hidden */
  35859. protected _fontOffset: {
  35860. ascent: number;
  35861. height: number;
  35862. descent: number;
  35863. };
  35864. private _color;
  35865. private _style;
  35866. private _styleObserver;
  35867. /** @hidden */
  35868. protected _horizontalAlignment: number;
  35869. /** @hidden */
  35870. protected _verticalAlignment: number;
  35871. private _isDirty;
  35872. /** @hidden */
  35873. /** @hidden */
  35874. protected _cachedParentMeasure: Measure;
  35875. private _paddingLeft;
  35876. private _paddingRight;
  35877. private _paddingTop;
  35878. private _paddingBottom;
  35879. /** @hidden */
  35880. /** @hidden */
  35881. private _scaleX;
  35882. private _scaleY;
  35883. private _rotation;
  35884. private _transformCenterX;
  35885. private _transformCenterY;
  35886. private _transformMatrix;
  35887. /** @hidden */
  35888. protected _invertTransformMatrix: Matrix2D;
  35889. /** @hidden */
  35890. protected _transformedPosition: Vector2;
  35891. private _onlyMeasureMode;
  35892. private _isMatrixDirty;
  35893. private _cachedOffsetX;
  35894. private _cachedOffsetY;
  35895. private _isVisible;
  35896. /** @hidden */
  35897. private _fontSet;
  35898. private _dummyVector2;
  35899. private _downCount;
  35900. private _enterCount;
  35901. private _doNotRender;
  35902. private _downPointerIds;
  35903. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  35904. isHitTestVisible: boolean;
  35905. /** Gets or sets a boolean indicating if the control can block pointer events */
  35906. isPointerBlocker: boolean;
  35907. /** Gets or sets a boolean indicating if the control can be focusable */
  35908. isFocusInvisible: boolean;
  35909. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  35910. shadowOffsetX: number;
  35911. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  35912. shadowOffsetY: number;
  35913. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  35914. shadowBlur: number;
  35915. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  35916. shadowColor: string;
  35917. /** @hidden */
  35918. protected _linkOffsetX: ValueAndUnit;
  35919. /** @hidden */
  35920. protected _linkOffsetY: ValueAndUnit;
  35921. /** Gets the control type name */
  35922. readonly typeName: string;
  35923. /**
  35924. * An event triggered when the pointer move over the control.
  35925. */
  35926. onPointerMoveObservable: Observable<Vector2>;
  35927. /**
  35928. * An event triggered when the pointer move out of the control.
  35929. */
  35930. onPointerOutObservable: Observable<Control>;
  35931. /**
  35932. * An event triggered when the pointer taps the control
  35933. */
  35934. onPointerDownObservable: Observable<Vector2WithInfo>;
  35935. /**
  35936. * An event triggered when pointer up
  35937. */
  35938. onPointerUpObservable: Observable<Vector2WithInfo>;
  35939. /**
  35940. * An event triggered when a control is clicked on
  35941. */
  35942. onPointerClickObservable: Observable<Vector2WithInfo>;
  35943. /**
  35944. * An event triggered when pointer enters the control
  35945. */
  35946. onPointerEnterObservable: Observable<Control>;
  35947. /**
  35948. * An event triggered when the control is marked as dirty
  35949. */
  35950. onDirtyObservable: Observable<Control>;
  35951. /**
  35952. * An event triggered after the control is drawn
  35953. */
  35954. onAfterDrawObservable: Observable<Control>;
  35955. /** Gets or set information about font offsets (used to render and align text) */
  35956. fontOffset: {
  35957. ascent: number;
  35958. height: number;
  35959. descent: number;
  35960. };
  35961. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  35962. alpha: number;
  35963. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  35964. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  35965. */
  35966. scaleX: number;
  35967. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  35968. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  35969. */
  35970. scaleY: number;
  35971. /** Gets or sets the rotation angle (0 by default)
  35972. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  35973. */
  35974. rotation: number;
  35975. /** Gets or sets the transformation center on Y axis (0 by default)
  35976. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  35977. */
  35978. transformCenterY: number;
  35979. /** Gets or sets the transformation center on X axis (0 by default)
  35980. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  35981. */
  35982. transformCenterX: number;
  35983. /**
  35984. * Gets or sets the horizontal alignment
  35985. * @see http://doc.babylonjs.com/how_to/gui#alignments
  35986. */
  35987. horizontalAlignment: number;
  35988. /**
  35989. * Gets or sets the vertical alignment
  35990. * @see http://doc.babylonjs.com/how_to/gui#alignments
  35991. */
  35992. verticalAlignment: number;
  35993. /**
  35994. * Gets or sets control width
  35995. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  35996. */
  35997. width: string | number;
  35998. /**
  35999. * Gets control width in pixel
  36000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36001. */
  36002. readonly widthInPixels: number;
  36003. /**
  36004. * Gets or sets control height
  36005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36006. */
  36007. height: string | number;
  36008. /**
  36009. * Gets control height in pixel
  36010. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36011. */
  36012. readonly heightInPixels: number;
  36013. /** Gets or set font family */
  36014. fontFamily: string;
  36015. /** Gets or sets font style */
  36016. fontStyle: string;
  36017. /** Gets or sets font weight */
  36018. fontWeight: string;
  36019. /**
  36020. * Gets or sets style
  36021. * @see http://doc.babylonjs.com/how_to/gui#styles
  36022. */
  36023. style: BABYLON.Nullable<Style>;
  36024. /** @hidden */
  36025. protected readonly _isFontSizeInPercentage: boolean;
  36026. /** Gets font size in pixels */
  36027. readonly fontSizeInPixels: number;
  36028. /** Gets or sets font size */
  36029. fontSize: string | number;
  36030. /** Gets or sets foreground color */
  36031. color: string;
  36032. /** Gets or sets z index which is used to reorder controls on the z axis */
  36033. zIndex: number;
  36034. /** Gets or sets a boolean indicating if the control can be rendered */
  36035. notRenderable: boolean;
  36036. /** Gets or sets a boolean indicating if the control is visible */
  36037. isVisible: boolean;
  36038. /** Gets a boolean indicating that the control needs to update its rendering */
  36039. readonly isDirty: boolean;
  36040. /**
  36041. * Gets or sets a value indicating the padding to use on the left of the control
  36042. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36043. */
  36044. paddingLeft: string | number;
  36045. /**
  36046. * Gets a value indicating the padding in pixels to use on the left of the control
  36047. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36048. */
  36049. readonly paddingLeftInPixels: number;
  36050. /**
  36051. * Gets or sets a value indicating the padding to use on the right of the control
  36052. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36053. */
  36054. paddingRight: string | number;
  36055. /**
  36056. * Gets a value indicating the padding in pixels to use on the right of the control
  36057. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36058. */
  36059. readonly paddingRightInPixels: number;
  36060. /**
  36061. * Gets or sets a value indicating the padding to use on the top of the control
  36062. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36063. */
  36064. paddingTop: string | number;
  36065. /**
  36066. * Gets a value indicating the padding in pixels to use on the top of the control
  36067. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36068. */
  36069. readonly paddingTopInPixels: number;
  36070. /**
  36071. * Gets or sets a value indicating the padding to use on the bottom of the control
  36072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36073. */
  36074. paddingBottom: string | number;
  36075. /**
  36076. * Gets a value indicating the padding in pixels to use on the bottom of the control
  36077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36078. */
  36079. readonly paddingBottomInPixels: number;
  36080. /**
  36081. * Gets or sets a value indicating the left coordinate of the control
  36082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36083. */
  36084. left: string | number;
  36085. /**
  36086. * Gets a value indicating the left coordinate in pixels of the control
  36087. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36088. */
  36089. readonly leftInPixels: number;
  36090. /**
  36091. * Gets or sets a value indicating the top coordinate of the control
  36092. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36093. */
  36094. top: string | number;
  36095. /**
  36096. * Gets a value indicating the top coordinate in pixels of the control
  36097. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  36098. */
  36099. readonly topInPixels: number;
  36100. /**
  36101. * Gets or sets a value indicating the offset on X axis to the linked mesh
  36102. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36103. */
  36104. linkOffsetX: string | number;
  36105. /**
  36106. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  36107. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36108. */
  36109. readonly linkOffsetXInPixels: number;
  36110. /**
  36111. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  36112. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36113. */
  36114. linkOffsetY: string | number;
  36115. /**
  36116. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  36117. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36118. */
  36119. readonly linkOffsetYInPixels: number;
  36120. /** Gets the center coordinate on X axis */
  36121. readonly centerX: number;
  36122. /** Gets the center coordinate on Y axis */
  36123. readonly centerY: number;
  36124. /**
  36125. * Creates a new control
  36126. * @param name defines the name of the control
  36127. */
  36128. constructor(
  36129. /** defines the name of the control */
  36130. name?: string | undefined);
  36131. /** @hidden */
  36132. protected _getTypeName(): string;
  36133. /** @hidden */
  36134. /**
  36135. * Gets coordinates in local control space
  36136. * @param globalCoordinates defines the coordinates to transform
  36137. * @returns the new coordinates in local space
  36138. */
  36139. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  36140. /**
  36141. * Gets coordinates in local control space
  36142. * @param globalCoordinates defines the coordinates to transform
  36143. * @param result defines the target vector2 where to store the result
  36144. * @returns the current control
  36145. */
  36146. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  36147. /**
  36148. * Gets coordinates in parent local control space
  36149. * @param globalCoordinates defines the coordinates to transform
  36150. * @returns the new coordinates in parent local space
  36151. */
  36152. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  36153. /**
  36154. * Move the current control to a vector3 position projected onto the screen.
  36155. * @param position defines the target position
  36156. * @param scene defines the hosting scene
  36157. */
  36158. moveToVector3(position: Vector3, scene: Scene): void;
  36159. /**
  36160. * Link current control with a target mesh
  36161. * @param mesh defines the mesh to link with
  36162. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  36163. */
  36164. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  36165. /** @hidden */
  36166. /** @hidden */
  36167. /** @hidden */
  36168. /** @hidden */
  36169. /** @hidden */
  36170. /** @hidden */
  36171. protected _transform(context: CanvasRenderingContext2D): void;
  36172. /** @hidden */
  36173. protected _applyStates(context: CanvasRenderingContext2D): void;
  36174. /** @hidden */
  36175. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  36176. /** @hidden */
  36177. protected _clip(context: CanvasRenderingContext2D): void;
  36178. /** @hidden */
  36179. /** @hidden */
  36180. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36181. /** @hidden */
  36182. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36183. /** @hidden */
  36184. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36185. /** @hidden */
  36186. /**
  36187. * Tests if a given coordinates belong to the current control
  36188. * @param x defines x coordinate to test
  36189. * @param y defines y coordinate to test
  36190. * @returns true if the coordinates are inside the control
  36191. */
  36192. contains(x: number, y: number): boolean;
  36193. /** @hidden */
  36194. /** @hidden */
  36195. /** @hidden */
  36196. /** @hidden */
  36197. /** @hidden */
  36198. /** @hidden */
  36199. /** @hidden */
  36200. /** @hidden */
  36201. private _prepareFont();
  36202. /** Releases associated resources */
  36203. dispose(): void;
  36204. private static _HORIZONTAL_ALIGNMENT_LEFT;
  36205. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  36206. private static _HORIZONTAL_ALIGNMENT_CENTER;
  36207. private static _VERTICAL_ALIGNMENT_TOP;
  36208. private static _VERTICAL_ALIGNMENT_BOTTOM;
  36209. private static _VERTICAL_ALIGNMENT_CENTER;
  36210. /** HORIZONTAL_ALIGNMENT_LEFT */
  36211. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  36212. /** HORIZONTAL_ALIGNMENT_RIGHT */
  36213. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  36214. /** HORIZONTAL_ALIGNMENT_CENTER */
  36215. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  36216. /** VERTICAL_ALIGNMENT_TOP */
  36217. static readonly VERTICAL_ALIGNMENT_TOP: number;
  36218. /** VERTICAL_ALIGNMENT_BOTTOM */
  36219. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  36220. /** VERTICAL_ALIGNMENT_CENTER */
  36221. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  36222. private static _FontHeightSizes;
  36223. /** @hidden */
  36224. private static _GetFontOffset(font: string): {
  36225. ascent: number;
  36226. height: number;
  36227. descent: number;
  36228. };
  36229. /**
  36230. * Creates a stack panel that can be used to render headers
  36231. * @param control defines the control to associate with the header
  36232. * @param text defines the text of the header
  36233. * @param size defines the size of the header
  36234. * @param options defines options used to configure the header
  36235. * @returns a new StackPanel
  36236. */
  36237. static AddHeader(control: Control, text: string, size: string | number, options: {
  36238. isHorizontal: boolean;
  36239. controlFirst: boolean;
  36240. }): StackPanel;
  36241. /** @hidden */
  36242. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  36243. }
  36244. }
  36245. declare module BABYLON.GUI {
  36246. /**
  36247. * Root class for 2D containers
  36248. * @see http://doc.babylonjs.com/how_to/gui#containers
  36249. */
  36250. class Container extends Control {
  36251. name: string | undefined;
  36252. /** @hidden */
  36253. protected _children: Control[];
  36254. /** @hidden */
  36255. protected _measureForChildren: Measure;
  36256. /** @hidden */
  36257. protected _background: string;
  36258. /** @hidden */
  36259. protected _adaptWidthToChildren: boolean;
  36260. /** @hidden */
  36261. protected _adaptHeightToChildren: boolean;
  36262. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  36263. adaptHeightToChildren: boolean;
  36264. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  36265. adaptWidthToChildren: boolean;
  36266. /** Gets or sets background color */
  36267. background: string;
  36268. /** Gets the list of children */
  36269. readonly children: Control[];
  36270. /**
  36271. * Creates a new Container
  36272. * @param name defines the name of the container
  36273. */
  36274. constructor(name?: string | undefined);
  36275. protected _getTypeName(): string;
  36276. /**
  36277. * Gets a child using its name
  36278. * @param name defines the child name to look for
  36279. * @returns the child control if found
  36280. */
  36281. getChildByName(name: string): Nullable<Control>;
  36282. /**
  36283. * Gets a child using its type and its name
  36284. * @param name defines the child name to look for
  36285. * @param type defines the child type to look for
  36286. * @returns the child control if found
  36287. */
  36288. getChildByType(name: string, type: string): Nullable<Control>;
  36289. /**
  36290. * Search for a specific control in children
  36291. * @param control defines the control to look for
  36292. * @returns true if the control is in child list
  36293. */
  36294. containsControl(control: Control): boolean;
  36295. /**
  36296. * Adds a new control to the current container
  36297. * @param control defines the control to add
  36298. * @returns the current container
  36299. */
  36300. addControl(control: Control): Container;
  36301. /**
  36302. * Removes a control from the current container
  36303. * @param control defines the control to remove
  36304. * @returns the current container
  36305. */
  36306. removeControl(control: Control): Container;
  36307. /** @hidden */
  36308. /** @hidden */
  36309. /** @hidden */
  36310. /** @hidden */
  36311. protected _localDraw(context: CanvasRenderingContext2D): void;
  36312. /** @hidden */
  36313. /** @hidden */
  36314. /** @hidden */
  36315. /** @hidden */
  36316. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  36317. /** @hidden */
  36318. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36319. /** Releases associated resources */
  36320. dispose(): void;
  36321. }
  36322. }
  36323. declare module BABYLON.GUI {
  36324. /**
  36325. * Class used to create a 2D stack panel container
  36326. */
  36327. class StackPanel extends Container {
  36328. name: string | undefined;
  36329. private _isVertical;
  36330. private _manualWidth;
  36331. private _manualHeight;
  36332. private _doNotTrackManualChanges;
  36333. private _tempMeasureStore;
  36334. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  36335. isVertical: boolean;
  36336. /** Gets or sets panel width */
  36337. width: string | number;
  36338. /** Gets or sets panel height */
  36339. height: string | number;
  36340. /**
  36341. * Creates a new StackPanel
  36342. * @param name defines control name
  36343. */
  36344. constructor(name?: string | undefined);
  36345. protected _getTypeName(): string;
  36346. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36347. }
  36348. }
  36349. declare module BABYLON.GUI {
  36350. /** Class used to create rectangle container */
  36351. class Rectangle extends Container {
  36352. name: string | undefined;
  36353. private _thickness;
  36354. private _cornerRadius;
  36355. /** Gets or sets border thickness */
  36356. thickness: number;
  36357. /** Gets or sets the corner radius angle */
  36358. cornerRadius: number;
  36359. /**
  36360. * Creates a new Rectangle
  36361. * @param name defines the control name
  36362. */
  36363. constructor(name?: string | undefined);
  36364. protected _getTypeName(): string;
  36365. protected _localDraw(context: CanvasRenderingContext2D): void;
  36366. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36367. private _drawRoundedRect(context, offset?);
  36368. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  36369. }
  36370. }
  36371. declare module BABYLON.GUI {
  36372. /** Class used to create 2D ellipse containers */
  36373. class Ellipse extends Container {
  36374. name: string | undefined;
  36375. private _thickness;
  36376. /** Gets or sets border thickness */
  36377. thickness: number;
  36378. /**
  36379. * Creates a new Ellipse
  36380. * @param name defines the control name
  36381. */
  36382. constructor(name?: string | undefined);
  36383. protected _getTypeName(): string;
  36384. protected _localDraw(context: CanvasRenderingContext2D): void;
  36385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36386. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  36387. }
  36388. }
  36389. declare module BABYLON.GUI {
  36390. /** Class used to render 2D lines */
  36391. class Line extends Control {
  36392. name: string | undefined;
  36393. private _lineWidth;
  36394. private _x1;
  36395. private _y1;
  36396. private _x2;
  36397. private _y2;
  36398. private _dash;
  36399. private _connectedControl;
  36400. private _connectedControlDirtyObserver;
  36401. /** Gets or sets the dash pattern */
  36402. dash: Array<number>;
  36403. /** Gets or sets the control connected with the line end */
  36404. connectedControl: Control;
  36405. /** Gets or sets start coordinates on X axis */
  36406. x1: string | number;
  36407. /** Gets or sets start coordinates on Y axis */
  36408. y1: string | number;
  36409. /** Gets or sets end coordinates on X axis */
  36410. x2: string | number;
  36411. /** Gets or sets end coordinates on Y axis */
  36412. y2: string | number;
  36413. /** Gets or sets line width */
  36414. lineWidth: number;
  36415. /** Gets or sets horizontal alignment */
  36416. horizontalAlignment: number;
  36417. /** Gets or sets vertical alignment */
  36418. verticalAlignment: number;
  36419. private readonly _effectiveX2;
  36420. private readonly _effectiveY2;
  36421. /**
  36422. * Creates a new Line
  36423. * @param name defines the control name
  36424. */
  36425. constructor(name?: string | undefined);
  36426. protected _getTypeName(): string;
  36427. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36428. /**
  36429. * Move one end of the line given 3D cartesian coordinates.
  36430. * @param position Targeted world position
  36431. * @param scene Scene
  36432. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  36433. */
  36434. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  36435. /**
  36436. * Move one end of the line to a position in screen absolute space.
  36437. * @param projectedPosition Position in screen absolute space (X, Y)
  36438. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  36439. */
  36440. }
  36441. }
  36442. declare module BABYLON.GUI {
  36443. /**
  36444. * Class used to create slider controls
  36445. */
  36446. class Slider extends Control {
  36447. name: string | undefined;
  36448. private _thumbWidth;
  36449. private _minimum;
  36450. private _maximum;
  36451. private _value;
  36452. private _background;
  36453. private _borderColor;
  36454. private _barOffset;
  36455. private _isThumbCircle;
  36456. private _isThumbClamped;
  36457. /** Observable raised when the sldier value changes */
  36458. onValueChangedObservable: Observable<number>;
  36459. /** Gets or sets border color */
  36460. borderColor: string;
  36461. /** Gets or sets background color */
  36462. background: string;
  36463. /** Gets or sets main bar offset */
  36464. barOffset: string | number;
  36465. /** Gets main bar offset in pixels*/
  36466. readonly barOffsetInPixels: number;
  36467. /** Gets or sets thumb width */
  36468. thumbWidth: string | number;
  36469. /** Gets thumb width in pixels */
  36470. readonly thumbWidthInPixels: number;
  36471. /** Gets or sets minimum value */
  36472. minimum: number;
  36473. /** Gets or sets maximum value */
  36474. maximum: number;
  36475. /** Gets or sets current value */
  36476. value: number;
  36477. /** Gets or sets a boolean indicating if the thumb should be round or square */
  36478. isThumbCircle: boolean;
  36479. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  36480. isThumbClamped: boolean;
  36481. /**
  36482. * Creates a new Slider
  36483. * @param name defines the control name
  36484. */
  36485. constructor(name?: string | undefined);
  36486. protected _getTypeName(): string;
  36487. private _pointerIsDown;
  36488. private _updateValueFromPointer(x, y);
  36489. }
  36490. }
  36491. declare module BABYLON.GUI {
  36492. /**
  36493. * Class used to represent a 2D checkbox
  36494. */
  36495. class Checkbox extends Control {
  36496. name: string | undefined;
  36497. private _isChecked;
  36498. private _background;
  36499. private _checkSizeRatio;
  36500. private _thickness;
  36501. /** Gets or sets border thickness */
  36502. thickness: number;
  36503. /**
  36504. * Observable raised when isChecked property changes
  36505. */
  36506. onIsCheckedChangedObservable: Observable<boolean>;
  36507. /** Gets or sets a value indicating the ratio between overall size and check size */
  36508. checkSizeRatio: number;
  36509. /** Gets or sets background color */
  36510. background: string;
  36511. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  36512. isChecked: boolean;
  36513. /**
  36514. * Creates a new CheckBox
  36515. * @param name defines the control name
  36516. */
  36517. constructor(name?: string | undefined);
  36518. protected _getTypeName(): string;
  36519. /** @hidden */
  36520. /** @hidden */
  36521. }
  36522. }
  36523. declare module BABYLON.GUI {
  36524. /**
  36525. * Class used to create radio button controls
  36526. */
  36527. class RadioButton extends Control {
  36528. name: string | undefined;
  36529. private _isChecked;
  36530. private _background;
  36531. private _checkSizeRatio;
  36532. private _thickness;
  36533. /** Gets or sets border thickness */
  36534. thickness: number;
  36535. /** Gets or sets group name */
  36536. group: string;
  36537. /** Observable raised when isChecked is changed */
  36538. onIsCheckedChangedObservable: Observable<boolean>;
  36539. /** Gets or sets a value indicating the ratio between overall size and check size */
  36540. checkSizeRatio: number;
  36541. /** Gets or sets background color */
  36542. background: string;
  36543. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  36544. isChecked: boolean;
  36545. /**
  36546. * Creates a new RadioButton
  36547. * @param name defines the control name
  36548. */
  36549. constructor(name?: string | undefined);
  36550. protected _getTypeName(): string;
  36551. }
  36552. }
  36553. declare module BABYLON.GUI {
  36554. /**
  36555. * Class used to create text block control
  36556. */
  36557. class TextBlock extends Control {
  36558. /**
  36559. * Defines the name of the control
  36560. */
  36561. name: string | undefined;
  36562. private _text;
  36563. private _textWrapping;
  36564. private _textHorizontalAlignment;
  36565. private _textVerticalAlignment;
  36566. private _lines;
  36567. private _resizeToFit;
  36568. private _lineSpacing;
  36569. private _outlineWidth;
  36570. private _outlineColor;
  36571. /**
  36572. * An event triggered after the text is changed
  36573. */
  36574. onTextChangedObservable: Observable<TextBlock>;
  36575. /**
  36576. * An event triggered after the text was broken up into lines
  36577. */
  36578. onLinesReadyObservable: Observable<TextBlock>;
  36579. /**
  36580. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  36581. */
  36582. readonly lines: any[];
  36583. /**
  36584. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  36585. */
  36586. /**
  36587. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  36588. */
  36589. resizeToFit: boolean;
  36590. /**
  36591. * Gets or sets a boolean indicating if text must be wrapped
  36592. */
  36593. /**
  36594. * Gets or sets a boolean indicating if text must be wrapped
  36595. */
  36596. textWrapping: boolean;
  36597. /**
  36598. * Gets or sets text to display
  36599. */
  36600. /**
  36601. * Gets or sets text to display
  36602. */
  36603. text: string;
  36604. /**
  36605. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  36606. */
  36607. /**
  36608. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  36609. */
  36610. textHorizontalAlignment: number;
  36611. /**
  36612. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  36613. */
  36614. /**
  36615. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  36616. */
  36617. textVerticalAlignment: number;
  36618. /**
  36619. * Gets or sets line spacing value
  36620. */
  36621. /**
  36622. * Gets or sets line spacing value
  36623. */
  36624. lineSpacing: string | number;
  36625. /**
  36626. * Gets or sets outlineWidth of the text to display
  36627. */
  36628. /**
  36629. * Gets or sets outlineWidth of the text to display
  36630. */
  36631. outlineWidth: number;
  36632. /**
  36633. * Gets or sets outlineColor of the text to display
  36634. */
  36635. /**
  36636. * Gets or sets outlineColor of the text to display
  36637. */
  36638. outlineColor: string;
  36639. /**
  36640. * Creates a new TextBlock object
  36641. * @param name defines the name of the control
  36642. * @param text defines the text to display (emptry string by default)
  36643. */
  36644. constructor(
  36645. /**
  36646. * Defines the name of the control
  36647. */
  36648. name?: string | undefined, text?: string);
  36649. protected _getTypeName(): string;
  36650. private _drawText(text, textWidth, y, context);
  36651. /** @hidden */
  36652. protected _applyStates(context: CanvasRenderingContext2D): void;
  36653. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  36654. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  36655. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  36656. protected _renderLines(context: CanvasRenderingContext2D): void;
  36657. dispose(): void;
  36658. }
  36659. }
  36660. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  36661. declare module BABYLON.GUI {
  36662. /**
  36663. * Class used to create 2D images
  36664. */
  36665. class Image extends Control {
  36666. name: string | undefined;
  36667. private _domImage;
  36668. private _imageWidth;
  36669. private _imageHeight;
  36670. private _loaded;
  36671. private _stretch;
  36672. private _source;
  36673. private _autoScale;
  36674. private _sourceLeft;
  36675. private _sourceTop;
  36676. private _sourceWidth;
  36677. private _sourceHeight;
  36678. private _cellWidth;
  36679. private _cellHeight;
  36680. private _cellId;
  36681. /**
  36682. * Gets or sets the left coordinate in the source image
  36683. */
  36684. sourceLeft: number;
  36685. /**
  36686. * Gets or sets the top coordinate in the source image
  36687. */
  36688. sourceTop: number;
  36689. /**
  36690. * Gets or sets the width to capture in the source image
  36691. */
  36692. sourceWidth: number;
  36693. /**
  36694. * Gets or sets the height to capture in the source image
  36695. */
  36696. sourceHeight: number;
  36697. /**
  36698. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  36699. * @see http://doc.babylonjs.com/how_to/gui#image
  36700. */
  36701. autoScale: boolean;
  36702. /** Gets or sets the streching mode used by the image */
  36703. stretch: number;
  36704. /**
  36705. * Gets or sets the internal DOM image used to render the control
  36706. */
  36707. domImage: HTMLImageElement;
  36708. private _onImageLoaded();
  36709. /**
  36710. * Gets or sets image source url
  36711. */
  36712. source: Nullable<string>;
  36713. /**
  36714. * Gets or sets the cell width to use when animation sheet is enabled
  36715. * @see http://doc.babylonjs.com/how_to/gui#image
  36716. */
  36717. cellWidth: number;
  36718. /**
  36719. * Gets or sets the cell height to use when animation sheet is enabled
  36720. * @see http://doc.babylonjs.com/how_to/gui#image
  36721. */
  36722. cellHeight: number;
  36723. /**
  36724. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  36725. * @see http://doc.babylonjs.com/how_to/gui#image
  36726. */
  36727. cellId: number;
  36728. /**
  36729. * Creates a new Image
  36730. * @param name defines the control name
  36731. * @param url defines the image url
  36732. */
  36733. constructor(name?: string | undefined, url?: Nullable<string>);
  36734. protected _getTypeName(): string;
  36735. /** Force the control to synchronize with its content */
  36736. synchronizeSizeWithContent(): void;
  36737. private static _STRETCH_NONE;
  36738. private static _STRETCH_FILL;
  36739. private static _STRETCH_UNIFORM;
  36740. private static _STRETCH_EXTEND;
  36741. /** STRETCH_NONE */
  36742. static readonly STRETCH_NONE: number;
  36743. /** STRETCH_FILL */
  36744. static readonly STRETCH_FILL: number;
  36745. /** STRETCH_UNIFORM */
  36746. static readonly STRETCH_UNIFORM: number;
  36747. /** STRETCH_EXTEND */
  36748. static readonly STRETCH_EXTEND: number;
  36749. }
  36750. }
  36751. declare module BABYLON.GUI {
  36752. /**
  36753. * Class used to create 2D buttons
  36754. */
  36755. class Button extends Rectangle {
  36756. name: string | undefined;
  36757. /**
  36758. * Function called to generate a pointer enter animation
  36759. */
  36760. pointerEnterAnimation: () => void;
  36761. /**
  36762. * Function called to generate a pointer out animation
  36763. */
  36764. pointerOutAnimation: () => void;
  36765. /**
  36766. * Function called to generate a pointer down animation
  36767. */
  36768. pointerDownAnimation: () => void;
  36769. /**
  36770. * Function called to generate a pointer up animation
  36771. */
  36772. pointerUpAnimation: () => void;
  36773. /**
  36774. * Creates a new Button
  36775. * @param name defines the name of the button
  36776. */
  36777. constructor(name?: string | undefined);
  36778. protected _getTypeName(): string;
  36779. /** @hidden */
  36780. /** @hidden */
  36781. /** @hidden */
  36782. /** @hidden */
  36783. /** @hidden */
  36784. /**
  36785. * Creates a new button made with an image and a text
  36786. * @param name defines the name of the button
  36787. * @param text defines the text of the button
  36788. * @param imageUrl defines the url of the image
  36789. * @returns a new Button
  36790. */
  36791. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  36792. /**
  36793. * Creates a new button made with an image
  36794. * @param name defines the name of the button
  36795. * @param imageUrl defines the url of the image
  36796. * @returns a new Button
  36797. */
  36798. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  36799. /**
  36800. * Creates a new button made with a text
  36801. * @param name defines the name of the button
  36802. * @param text defines the text of the button
  36803. * @returns a new Button
  36804. */
  36805. static CreateSimpleButton(name: string, text: string): Button;
  36806. /**
  36807. * Creates a new button made with an image and a centered text
  36808. * @param name defines the name of the button
  36809. * @param text defines the text of the button
  36810. * @param imageUrl defines the url of the image
  36811. * @returns a new Button
  36812. */
  36813. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  36814. }
  36815. }
  36816. declare module BABYLON.GUI {
  36817. /** Class used to create color pickers */
  36818. class ColorPicker extends Control {
  36819. name: string | undefined;
  36820. private _colorWheelCanvas;
  36821. private _value;
  36822. private _tmpColor;
  36823. private _pointerStartedOnSquare;
  36824. private _pointerStartedOnWheel;
  36825. private _squareLeft;
  36826. private _squareTop;
  36827. private _squareSize;
  36828. private _h;
  36829. private _s;
  36830. private _v;
  36831. /**
  36832. * Observable raised when the value changes
  36833. */
  36834. onValueChangedObservable: Observable<Color3>;
  36835. /** Gets or sets the color of the color picker */
  36836. value: Color3;
  36837. /** Gets or sets control width */
  36838. width: string | number;
  36839. /** Gets or sets control height */
  36840. height: string | number;
  36841. /** Gets or sets control size */
  36842. size: string | number;
  36843. /**
  36844. * Creates a new ColorPicker
  36845. * @param name defines the control name
  36846. */
  36847. constructor(name?: string | undefined);
  36848. protected _getTypeName(): string;
  36849. private _updateSquareProps();
  36850. private _drawGradientSquare(hueValue, left, top, width, height, context);
  36851. private _drawCircle(centerX, centerY, radius, context);
  36852. private _createColorWheelCanvas(radius, thickness);
  36853. private _RGBtoHSV(color, result);
  36854. private _HSVtoRGB(hue, saturation, value, result);
  36855. /** @hidden */
  36856. private _pointerIsDown;
  36857. private _updateValueFromPointer(x, y);
  36858. private _isPointOnSquare(coordinates);
  36859. private _isPointOnWheel(coordinates);
  36860. }
  36861. }
  36862. declare module BABYLON.GUI {
  36863. /**
  36864. * Class used to create input text control
  36865. */
  36866. class InputText extends Control implements IFocusableControl {
  36867. name: string | undefined;
  36868. private _text;
  36869. private _placeholderText;
  36870. private _background;
  36871. private _focusedBackground;
  36872. private _placeholderColor;
  36873. private _thickness;
  36874. private _margin;
  36875. private _autoStretchWidth;
  36876. private _maxWidth;
  36877. private _isFocused;
  36878. private _blinkTimeout;
  36879. private _blinkIsEven;
  36880. private _cursorOffset;
  36881. private _scrollLeft;
  36882. private _textWidth;
  36883. private _clickedCoordinate;
  36884. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  36885. promptMessage: string;
  36886. /** Observable raised when the text changes */
  36887. onTextChangedObservable: Observable<InputText>;
  36888. /** Observable raised when the control gets the focus */
  36889. onFocusObservable: Observable<InputText>;
  36890. /** Observable raised when the control loses the focus */
  36891. onBlurObservable: Observable<InputText>;
  36892. /** Gets or sets the maximum width allowed by the control */
  36893. maxWidth: string | number;
  36894. /** Gets the maximum width allowed by the control in pixels */
  36895. readonly maxWidthInPixels: number;
  36896. /** Gets or sets control margin */
  36897. margin: string;
  36898. /** Gets control margin in pixels */
  36899. readonly marginInPixels: number;
  36900. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  36901. autoStretchWidth: boolean;
  36902. /** Gets or sets border thickness */
  36903. thickness: number;
  36904. /** Gets or sets the background color when focused */
  36905. focusedBackground: string;
  36906. /** Gets or sets the background color */
  36907. background: string;
  36908. /** Gets or sets the placeholder color */
  36909. placeholderColor: string;
  36910. /** Gets or sets the text displayed when the control is empty */
  36911. placeholderText: string;
  36912. /** Gets or sets the text displayed in the control */
  36913. text: string;
  36914. /** Gets or sets control width */
  36915. width: string | number;
  36916. /**
  36917. * Creates a new InputText
  36918. * @param name defines the control name
  36919. * @param text defines the text of the control
  36920. */
  36921. constructor(name?: string | undefined, text?: string);
  36922. /** @hidden */
  36923. onBlur(): void;
  36924. /** @hidden */
  36925. onFocus(): void;
  36926. protected _getTypeName(): string;
  36927. /** @hidden */
  36928. processKey(keyCode: number, key?: string): void;
  36929. /** @hidden */
  36930. processKeyboard(evt: KeyboardEvent): void;
  36931. dispose(): void;
  36932. }
  36933. }
  36934. declare module BABYLON.GUI {
  36935. /**
  36936. * Class used to store key control properties
  36937. */
  36938. class KeyPropertySet {
  36939. /** Width */
  36940. width?: string;
  36941. /** Height */
  36942. height?: string;
  36943. /** Left padding */
  36944. paddingLeft?: string;
  36945. /** Right padding */
  36946. paddingRight?: string;
  36947. /** Top padding */
  36948. paddingTop?: string;
  36949. /** Bottom padding */
  36950. paddingBottom?: string;
  36951. /** Foreground color */
  36952. color?: string;
  36953. /** Background color */
  36954. background?: string;
  36955. }
  36956. /**
  36957. * Class used to create virtual keyboard
  36958. */
  36959. class VirtualKeyboard extends StackPanel {
  36960. /** Observable raised when a key is pressed */
  36961. onKeyPressObservable: Observable<string>;
  36962. /** Gets or sets default key button width */
  36963. defaultButtonWidth: string;
  36964. /** Gets or sets default key button height */
  36965. defaultButtonHeight: string;
  36966. /** Gets or sets default key button left padding */
  36967. defaultButtonPaddingLeft: string;
  36968. /** Gets or sets default key button right padding */
  36969. defaultButtonPaddingRight: string;
  36970. /** Gets or sets default key button top padding */
  36971. defaultButtonPaddingTop: string;
  36972. /** Gets or sets default key button bottom padding */
  36973. defaultButtonPaddingBottom: string;
  36974. /** Gets or sets default key button foreground color */
  36975. defaultButtonColor: string;
  36976. /** Gets or sets default key button background color */
  36977. defaultButtonBackground: string;
  36978. /** Gets or sets shift button foreground color */
  36979. shiftButtonColor: string;
  36980. /** Gets or sets shift button thickness*/
  36981. selectedShiftThickness: number;
  36982. /** Gets shift key state */
  36983. shiftState: number;
  36984. protected _getTypeName(): string;
  36985. private _createKey(key, propertySet);
  36986. /**
  36987. * Adds a new row of keys
  36988. * @param keys defines the list of keys to add
  36989. * @param propertySets defines the associated property sets
  36990. */
  36991. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  36992. /**
  36993. * Set the shift key to a specific state
  36994. * @param shiftState defines the new shift state
  36995. */
  36996. applyShiftState(shiftState: number): void;
  36997. private _connectedInputText;
  36998. private _onFocusObserver;
  36999. private _onBlurObserver;
  37000. private _onKeyPressObserver;
  37001. /** Gets the input text control attached with the keyboard */
  37002. readonly connectedInputText: Nullable<InputText>;
  37003. /**
  37004. * Connects the keyboard with an input text control
  37005. * @param input defines the target control
  37006. */
  37007. connect(input: InputText): void;
  37008. /**
  37009. * Disconnects the keyboard from an input text control
  37010. */
  37011. disconnect(): void;
  37012. /**
  37013. * Creates a new keyboard using a default layout
  37014. * @returns a new VirtualKeyboard
  37015. */
  37016. static CreateDefaultLayout(): VirtualKeyboard;
  37017. }
  37018. }
  37019. declare module BABYLON.GUI {
  37020. /**
  37021. * Class used to create multi line control
  37022. */
  37023. class MultiLine extends Control {
  37024. name: string | undefined;
  37025. private _lineWidth;
  37026. private _dash;
  37027. private _points;
  37028. private _minX;
  37029. private _minY;
  37030. private _maxX;
  37031. private _maxY;
  37032. /**
  37033. * Creates a new MultiLine
  37034. * @param name defines the control name
  37035. */
  37036. constructor(name?: string | undefined);
  37037. /** Gets or sets dash pattern */
  37038. dash: Array<number>;
  37039. /**
  37040. * Gets point stored at specified index
  37041. * @param index defines the index to look for
  37042. * @returns the requested point if found
  37043. */
  37044. getAt(index: number): MultiLinePoint;
  37045. /** Function called when a point is updated */
  37046. onPointUpdate: () => void;
  37047. /**
  37048. * Adds new points to the point collection
  37049. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  37050. * @returns the list of created MultiLinePoint
  37051. */
  37052. add(...items: (AbstractMesh | Control | {
  37053. x: string | number;
  37054. y: string | number;
  37055. })[]): MultiLinePoint[];
  37056. /**
  37057. * Adds a new point to the point collection
  37058. * @param item defines the item (mesh, control or 2d coordiantes) to add
  37059. * @returns the created MultiLinePoint
  37060. */
  37061. push(item?: (AbstractMesh | Control | {
  37062. x: string | number;
  37063. y: string | number;
  37064. })): MultiLinePoint;
  37065. /**
  37066. * Remove a specific value or point from the active point collection
  37067. * @param value defines the value or point to remove
  37068. */
  37069. remove(value: number | MultiLinePoint): void;
  37070. /** Gets or sets line width */
  37071. lineWidth: number;
  37072. horizontalAlignment: number;
  37073. verticalAlignment: number;
  37074. protected _getTypeName(): string;
  37075. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37076. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  37077. dispose(): void;
  37078. }
  37079. }
  37080. declare module BABYLON.GUI {
  37081. /**
  37082. * Class used to manage 3D user interface
  37083. * @see http://doc.babylonjs.com/how_to/gui3d
  37084. */
  37085. class GUI3DManager implements BABYLON.IDisposable {
  37086. private _scene;
  37087. private _sceneDisposeObserver;
  37088. private _utilityLayer;
  37089. private _rootContainer;
  37090. private _pointerObserver;
  37091. /** @hidden */
  37092. /** @hidden */
  37093. ;
  37094. /** @hidden */
  37095. ;
  37096. /**
  37097. * Observable raised when the point picked by the pointer events changed
  37098. */
  37099. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  37100. /** @hidden */
  37101. ;
  37102. /** Gets the hosting scene */
  37103. readonly scene: Scene;
  37104. /** Gets associated utility layer */
  37105. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  37106. /**
  37107. * Creates a new GUI3DManager
  37108. * @param scene
  37109. */
  37110. constructor(scene?: Scene);
  37111. private _doPicking(type, pointerEvent, ray?);
  37112. /**
  37113. * Gets the root container
  37114. */
  37115. readonly rootContainer: Container3D;
  37116. /**
  37117. * Gets a boolean indicating if the given control is in the root child list
  37118. * @param control defines the control to check
  37119. * @returns true if the control is in the root child list
  37120. */
  37121. containsControl(control: Control3D): boolean;
  37122. /**
  37123. * Adds a control to the root child list
  37124. * @param control defines the control to add
  37125. * @returns the current manager
  37126. */
  37127. addControl(control: Control3D): GUI3DManager;
  37128. /**
  37129. * Removes a control from the root child list
  37130. * @param control defines the control to remove
  37131. * @returns the current container
  37132. */
  37133. removeControl(control: Control3D): GUI3DManager;
  37134. /**
  37135. * Releases all associated resources
  37136. */
  37137. dispose(): void;
  37138. }
  37139. }
  37140. declare module BABYLON.GUI {
  37141. /** @hidden */
  37142. class FluentMaterialDefines extends MaterialDefines {
  37143. INNERGLOW: boolean;
  37144. BORDER: boolean;
  37145. HOVERLIGHT: boolean;
  37146. constructor();
  37147. }
  37148. /**
  37149. * Class used to render controls with fluent desgin
  37150. */
  37151. class FluentMaterial extends PushMaterial {
  37152. /**
  37153. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  37154. */
  37155. innerGlowColorIntensity: number;
  37156. /**
  37157. * Gets or sets the inner glow color (white by default)
  37158. */
  37159. innerGlowColor: Color3;
  37160. /**
  37161. * Gets or sets alpha value (default is 1.0)
  37162. */
  37163. alpha: number;
  37164. /**
  37165. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  37166. */
  37167. albedoColor: Color3;
  37168. /**
  37169. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  37170. */
  37171. renderBorders: boolean;
  37172. /**
  37173. * Gets or sets border width (default is 0.5)
  37174. */
  37175. borderWidth: number;
  37176. /**
  37177. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  37178. */
  37179. edgeSmoothingValue: number;
  37180. /**
  37181. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  37182. */
  37183. borderMinValue: number;
  37184. /**
  37185. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  37186. */
  37187. renderHoverLight: boolean;
  37188. /**
  37189. * Gets or sets the radius used to render the hover light (default is 0.15)
  37190. */
  37191. hoverRadius: number;
  37192. /**
  37193. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  37194. */
  37195. hoverColor: Color4;
  37196. /**
  37197. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  37198. */
  37199. hoverPosition: Vector3;
  37200. /**
  37201. * Creates a new Fluent material
  37202. * @param name defines the name of the material
  37203. * @param scene defines the hosting scene
  37204. */
  37205. constructor(name: string, scene: Scene);
  37206. needAlphaBlending(): boolean;
  37207. needAlphaTesting(): boolean;
  37208. getAlphaTestTexture(): Nullable<BaseTexture>;
  37209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37210. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37211. getActiveTextures(): BaseTexture[];
  37212. hasTexture(texture: BaseTexture): boolean;
  37213. dispose(forceDisposeEffect?: boolean): void;
  37214. clone(name: string): FluentMaterial;
  37215. serialize(): any;
  37216. getClassName(): string;
  37217. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  37218. }
  37219. }
  37220. declare module BABYLON.GUI {
  37221. /**
  37222. * Class used to transport Vector3 information for pointer events
  37223. */
  37224. class Vector3WithInfo extends Vector3 {
  37225. /** defines the current mouse button index */
  37226. buttonIndex: number;
  37227. /**
  37228. * Creates a new Vector3WithInfo
  37229. * @param source defines the vector3 data to transport
  37230. * @param buttonIndex defines the current mouse button index
  37231. */
  37232. constructor(source: Vector3,
  37233. /** defines the current mouse button index */
  37234. buttonIndex?: number);
  37235. }
  37236. }
  37237. declare module BABYLON.GUI {
  37238. /**
  37239. * Class used as base class for controls
  37240. */
  37241. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  37242. /** Defines the control name */
  37243. name: string | undefined;
  37244. /** @hidden */
  37245. private _node;
  37246. private _downCount;
  37247. private _enterCount;
  37248. private _downPointerIds;
  37249. private _isVisible;
  37250. /** Gets or sets the control position in world space */
  37251. position: Vector3;
  37252. /** Gets or sets the control scaling in world space */
  37253. scaling: Vector3;
  37254. /** Callback used to start pointer enter animation */
  37255. pointerEnterAnimation: () => void;
  37256. /** Callback used to start pointer out animation */
  37257. pointerOutAnimation: () => void;
  37258. /** Callback used to start pointer down animation */
  37259. pointerDownAnimation: () => void;
  37260. /** Callback used to start pointer up animation */
  37261. pointerUpAnimation: () => void;
  37262. /**
  37263. * An event triggered when the pointer move over the control
  37264. */
  37265. onPointerMoveObservable: Observable<Vector3>;
  37266. /**
  37267. * An event triggered when the pointer move out of the control
  37268. */
  37269. onPointerOutObservable: Observable<Control3D>;
  37270. /**
  37271. * An event triggered when the pointer taps the control
  37272. */
  37273. onPointerDownObservable: Observable<Vector3WithInfo>;
  37274. /**
  37275. * An event triggered when pointer is up
  37276. */
  37277. onPointerUpObservable: Observable<Vector3WithInfo>;
  37278. /**
  37279. * An event triggered when a control is clicked on (with a mouse)
  37280. */
  37281. onPointerClickObservable: Observable<Vector3WithInfo>;
  37282. /**
  37283. * An event triggered when pointer enters the control
  37284. */
  37285. onPointerEnterObservable: Observable<Control3D>;
  37286. /**
  37287. * Gets or sets the parent container
  37288. */
  37289. parent: Nullable<Container3D>;
  37290. private _behaviors;
  37291. /**
  37292. * Gets the list of attached behaviors
  37293. * @see http://doc.babylonjs.com/features/behaviour
  37294. */
  37295. readonly behaviors: Behavior<Control3D>[];
  37296. /**
  37297. * Attach a behavior to the control
  37298. * @see http://doc.babylonjs.com/features/behaviour
  37299. * @param behavior defines the behavior to attach
  37300. * @returns the current control
  37301. */
  37302. addBehavior(behavior: Behavior<Control3D>): Control3D;
  37303. /**
  37304. * Remove an attached behavior
  37305. * @see http://doc.babylonjs.com/features/behaviour
  37306. * @param behavior defines the behavior to attach
  37307. * @returns the current control
  37308. */
  37309. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  37310. /**
  37311. * Gets an attached behavior by name
  37312. * @param name defines the name of the behavior to look for
  37313. * @see http://doc.babylonjs.com/features/behaviour
  37314. * @returns null if behavior was not found else the requested behavior
  37315. */
  37316. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  37317. /** Gets or sets a boolean indicating if the control is visible */
  37318. isVisible: boolean;
  37319. /**
  37320. * Creates a new control
  37321. * @param name defines the control name
  37322. */
  37323. constructor(
  37324. /** Defines the control name */
  37325. name?: string | undefined);
  37326. /**
  37327. * Gets a string representing the class name
  37328. */
  37329. readonly typeName: string;
  37330. protected _getTypeName(): string;
  37331. /**
  37332. * Gets the transform node used by this control
  37333. */
  37334. readonly node: Nullable<TransformNode>;
  37335. /**
  37336. * Gets the mesh used to render this control
  37337. */
  37338. readonly mesh: Nullable<AbstractMesh>;
  37339. /**
  37340. * Link the control as child of the given node
  37341. * @param node defines the node to link to. Use null to unlink the control
  37342. * @returns the current control
  37343. */
  37344. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  37345. /** @hidden **/
  37346. /**
  37347. * Node creation.
  37348. * Can be overriden by children
  37349. * @param scene defines the scene where the node must be attached
  37350. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  37351. */
  37352. protected _createNode(scene: Scene): Nullable<TransformNode>;
  37353. /**
  37354. * Affect a material to the given mesh
  37355. * @param mesh defines the mesh which will represent the control
  37356. */
  37357. protected _affectMaterial(mesh: AbstractMesh): void;
  37358. /** @hidden */
  37359. /** @hidden */
  37360. /** @hidden */
  37361. /** @hidden */
  37362. /** @hidden */
  37363. /** @hidden */
  37364. forcePointerUp(pointerId?: Nullable<number>): void;
  37365. /** @hidden */
  37366. /**
  37367. * Releases all associated resources
  37368. */
  37369. dispose(): void;
  37370. }
  37371. }
  37372. declare module BABYLON.GUI {
  37373. /**
  37374. * Class used to create containers for controls
  37375. */
  37376. class Container3D extends Control3D {
  37377. /**
  37378. * Gets the list of child controls
  37379. */
  37380. protected _children: Control3D[];
  37381. /**
  37382. * Creates a new container
  37383. * @param name defines the container name
  37384. */
  37385. constructor(name?: string);
  37386. /**
  37387. * Gets a boolean indicating if the given control is in the children of this control
  37388. * @param control defines the control to check
  37389. * @returns true if the control is in the child list
  37390. */
  37391. containsControl(control: Control3D): boolean;
  37392. /**
  37393. * Adds a control to the children of this control
  37394. * @param control defines the control to add
  37395. * @returns the current container
  37396. */
  37397. addControl(control: Control3D): Container3D;
  37398. /**
  37399. * This function will be called everytime a new control is added
  37400. */
  37401. protected _arrangeChildren(): void;
  37402. protected _createNode(scene: Scene): Nullable<TransformNode>;
  37403. /**
  37404. * Removes a control from the children of this control
  37405. * @param control defines the control to remove
  37406. * @returns the current container
  37407. */
  37408. removeControl(control: Control3D): Container3D;
  37409. protected _getTypeName(): string;
  37410. /**
  37411. * Releases all associated resources
  37412. */
  37413. dispose(): void;
  37414. }
  37415. }
  37416. declare module BABYLON.GUI {
  37417. /**
  37418. * Class used to create a button in 3D
  37419. */
  37420. class Button3D extends Control3D {
  37421. /** @hidden */
  37422. protected _currentMaterial: Material;
  37423. private _facadeTexture;
  37424. private _content;
  37425. private _contentResolution;
  37426. private _contentScaleRatio;
  37427. /**
  37428. * Gets or sets the texture resolution used to render content (512 by default)
  37429. */
  37430. contentResolution: int;
  37431. /**
  37432. * Gets or sets the texture scale ratio used to render content (2 by default)
  37433. */
  37434. contentScaleRatio: number;
  37435. protected _disposeFacadeTexture(): void;
  37436. private _resetContent();
  37437. /**
  37438. * Creates a new button
  37439. * @param name defines the control name
  37440. */
  37441. constructor(name?: string);
  37442. /**
  37443. * Gets or sets the GUI 2D content used to display the button's facade
  37444. */
  37445. content: Control;
  37446. /**
  37447. * Apply the facade texture (created from the content property).
  37448. * This function can be overloaded by child classes
  37449. * @param facadeTexture defines the AdvancedDynamicTexture to use
  37450. */
  37451. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  37452. protected _getTypeName(): string;
  37453. protected _createNode(scene: Scene): TransformNode;
  37454. protected _affectMaterial(mesh: AbstractMesh): void;
  37455. /**
  37456. * Releases all associated resources
  37457. */
  37458. dispose(): void;
  37459. }
  37460. }
  37461. declare module BABYLON.GUI {
  37462. /**
  37463. * Class used to create a holographic button in 3D
  37464. */
  37465. class HolographicButton extends Button3D {
  37466. private _backPlate;
  37467. private _textPlate;
  37468. private _frontPlate;
  37469. private _text;
  37470. private _imageUrl;
  37471. private _shareMaterials;
  37472. private _frontMaterial;
  37473. private _backMaterial;
  37474. private _plateMaterial;
  37475. private _pickedPointObserver;
  37476. /**
  37477. * Gets or sets text for the button
  37478. */
  37479. text: string;
  37480. /**
  37481. * Gets or sets the image url for the button
  37482. */
  37483. imageUrl: string;
  37484. /**
  37485. * Gets the back material used by this button
  37486. */
  37487. readonly backMaterial: FluentMaterial;
  37488. /**
  37489. * Gets the front material used by this button
  37490. */
  37491. readonly frontMaterial: FluentMaterial;
  37492. /**
  37493. * Gets the plate material used by this button
  37494. */
  37495. readonly plateMaterial: StandardMaterial;
  37496. /**
  37497. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  37498. */
  37499. readonly shareMaterials: boolean;
  37500. /**
  37501. * Creates a new button
  37502. * @param name defines the control name
  37503. */
  37504. constructor(name?: string, shareMaterials?: boolean);
  37505. protected _getTypeName(): string;
  37506. private _rebuildContent();
  37507. protected _createNode(scene: Scene): TransformNode;
  37508. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  37509. private _createBackMaterial(mesh);
  37510. private _createFrontMaterial(mesh);
  37511. private _createPlateMaterial(mesh);
  37512. protected _affectMaterial(mesh: Mesh): void;
  37513. /**
  37514. * Releases all associated resources
  37515. */
  37516. dispose(): void;
  37517. }
  37518. }
  37519. declare module BABYLON.GUI {
  37520. /**
  37521. * Class used to create a stack panel in 3D on XY plane
  37522. */
  37523. class StackPanel3D extends Container3D {
  37524. private _isVertical;
  37525. /**
  37526. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  37527. */
  37528. isVertical: boolean;
  37529. /**
  37530. * Gets or sets the distance between elements
  37531. */
  37532. margin: number;
  37533. /**
  37534. * Creates new StackPanel
  37535. * @param isVertical
  37536. */
  37537. constructor();
  37538. protected _arrangeChildren(): void;
  37539. }
  37540. }
  37541. declare module BABYLON {
  37542. /**
  37543. * Mode that determines the coordinate system to use.
  37544. */
  37545. enum GLTFLoaderCoordinateSystemMode {
  37546. /**
  37547. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  37548. */
  37549. AUTO = 0,
  37550. /**
  37551. * Sets the useRightHandedSystem flag on the scene.
  37552. */
  37553. FORCE_RIGHT_HANDED = 1,
  37554. }
  37555. /**
  37556. * Mode that determines what animations will start.
  37557. */
  37558. enum GLTFLoaderAnimationStartMode {
  37559. /**
  37560. * No animation will start.
  37561. */
  37562. NONE = 0,
  37563. /**
  37564. * The first animation will start.
  37565. */
  37566. FIRST = 1,
  37567. /**
  37568. * All animations will start.
  37569. */
  37570. ALL = 2,
  37571. }
  37572. /**
  37573. * Interface that contains the data for the glTF asset.
  37574. */
  37575. interface IGLTFLoaderData {
  37576. /**
  37577. * JSON that represents the glTF.
  37578. */
  37579. json: Object;
  37580. /**
  37581. * The BIN chunk of a binary glTF
  37582. */
  37583. bin: Nullable<ArrayBufferView>;
  37584. }
  37585. /**
  37586. * Interface for extending the loader.
  37587. */
  37588. interface IGLTFLoaderExtension {
  37589. /**
  37590. * The name of this extension.
  37591. */
  37592. readonly name: string;
  37593. /**
  37594. * Defines whether this extension is enabled.
  37595. */
  37596. enabled: boolean;
  37597. }
  37598. /**
  37599. * Loader state.
  37600. */
  37601. enum GLTFLoaderState {
  37602. /**
  37603. * The asset is loading.
  37604. */
  37605. LOADING = 0,
  37606. /**
  37607. * The asset is ready for rendering.
  37608. */
  37609. READY = 1,
  37610. /**
  37611. * The asset is completely loaded.
  37612. */
  37613. COMPLETE = 2,
  37614. }
  37615. /**
  37616. * Loader interface.
  37617. */
  37618. interface IGLTFLoader extends IDisposable {
  37619. /**
  37620. * Mode that determines the coordinate system to use.
  37621. */
  37622. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  37623. /**
  37624. * Mode that determines what animations will start.
  37625. */
  37626. animationStartMode: GLTFLoaderAnimationStartMode;
  37627. /**
  37628. * Defines if the loader should compile materials.
  37629. */
  37630. compileMaterials: boolean;
  37631. /**
  37632. * Defines if the loader should also compile materials with clip planes.
  37633. */
  37634. useClipPlane: boolean;
  37635. /**
  37636. * Defines if the loader should compile shadow generators.
  37637. */
  37638. compileShadowGenerators: boolean;
  37639. /**
  37640. * Defines if the Alpha blended materials are only applied as coverage.
  37641. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  37642. * If true, no extra effects are applied to transparent pixels.
  37643. */
  37644. transparencyAsCoverage: boolean;
  37645. /** @hidden */
  37646. /**
  37647. * Function called before loading a url referenced by the asset.
  37648. */
  37649. preprocessUrlAsync: (url: string) => Promise<string>;
  37650. /**
  37651. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  37652. */
  37653. onMeshLoadedObservable: Observable<AbstractMesh>;
  37654. /**
  37655. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  37656. */
  37657. onTextureLoadedObservable: Observable<BaseTexture>;
  37658. /**
  37659. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  37660. */
  37661. onMaterialLoadedObservable: Observable<Material>;
  37662. /**
  37663. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  37664. */
  37665. onCameraLoadedObservable: Observable<Camera>;
  37666. /**
  37667. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  37668. * For assets with LODs, raised when all of the LODs are complete.
  37669. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  37670. */
  37671. onCompleteObservable: Observable<IGLTFLoader>;
  37672. /**
  37673. * Observable raised after the loader is disposed.
  37674. */
  37675. onDisposeObservable: Observable<IGLTFLoader>;
  37676. /**
  37677. * Observable raised after a loader extension is created.
  37678. * Set additional options for a loader extension in this event.
  37679. */
  37680. onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  37681. /**
  37682. * Loader state or null if the loader is not active.
  37683. */
  37684. state: Nullable<GLTFLoaderState>;
  37685. /**
  37686. * Imports meshes from the given data and adds them to the scene.
  37687. */
  37688. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{
  37689. meshes: AbstractMesh[];
  37690. particleSystems: ParticleSystem[];
  37691. skeletons: Skeleton[];
  37692. animationGroups: AnimationGroup[];
  37693. }>;
  37694. /**
  37695. * Loads all objects from the given data and adds them to the scene.
  37696. */
  37697. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>;
  37698. }
  37699. /**
  37700. * File loader for loading glTF files into a scene.
  37701. */
  37702. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  37703. /**
  37704. * Factory function that creates a glTF 1.0 loader
  37705. * @hidden
  37706. */
  37707. private static _CreateGLTFLoaderV1: () => IGLTFLoader;
  37708. /**
  37709. * Factory function that creates a glTF 2.0 loader
  37710. * @hidden
  37711. */
  37712. private static _CreateGLTFLoaderV2: () => IGLTFLoader;
  37713. /**
  37714. * Raised when the asset has been parsed
  37715. */
  37716. onParsedObservable: Observable<IGLTFLoaderData>;
  37717. private _onParsedObserver;
  37718. /**
  37719. * Raised when the asset has been parsed
  37720. */
  37721. onParsed: (loaderData: IGLTFLoaderData) => void;
  37722. /**
  37723. * 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.
  37724. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  37725. * Defaults to true.
  37726. */
  37727. static IncrementalLoading: boolean;
  37728. /**
  37729. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  37730. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  37731. */
  37732. static HomogeneousCoordinates: boolean;
  37733. /**
  37734. * The coordinate system mode. Defaults to AUTO.
  37735. */
  37736. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  37737. /**
  37738. * The animation start mode. Defaults to FIRST.
  37739. */
  37740. animationStartMode: GLTFLoaderAnimationStartMode;
  37741. /**
  37742. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  37743. */
  37744. compileMaterials: boolean;
  37745. /**
  37746. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  37747. */
  37748. useClipPlane: boolean;
  37749. /**
  37750. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  37751. */
  37752. compileShadowGenerators: boolean;
  37753. /**
  37754. * Defines if the Alpha blended materials are only applied as coverage.
  37755. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  37756. * If true, no extra effects are applied to transparent pixels.
  37757. */
  37758. transparencyAsCoverage: boolean;
  37759. /** @hidden */
  37760. /**
  37761. * Function called before loading a url referenced by the asset.
  37762. */
  37763. preprocessUrlAsync: (url: string) => Promise<string>;
  37764. /**
  37765. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  37766. */
  37767. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  37768. private _onMeshLoadedObserver;
  37769. /**
  37770. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  37771. */
  37772. onMeshLoaded: (mesh: AbstractMesh) => void;
  37773. /**
  37774. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  37775. */
  37776. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  37777. private _onTextureLoadedObserver;
  37778. /**
  37779. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  37780. */
  37781. onTextureLoaded: (texture: BaseTexture) => void;
  37782. /**
  37783. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  37784. */
  37785. readonly onMaterialLoadedObservable: Observable<Material>;
  37786. private _onMaterialLoadedObserver;
  37787. /**
  37788. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  37789. */
  37790. onMaterialLoaded: (material: Material) => void;
  37791. /**
  37792. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  37793. */
  37794. readonly onCameraLoadedObservable: Observable<Camera>;
  37795. private _onCameraLoadedObserver;
  37796. /**
  37797. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  37798. */
  37799. onCameraLoaded: (camera: Camera) => void;
  37800. /**
  37801. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  37802. * For assets with LODs, raised when all of the LODs are complete.
  37803. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  37804. */
  37805. readonly onCompleteObservable: Observable<GLTFFileLoader>;
  37806. private _onCompleteObserver;
  37807. /**
  37808. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  37809. */
  37810. onComplete: () => void;
  37811. /**
  37812. * Observable raised after the loader is disposed.
  37813. */
  37814. readonly onDisposeObservable: Observable<GLTFFileLoader>;
  37815. private _onDisposeObserver;
  37816. /**
  37817. * Callback raised after the loader is disposed.
  37818. */
  37819. onDispose: () => void;
  37820. /**
  37821. * Observable raised after a loader extension is created.
  37822. * Set additional options for a loader extension in this event.
  37823. */
  37824. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  37825. private _onExtensionLoadedObserver;
  37826. /**
  37827. * Callback raised after a loader extension is created.
  37828. */
  37829. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  37830. /**
  37831. * Returns a promise that resolves when the asset is completely loaded.
  37832. * @returns a promise that resolves when the asset is completely loaded.
  37833. */
  37834. whenCompleteAsync(): Promise<void>;
  37835. /**
  37836. * The loader state or null if the loader is not active.
  37837. */
  37838. readonly loaderState: Nullable<GLTFLoaderState>;
  37839. private _loader;
  37840. /**
  37841. * Name of the loader ("gltf")
  37842. */
  37843. name: string;
  37844. /**
  37845. * Supported file extensions of the loader (.gltf, .glb)
  37846. */
  37847. extensions: ISceneLoaderPluginExtensions;
  37848. /**
  37849. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  37850. */
  37851. dispose(): void;
  37852. /**
  37853. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  37854. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  37855. * @param scene the scene the meshes should be added to
  37856. * @param data the glTF data to load
  37857. * @param rootUrl root url to load from
  37858. * @param onProgress event that fires when loading progress has occured
  37859. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  37860. */
  37861. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  37862. meshes: AbstractMesh[];
  37863. particleSystems: ParticleSystem[];
  37864. skeletons: Skeleton[];
  37865. animationGroups: AnimationGroup[];
  37866. }>;
  37867. /**
  37868. * Imports all objects from the loaded glTF data and adds them to the scene
  37869. * @param scene the scene the objects should be added to
  37870. * @param data the glTF data to load
  37871. * @param rootUrl root url to load from
  37872. * @param onProgress event that fires when loading progress has occured
  37873. * @returns a promise which completes when objects have been loaded to the scene
  37874. */
  37875. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  37876. /**
  37877. * Load into an asset container.
  37878. * @param scene The scene to load into
  37879. * @param data The data to import
  37880. * @param rootUrl The root url for scene and resources
  37881. * @param onProgress The callback when the load progresses
  37882. * @returns The loaded asset container
  37883. */
  37884. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  37885. /**
  37886. * If the data string can be loaded directly.
  37887. * @param data string contianing the file data
  37888. * @returns if the data can be loaded directly
  37889. */
  37890. canDirectLoad(data: string): boolean;
  37891. /**
  37892. * Rewrites a url by combining a root url and response url.
  37893. */
  37894. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  37895. /**
  37896. * Instantiates a glTF file loader plugin.
  37897. * @returns the created plugin
  37898. */
  37899. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  37900. private _parse(data);
  37901. private _getLoader(loaderData);
  37902. private static _parseBinary(data);
  37903. private static _parseV1(binaryReader);
  37904. private static _parseV2(binaryReader);
  37905. private static _parseVersion(version);
  37906. private static _compareVersion(a, b);
  37907. private static _decodeBufferToText(buffer);
  37908. }
  37909. }
  37910. declare module BABYLON.GLTF2 {
  37911. /** @hidden */
  37912. interface _IArrayItem {
  37913. }
  37914. /** @hidden */
  37915. interface _ILoaderAccessor extends IAccessor, _IArrayItem {
  37916. }
  37917. /** @hidden */
  37918. interface _ILoaderAnimationChannel extends IAnimationChannel, _IArrayItem {
  37919. }
  37920. /** @hidden */
  37921. interface _ILoaderAnimationSamplerData {
  37922. input: Float32Array;
  37923. interpolation: AnimationSamplerInterpolation;
  37924. output: Float32Array;
  37925. }
  37926. /** @hidden */
  37927. interface _ILoaderAnimationSampler extends IAnimationSampler, _IArrayItem {
  37928. }
  37929. /** @hidden */
  37930. interface _ILoaderAnimation extends IAnimation, _IArrayItem {
  37931. channels: _ILoaderAnimationChannel[];
  37932. samplers: _ILoaderAnimationSampler[];
  37933. }
  37934. /** @hidden */
  37935. interface _ILoaderBuffer extends IBuffer, _IArrayItem {
  37936. }
  37937. /** @hidden */
  37938. interface _ILoaderBufferView extends IBufferView, _IArrayItem {
  37939. }
  37940. /** @hidden */
  37941. interface _ILoaderCamera extends ICamera, _IArrayItem {
  37942. }
  37943. /** @hidden */
  37944. interface _ILoaderImage extends IImage, _IArrayItem {
  37945. }
  37946. /** @hidden */
  37947. interface _ILoaderMaterial extends IMaterial, _IArrayItem {
  37948. ;
  37949. };
  37950. }
  37951. /** @hidden */
  37952. interface _ILoaderMesh extends IMesh, _IArrayItem {
  37953. primitives: _ILoaderMeshPrimitive[];
  37954. }
  37955. /** @hidden */
  37956. interface _ILoaderMeshPrimitive extends IMeshPrimitive, _IArrayItem {
  37957. }
  37958. /** @hidden */
  37959. interface _ILoaderNode extends INode, _IArrayItem {
  37960. }
  37961. /** @hidden */
  37962. interface _ILoaderSamplerData {
  37963. noMipMaps: boolean;
  37964. samplingMode: number;
  37965. wrapU: number;
  37966. wrapV: number;
  37967. }
  37968. /** @hidden */
  37969. interface _ILoaderSampler extends ISampler, _IArrayItem {
  37970. }
  37971. /** @hidden */
  37972. interface _ILoaderScene extends IScene, _IArrayItem {
  37973. }
  37974. /** @hidden */
  37975. interface _ILoaderSkin extends ISkin, _IArrayItem {
  37976. }
  37977. /** @hidden */
  37978. interface _ILoaderTexture extends ITexture, _IArrayItem {
  37979. }
  37980. /** @hidden */
  37981. interface _ILoaderGLTF extends IGLTF {
  37982. accessors?: _ILoaderAccessor[];
  37983. animations?: _ILoaderAnimation[];
  37984. buffers?: _ILoaderBuffer[];
  37985. bufferViews?: _ILoaderBufferView[];
  37986. cameras?: _ILoaderCamera[];
  37987. images?: _ILoaderImage[];
  37988. materials?: _ILoaderMaterial[];
  37989. meshes?: _ILoaderMesh[];
  37990. nodes?: _ILoaderNode[];
  37991. samplers?: _ILoaderSampler[];
  37992. scenes?: _ILoaderScene[];
  37993. skins?: _ILoaderSkin[];
  37994. textures?: _ILoaderTexture[];
  37995. }
  37996. }
  37997. /**
  37998. * Defines the module used to import/export glTF 2.0 assets
  37999. */
  38000. declare module BABYLON.GLTF2 {
  38001. /**
  38002. * Loader for loading a glTF 2.0 asset
  38003. */
  38004. class GLTFLoader implements IGLTFLoader {
  38005. /** @hidden */
  38006. /** @hidden */
  38007. /** @hidden */
  38008. /** @hidden */
  38009. private _disposed;
  38010. private _state;
  38011. private _extensions;
  38012. private _rootUrl;
  38013. private _rootBabylonMesh;
  38014. private _defaultSampler;
  38015. private _defaultBabylonMaterials;
  38016. private _progressCallback?;
  38017. private _requests;
  38018. private static _ExtensionNames;
  38019. private static _ExtensionFactories;
  38020. /** @hidden */
  38021. private static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
  38022. /**
  38023. * Mode that determines the coordinate system to use.
  38024. */
  38025. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  38026. /**
  38027. * Mode that determines what animations will start.
  38028. */
  38029. animationStartMode: GLTFLoaderAnimationStartMode;
  38030. /**
  38031. * Defines if the loader should compile materials.
  38032. */
  38033. compileMaterials: boolean;
  38034. /**
  38035. * Defines if the loader should also compile materials with clip planes.
  38036. */
  38037. useClipPlane: boolean;
  38038. /**
  38039. * Defines if the loader should compile shadow generators.
  38040. */
  38041. compileShadowGenerators: boolean;
  38042. /**
  38043. * Defines if the Alpha blended materials are only applied as coverage.
  38044. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  38045. * If true, no extra effects are applied to transparent pixels.
  38046. */
  38047. transparencyAsCoverage: boolean;
  38048. /** @hidden */
  38049. /**
  38050. * Function called before loading a url referenced by the asset.
  38051. */
  38052. preprocessUrlAsync: (url: string) => Promise<string>;
  38053. /**
  38054. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  38055. */
  38056. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  38057. /**
  38058. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  38059. */
  38060. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  38061. /**
  38062. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  38063. */
  38064. readonly onMaterialLoadedObservable: Observable<Material>;
  38065. /**
  38066. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  38067. */
  38068. readonly onCameraLoadedObservable: Observable<Camera>;
  38069. /**
  38070. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  38071. * For assets with LODs, raised when all of the LODs are complete.
  38072. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  38073. */
  38074. readonly onCompleteObservable: Observable<IGLTFLoader>;
  38075. /**
  38076. * Observable raised after the loader is disposed.
  38077. */
  38078. readonly onDisposeObservable: Observable<IGLTFLoader>;
  38079. /**
  38080. * Observable raised after a loader extension is created.
  38081. * Set additional options for a loader extension in this event.
  38082. */
  38083. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  38084. /**
  38085. * Loader state or null if the loader is not active.
  38086. */
  38087. readonly state: Nullable<GLTFLoaderState>;
  38088. /**
  38089. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  38090. */
  38091. dispose(): void;
  38092. /**
  38093. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  38094. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  38095. * @param scene the scene the meshes should be added to
  38096. * @param data the glTF data to load
  38097. * @param rootUrl root url to load from
  38098. * @param onProgress event that fires when loading progress has occured
  38099. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  38100. */
  38101. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  38102. meshes: AbstractMesh[];
  38103. particleSystems: ParticleSystem[];
  38104. skeletons: Skeleton[];
  38105. animationGroups: AnimationGroup[];
  38106. }>;
  38107. /**
  38108. * Imports all objects from the loaded glTF data and adds them to the scene
  38109. * @param scene the scene the objects should be added to
  38110. * @param data the glTF data to load
  38111. * @param rootUrl root url to load from
  38112. * @param onProgress event that fires when loading progress has occured
  38113. * @returns a promise which completes when objects have been loaded to the scene
  38114. */
  38115. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  38116. private _loadAsync(nodes);
  38117. private _loadData(data);
  38118. private _setupData();
  38119. private _loadExtensions();
  38120. private _checkExtensions();
  38121. private _createRootNode();
  38122. private _loadNodesAsync(nodes);
  38123. /** @hidden */
  38124. private _forEachPrimitive(node, callback);
  38125. private _getMeshes();
  38126. private _getSkeletons();
  38127. private _getAnimationGroups();
  38128. private _startAnimations();
  38129. /** @hidden */
  38130. private _loadMeshAsync(context, node, mesh, babylonMesh);
  38131. private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
  38132. private _loadVertexDataAsync(context, primitive, babylonMesh);
  38133. private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
  38134. private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
  38135. private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
  38136. private static _LoadTransform(node, babylonNode);
  38137. private _loadSkinAsync(context, node, mesh, skin);
  38138. private _loadBones(context, skin);
  38139. private _loadBone(node, skin, babylonBones);
  38140. private _loadSkinInverseBindMatricesDataAsync(context, skin);
  38141. private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
  38142. private _getNodeMatrix(node);
  38143. private _loadCamera(context, camera, babylonMesh);
  38144. private _loadAnimationsAsync();
  38145. private _loadAnimationAsync(context, animation);
  38146. private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
  38147. private _loadAnimationSamplerAsync(context, sampler);
  38148. private _loadBufferAsync(context, buffer);
  38149. /** @hidden */
  38150. private _loadIndicesAccessorAsync(context, accessor);
  38151. private _loadFloatAccessorAsync(context, accessor);
  38152. /** @hidden */
  38153. private _loadVertexAccessorAsync(context, accessor, kind);
  38154. private _getDefaultMaterial(drawMode);
  38155. private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
  38156. /** @hidden */
  38157. /** @hidden */
  38158. /** @hidden */
  38159. /** @hidden */
  38160. /** @hidden */
  38161. private _loadSampler(context, sampler);
  38162. private _loadImageAsync(context, image);
  38163. /** @hidden */
  38164. private _onProgress();
  38165. /** @hidden */
  38166. private static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  38167. private static _GetTextureWrapMode(context, mode);
  38168. private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
  38169. private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
  38170. private static _GetNumComponents(context, type);
  38171. private static _ValidateUri(uri);
  38172. private static _GetDrawMode(context, mode);
  38173. private _compileMaterialsAsync();
  38174. private _compileShadowGeneratorsAsync();
  38175. private _clear();
  38176. /** @hidden */
  38177. }
  38178. }
  38179. declare module BABYLON.GLTF2 {
  38180. /**
  38181. * Abstract class that can be implemented to extend existing glTF loader behavior.
  38182. */
  38183. abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable {
  38184. /**
  38185. * Gets or sets a boolean indicating if the extension is enabled
  38186. */
  38187. enabled: boolean;
  38188. /**
  38189. * Gets or sets extension name
  38190. */
  38191. readonly abstract name: string;
  38192. protected _loader: GLTFLoader;
  38193. /**
  38194. * Creates new GLTFLoaderExtension
  38195. * @param loader defines the GLTFLoader to use
  38196. */
  38197. constructor(loader: GLTFLoader);
  38198. /**
  38199. * Release all resources
  38200. */
  38201. dispose(): void;
  38202. /**
  38203. * Override this method to modify the default behavior for loading scenes.
  38204. * @hidden
  38205. */
  38206. protected _loadSceneAsync(context: string, node: _ILoaderScene): Nullable<Promise<void>>;
  38207. /**
  38208. * Override this method to modify the default behavior for loading nodes.
  38209. * @hidden
  38210. */
  38211. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  38212. /**
  38213. * Override this method to modify the default behavior for loading mesh primitive vertex data.
  38214. * @hidden
  38215. */
  38216. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  38217. /**
  38218. * Override this method to modify the default behavior for loading materials.
  38219. * @hidden
  38220. */
  38221. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38222. /**
  38223. * Override this method to modify the default behavior for loading textures.
  38224. * @hidden
  38225. */
  38226. protected _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  38227. /**
  38228. * Override this method to modify the default behavior for loading uris.
  38229. * @hidden
  38230. */
  38231. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  38232. /**
  38233. * Helper method called by a loader extension to load an glTF extension.
  38234. * @hidden
  38235. */
  38236. protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, extension: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  38237. /**
  38238. * Helper method called by the loader to allow extensions to override loading scenes.
  38239. * @hidden
  38240. */
  38241. protected _loadExtrasValueAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, value: TProperty) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  38242. /**
  38243. * Helper method called by the loader to allow extensions to override loading scenes.
  38244. * @hidden
  38245. */
  38246. private static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  38247. /**
  38248. * Helper method called by the loader to allow extensions to override loading nodes.
  38249. * @hidden
  38250. */
  38251. private static _LoadNodeAsync(loader: GLTFLoader, context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  38252. /**
  38253. * Helper method called by the loader to allow extensions to override loading mesh primitive vertex data.
  38254. * @hidden
  38255. */
  38256. private static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  38257. /**
  38258. * Helper method called by the loader to allow extensions to override loading materials.
  38259. * @hidden
  38260. */
  38261. private static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38262. /**
  38263. * Helper method called by the loader to allow extensions to override loading textures.
  38264. * @hidden
  38265. */
  38266. private static _LoadTextureAsync(loader: GLTFLoader, context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  38267. /**
  38268. * Helper method called by the loader to allow extensions to override loading uris.
  38269. * @hidden
  38270. */
  38271. private static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  38272. }
  38273. }
  38274. /**
  38275. * Defines the module of the glTF 2.0 loader extensions.
  38276. */
  38277. declare module BABYLON.GLTF2.Extensions {
  38278. }
  38279. declare module BABYLON.GLTF2.Extensions {
  38280. /**
  38281. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  38282. */
  38283. class MSFT_lod extends GLTFLoaderExtension {
  38284. readonly name: string;
  38285. /**
  38286. * Maximum number of LODs to load, starting from the lowest LOD.
  38287. */
  38288. maxLODsToLoad: number;
  38289. /**
  38290. * Observable raised when all node LODs of one level are loaded.
  38291. * The event data is the index of the loaded LOD starting from zero.
  38292. * Dispose the loader to cancel the loading of the next level of LODs.
  38293. */
  38294. onNodeLODsLoadedObservable: Observable<number>;
  38295. /**
  38296. * Observable raised when all material LODs of one level are loaded.
  38297. * The event data is the index of the loaded LOD starting from zero.
  38298. * Dispose the loader to cancel the loading of the next level of LODs.
  38299. */
  38300. onMaterialLODsLoadedObservable: Observable<number>;
  38301. private _loadingNodeLOD;
  38302. private _loadNodeSignals;
  38303. private _loadNodePromises;
  38304. private _loadingMaterialLOD;
  38305. private _loadMaterialSignals;
  38306. private _loadMaterialPromises;
  38307. constructor(loader: GLTFLoader);
  38308. dispose(): void;
  38309. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  38310. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38311. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  38312. /**
  38313. * Gets an array of LOD properties from lowest to highest.
  38314. */
  38315. private _getLODs<T>(context, property, array, ids);
  38316. }
  38317. }
  38318. declare module BABYLON.GLTF2.Extensions {
  38319. /** @hidden */
  38320. class MSFT_minecraftMesh extends GLTFLoaderExtension {
  38321. readonly name: string;
  38322. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38323. }
  38324. }
  38325. declare module BABYLON.GLTF2.Extensions {
  38326. /** @hidden */
  38327. class MSFT_sRGBFactors extends GLTFLoaderExtension {
  38328. readonly name: string;
  38329. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38330. }
  38331. }
  38332. declare module BABYLON.GLTF2.Extensions {
  38333. /**
  38334. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  38335. */
  38336. class KHR_draco_mesh_compression extends GLTFLoaderExtension {
  38337. readonly name: string;
  38338. private _dracoCompression;
  38339. constructor(loader: GLTFLoader);
  38340. dispose(): void;
  38341. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  38342. }
  38343. }
  38344. declare module BABYLON.GLTF2.Extensions {
  38345. /**
  38346. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  38347. */
  38348. class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
  38349. readonly name: string;
  38350. /** @hidden */
  38351. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38352. private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
  38353. }
  38354. }
  38355. declare module BABYLON.GLTF2.Extensions {
  38356. /**
  38357. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  38358. */
  38359. class KHR_materials_unlit extends GLTFLoaderExtension {
  38360. readonly name: string;
  38361. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, mesh: _ILoaderMesh, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  38362. private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
  38363. }
  38364. }
  38365. declare module BABYLON.GLTF2.Extensions {
  38366. /**
  38367. * [Specification](https://github.com/MiiBond/glTF/tree/khr_lights_v1/extensions/Khronos/KHR_lights) (Experimental)
  38368. */
  38369. class KHR_lights extends GLTFLoaderExtension {
  38370. readonly name: string;
  38371. protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  38372. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  38373. private readonly _lights;
  38374. }
  38375. }
  38376. declare module BABYLON.GLTF2.Extensions {
  38377. /**
  38378. * [Specification](https://github.com/AltspaceVR/glTF/blob/avr-sampler-offset-tile/extensions/2.0/Khronos/KHR_texture_transform/README.md) (Experimental)
  38379. */
  38380. class KHR_texture_transform extends GLTFLoaderExtension {
  38381. readonly name: string;
  38382. protected _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Nullable<Promise<void>>;
  38383. }
  38384. }
  38385. declare module BABYLON {
  38386. /**
  38387. * Holds a collection of exporter options and parameters
  38388. */
  38389. interface IExportOptions {
  38390. /**
  38391. * Function which indicates whether a babylon mesh should be exported or not
  38392. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  38393. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  38394. */
  38395. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  38396. /**
  38397. * The sample rate to bake animation curves
  38398. */
  38399. animationSampleRate?: number;
  38400. }
  38401. /**
  38402. * Class for generating glTF data from a Babylon scene.
  38403. */
  38404. class GLTF2Export {
  38405. /**
  38406. * Exports the geometry of the scene to .gltf file format asynchronously
  38407. * @param scene Babylon scene with scene hierarchy information
  38408. * @param filePrefix File prefix to use when generating the glTF file
  38409. * @param options Exporter options
  38410. * @returns Returns an object with a .gltf file and associates texture names
  38411. * as keys and their data and paths as values
  38412. */
  38413. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  38414. /**
  38415. * Exports the geometry of the scene to .glb file format asychronously
  38416. * @param scene Babylon scene with scene hierarchy information
  38417. * @param filePrefix File prefix to use when generating glb file
  38418. * @param options Exporter options
  38419. * @returns Returns an object with a .glb filename as key and data as value
  38420. */
  38421. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  38422. }
  38423. }
  38424. /**
  38425. * Module for the Babylon glTF 2.0 exporter. Should ONLY be used internally
  38426. * @hidden
  38427. */
  38428. declare module BABYLON.GLTF2 {
  38429. /**
  38430. * Converts Babylon Scene into glTF 2.0.
  38431. * @hidden
  38432. */
  38433. class _Exporter {
  38434. /**
  38435. * Stores all generated buffer views, which represents views into the main glTF buffer data
  38436. */
  38437. private bufferViews;
  38438. /**
  38439. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  38440. */
  38441. private accessors;
  38442. /**
  38443. * Stores all the generated nodes, which contains transform and/or mesh information per node
  38444. */
  38445. private nodes;
  38446. /**
  38447. * Stores the glTF asset information, which represents the glTF version and this file generator
  38448. */
  38449. private asset;
  38450. /**
  38451. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  38452. */
  38453. private scenes;
  38454. /**
  38455. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  38456. */
  38457. private meshes;
  38458. /**
  38459. * Stores all the generated material information, which represents the appearance of each primitive
  38460. */
  38461. private materials;
  38462. private materialMap;
  38463. /**
  38464. * Stores all the generated texture information, which is referenced by glTF materials
  38465. */
  38466. private textures;
  38467. /**
  38468. * Stores all the generated image information, which is referenced by glTF textures
  38469. */
  38470. private images;
  38471. /**
  38472. * Stores all the texture samplers
  38473. */
  38474. private samplers;
  38475. /**
  38476. * Stores all the generated animation samplers, which is referenced by glTF animations
  38477. */
  38478. /**
  38479. * Stores the animations for glTF models
  38480. */
  38481. private animations;
  38482. /**
  38483. * Stores the total amount of bytes stored in the glTF buffer
  38484. */
  38485. private totalByteLength;
  38486. /**
  38487. * Stores a reference to the Babylon scene containing the source geometry and material information
  38488. */
  38489. private babylonScene;
  38490. /**
  38491. * Stores a map of the image data, where the key is the file name and the value
  38492. * is the image data
  38493. */
  38494. private imageData;
  38495. /**
  38496. * Stores a map of the unique id of a node to its index in the node array
  38497. */
  38498. private nodeMap;
  38499. /**
  38500. * Specifies if the Babylon scene should be converted to right-handed on export
  38501. */
  38502. private convertToRightHandedSystem;
  38503. /**
  38504. * Baked animation sample rate
  38505. */
  38506. private animationSampleRate;
  38507. /**
  38508. * Callback which specifies if a transform node should be exported or not
  38509. */
  38510. private shouldExportTransformNode;
  38511. /**
  38512. * Creates a glTF Exporter instance, which can accept optional exporter options
  38513. * @param babylonScene Babylon scene object
  38514. * @param options Options to modify the behavior of the exporter
  38515. */
  38516. constructor(babylonScene: Scene, options?: IExportOptions);
  38517. private reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter);
  38518. /**
  38519. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  38520. * clock-wise during export to glTF
  38521. * @param submesh BabylonJS submesh
  38522. * @param primitiveMode Primitive mode of the mesh
  38523. * @param sideOrientation the winding order of the submesh
  38524. * @param vertexBufferKind The type of vertex attribute
  38525. * @param meshAttributeArray The vertex attribute data
  38526. * @param byteOffset The offset to the binary data
  38527. * @param binaryWriter The binary data for the glTF file
  38528. */
  38529. private reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  38530. /**
  38531. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  38532. * clock-wise during export to glTF
  38533. * @param submesh BabylonJS submesh
  38534. * @param primitiveMode Primitive mode of the mesh
  38535. * @param sideOrientation the winding order of the submesh
  38536. * @param vertexBufferKind The type of vertex attribute
  38537. * @param meshAttributeArray The vertex attribute data
  38538. * @param byteOffset The offset to the binary data
  38539. * @param binaryWriter The binary data for the glTF file
  38540. */
  38541. private reorderTriangleFillMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  38542. /**
  38543. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  38544. * clock-wise during export to glTF
  38545. * @param submesh BabylonJS submesh
  38546. * @param primitiveMode Primitive mode of the mesh
  38547. * @param sideOrientation the winding order of the submesh
  38548. * @param vertexBufferKind The type of vertex attribute
  38549. * @param meshAttributeArray The vertex attribute data
  38550. * @param byteOffset The offset to the binary data
  38551. * @param binaryWriter The binary data for the glTF file
  38552. */
  38553. private reorderTriangleStripDrawMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  38554. /**
  38555. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  38556. * clock-wise during export to glTF
  38557. * @param submesh BabylonJS submesh
  38558. * @param primitiveMode Primitive mode of the mesh
  38559. * @param sideOrientation the winding order of the submesh
  38560. * @param vertexBufferKind The type of vertex attribute
  38561. * @param meshAttributeArray The vertex attribute data
  38562. * @param byteOffset The offset to the binary data
  38563. * @param binaryWriter The binary data for the glTF file
  38564. */
  38565. private reorderTriangleFanMode(submesh, primitiveMode, sideOrientation, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter);
  38566. /**
  38567. * Writes the vertex attribute data to binary
  38568. * @param vertices The vertices to write to the binary writer
  38569. * @param byteOffset The offset into the binary writer to overwrite binary data
  38570. * @param vertexAttributeKind The vertex attribute type
  38571. * @param meshAttributeArray The vertex attribute data
  38572. * @param binaryWriter The writer containing the binary data
  38573. */
  38574. private writeVertexAttributeData(vertices, byteOffset, vertexAttributeKind, meshAttributeArray, binaryWriter);
  38575. /**
  38576. * Writes mesh attribute data to a data buffer
  38577. * Returns the bytelength of the data
  38578. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  38579. * @param meshAttributeArray Array containing the attribute data
  38580. * @param binaryWriter The buffer to write the binary data to
  38581. * @param indices Used to specify the order of the vertex data
  38582. */
  38583. private writeAttributeData(vertexBufferKind, meshAttributeArray, byteStride, binaryWriter);
  38584. /**
  38585. * Generates glTF json data
  38586. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  38587. * @param glTFPrefix Text to use when prefixing a glTF file
  38588. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  38589. * @returns json data as string
  38590. */
  38591. private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
  38592. /**
  38593. * Generates data for .gltf and .bin files based on the glTF prefix string
  38594. * @param glTFPrefix Text to use when prefixing a glTF file
  38595. * @returns GLTFData with glTF file data
  38596. */
  38597. /**
  38598. * Creates a binary buffer for glTF
  38599. * @returns array buffer for binary data
  38600. */
  38601. private _generateBinaryAsync();
  38602. /**
  38603. * Pads the number to a multiple of 4
  38604. * @param num number to pad
  38605. * @returns padded number
  38606. */
  38607. private _getPadding(num);
  38608. /**
  38609. * Generates a glb file from the json and binary data
  38610. * Returns an object with the glb file name as the key and data as the value
  38611. * @param glTFPrefix
  38612. * @returns object with glb filename as key and data as value
  38613. */
  38614. /**
  38615. * Sets the TRS for each node
  38616. * @param node glTF Node for storing the transformation data
  38617. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  38618. */
  38619. private setNodeTransformation(node, babylonTransformNode);
  38620. private getVertexBufferFromMesh(attributeKind, bufferMesh);
  38621. /**
  38622. * Creates a bufferview based on the vertices type for the Babylon mesh
  38623. * @param kind Indicates the type of vertices data
  38624. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  38625. * @param binaryWriter The buffer to write the bufferview data to
  38626. */
  38627. private createBufferViewKind(kind, babylonTransformNode, binaryWriter, byteStride);
  38628. /**
  38629. * The primitive mode of the Babylon mesh
  38630. * @param babylonMesh The BabylonJS mesh
  38631. */
  38632. private getMeshPrimitiveMode(babylonMesh);
  38633. /**
  38634. * Sets the primitive mode of the glTF mesh primitive
  38635. * @param meshPrimitive glTF mesh primitive
  38636. * @param primitiveMode The primitive mode
  38637. */
  38638. private setPrimitiveMode(meshPrimitive, primitiveMode);
  38639. /**
  38640. * Sets the vertex attribute accessor based of the glTF mesh primitive
  38641. * @param meshPrimitive glTF mesh primitive
  38642. * @param attributeKind vertex attribute
  38643. * @returns boolean specifying if uv coordinates are present
  38644. */
  38645. private setAttributeKind(meshPrimitive, attributeKind);
  38646. /**
  38647. * Sets data for the primitive attributes of each submesh
  38648. * @param mesh glTF Mesh object to store the primitive attribute information
  38649. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  38650. * @param binaryWriter Buffer to write the attribute data to
  38651. */
  38652. private setPrimitiveAttributes(mesh, babylonTransformNode, binaryWriter);
  38653. /**
  38654. * Creates a glTF scene based on the array of meshes
  38655. * Returns the the total byte offset
  38656. * @param babylonScene Babylon scene to get the mesh data from
  38657. * @param binaryWriter Buffer to write binary data to
  38658. */
  38659. private createSceneAsync(babylonScene, binaryWriter);
  38660. /**
  38661. * Creates a mapping of Node unique id to node index and handles animations
  38662. * @param babylonScene Babylon Scene
  38663. * @param nodes Babylon transform nodes
  38664. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  38665. * @param binaryWriter Buffer to write binary data to
  38666. * @returns Node mapping of unique id to index
  38667. */
  38668. private createNodeMapAndAnimations(babylonScene, nodes, shouldExportTransformNode, binaryWriter);
  38669. /**
  38670. * Creates a glTF node from a Babylon mesh
  38671. * @param babylonMesh Source Babylon mesh
  38672. * @param binaryWriter Buffer for storing geometry data
  38673. * @returns glTF node
  38674. */
  38675. private createNode(babylonTransformNode, binaryWriter);
  38676. }
  38677. /**
  38678. * @hidden
  38679. *
  38680. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  38681. */
  38682. class _BinaryWriter {
  38683. /**
  38684. * Array buffer which stores all binary data
  38685. */
  38686. private _arrayBuffer;
  38687. /**
  38688. * View of the array buffer
  38689. */
  38690. private _dataView;
  38691. /**
  38692. * byte offset of data in array buffer
  38693. */
  38694. private _byteOffset;
  38695. /**
  38696. * Initialize binary writer with an initial byte length
  38697. * @param byteLength Initial byte length of the array buffer
  38698. */
  38699. constructor(byteLength: number);
  38700. /**
  38701. * Resize the array buffer to the specified byte length
  38702. * @param byteLength
  38703. */
  38704. private resizeBuffer(byteLength);
  38705. /**
  38706. * Get an array buffer with the length of the byte offset
  38707. * @returns ArrayBuffer resized to the byte offset
  38708. */
  38709. getArrayBuffer(): ArrayBuffer;
  38710. /**
  38711. * Get the byte offset of the array buffer
  38712. * @returns byte offset
  38713. */
  38714. getByteOffset(): number;
  38715. /**
  38716. * Stores an UInt8 in the array buffer
  38717. * @param entry
  38718. * @param byteOffset If defined, specifies where to set the value as an offset.
  38719. */
  38720. setUInt8(entry: number, byteOffset?: number): void;
  38721. /**
  38722. * Gets an UInt32 in the array buffer
  38723. * @param entry
  38724. * @param byteOffset If defined, specifies where to set the value as an offset.
  38725. */
  38726. getUInt32(byteOffset: number): number;
  38727. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  38728. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  38729. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  38730. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  38731. /**
  38732. * Stores a Float32 in the array buffer
  38733. * @param entry
  38734. */
  38735. setFloat32(entry: number, byteOffset?: number): void;
  38736. /**
  38737. * Stores an UInt32 in the array buffer
  38738. * @param entry
  38739. * @param byteOffset If defined, specifies where to set the value as an offset.
  38740. */
  38741. setUInt32(entry: number, byteOffset?: number): void;
  38742. }
  38743. }
  38744. declare module BABYLON {
  38745. /**
  38746. * Class for holding and downloading glTF file data
  38747. */
  38748. class GLTFData {
  38749. /**
  38750. * Object which contains the file name as the key and its data as the value
  38751. */
  38752. glTFFiles: {
  38753. [fileName: string]: string | Blob;
  38754. };
  38755. /**
  38756. * Initializes the glTF file object
  38757. */
  38758. constructor();
  38759. /**
  38760. * Downloads the glTF data as files based on their names and data
  38761. */
  38762. downloadFiles(): void;
  38763. }
  38764. }
  38765. declare module BABYLON.GLTF2 {
  38766. /**
  38767. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  38768. * @hidden
  38769. */
  38770. class _GLTFMaterial {
  38771. /**
  38772. * Represents the dielectric specular values for R, G and B
  38773. */
  38774. private static readonly _dielectricSpecular;
  38775. /**
  38776. * Allows the maximum specular power to be defined for material calculations
  38777. */
  38778. private static _maxSpecularPower;
  38779. /**
  38780. * Numeric tolerance value
  38781. */
  38782. private static _epsilon;
  38783. /**
  38784. * Specifies if two colors are approximately equal in value
  38785. * @param color1 first color to compare to
  38786. * @param color2 second color to compare to
  38787. * @param epsilon threshold value
  38788. */
  38789. private static FuzzyEquals(color1, color2, epsilon);
  38790. /**
  38791. * Gets the materials from a Babylon scene and converts them to glTF materials
  38792. * @param scene babylonjs scene
  38793. * @param mimeType texture mime type
  38794. * @param images array of images
  38795. * @param textures array of textures
  38796. * @param materials array of materials
  38797. * @param imageData mapping of texture names to base64 textures
  38798. * @param hasTextureCoords specifies if texture coordinates are present on the material
  38799. */
  38800. private static _ConvertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  38801. [materialID: number]: number;
  38802. }, imageData: {
  38803. [fileName: string]: {
  38804. data: Uint8Array;
  38805. mimeType: ImageMimeType;
  38806. };
  38807. }, hasTextureCoords: boolean): Promise<void>;
  38808. /**
  38809. * Makes a copy of the glTF material without the texture parameters
  38810. * @param originalMaterial original glTF material
  38811. * @returns glTF material without texture parameters
  38812. */
  38813. private static _StripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  38814. /**
  38815. * Specifies if the material has any texture parameters present
  38816. * @param material glTF Material
  38817. * @returns boolean specifying if texture parameters are present
  38818. */
  38819. private static _HasTexturesPresent(material: IMaterial): boolean;
  38820. /**
  38821. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  38822. * @param babylonStandardMaterial
  38823. * @returns glTF Metallic Roughness Material representation
  38824. */
  38825. private static _ConvertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  38826. /**
  38827. * Computes the metallic factor
  38828. * @param diffuse diffused value
  38829. * @param specular specular value
  38830. * @param oneMinusSpecularStrength one minus the specular strength
  38831. * @returns metallic value
  38832. */
  38833. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  38834. /**
  38835. * Gets the glTF alpha mode from the Babylon Material
  38836. * @param babylonMaterial Babylon Material
  38837. * @returns The Babylon alpha mode value
  38838. */
  38839. private static _GetAlphaMode(babylonMaterial: Material): Nullable<MaterialAlphaMode>;
  38840. /**
  38841. * Converts a Babylon Standard Material to a glTF Material
  38842. * @param babylonStandardMaterial BJS Standard Material
  38843. * @param mimeType mime type to use for the textures
  38844. * @param images array of glTF image interfaces
  38845. * @param textures array of glTF texture interfaces
  38846. * @param materials array of glTF material interfaces
  38847. * @param imageData map of image file name to data
  38848. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  38849. */
  38850. private static _ConvertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  38851. [materialID: number]: number;
  38852. }, imageData: {
  38853. [fileName: string]: {
  38854. data: Uint8Array;
  38855. mimeType: ImageMimeType;
  38856. };
  38857. }, hasTextureCoords: boolean): Promise<void>;
  38858. /**
  38859. *
  38860. * @param texture Texture with alpha to overwrite to one
  38861. * @param useAlpha Specifies if alpha should be preserved or not
  38862. * @returns Promise with texture
  38863. */
  38864. private static _SetAlphaToOneAsync(texture: BaseTexture, useAlpha: boolean): Promise<Texture>;
  38865. /**
  38866. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  38867. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  38868. * @param mimeType mime type to use for the textures
  38869. * @param images array of glTF image interfaces
  38870. * @param textures array of glTF texture interfaces
  38871. * @param materials array of glTF material interfaces
  38872. * @param imageData map of image file name to data
  38873. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  38874. */
  38875. private static _ConvertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  38876. [materialID: number]: number;
  38877. }, imageData: {
  38878. [fileName: string]: {
  38879. data: Uint8Array;
  38880. mimeType: ImageMimeType;
  38881. };
  38882. }, hasTextureCoords: boolean): Promise<void>;
  38883. /**
  38884. * Converts an image typed array buffer to a base64 image
  38885. * @param buffer typed array buffer
  38886. * @param width width of the image
  38887. * @param height height of the image
  38888. * @param mimeType mimetype of the image
  38889. * @returns base64 image string
  38890. */
  38891. private static _CreateBase64FromCanvas(buffer, width, height, mimeType);
  38892. /**
  38893. * Generates a white texture based on the specified width and height
  38894. * @param width width of the texture in pixels
  38895. * @param height height of the texture in pixels
  38896. * @param scene babylonjs scene
  38897. * @returns white texture
  38898. */
  38899. private static _CreateWhiteTexture(width, height, scene);
  38900. /**
  38901. * 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
  38902. * @param texture1 first texture to resize
  38903. * @param texture2 second texture to resize
  38904. * @param scene babylonjs scene
  38905. * @returns resized textures or null
  38906. */
  38907. private static _ResizeTexturesToSameDimensions(texture1, texture2, scene);
  38908. /**
  38909. * Convert Specular Glossiness Textures to Metallic Roughness
  38910. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  38911. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  38912. * @param diffuseTexture texture used to store diffuse information
  38913. * @param specularGlossinessTexture texture used to store specular and glossiness information
  38914. * @param factors specular glossiness material factors
  38915. * @param mimeType the mime type to use for the texture
  38916. * @returns pbr metallic roughness interface or null
  38917. */
  38918. private static _ConvertSpecularGlossinessTexturesToMetallicRoughness(diffuseTexture, specularGlossinessTexture, factors, mimeType);
  38919. /**
  38920. * Converts specular glossiness material properties to metallic roughness
  38921. * @param specularGlossiness interface with specular glossiness material properties
  38922. * @returns interface with metallic roughness material properties
  38923. */
  38924. private static _ConvertSpecularGlossinessToMetallicRoughness(specularGlossiness);
  38925. /**
  38926. * Calculates the surface reflectance, independent of lighting conditions
  38927. * @param color Color source to calculate brightness from
  38928. * @returns number representing the perceived brightness, or zero if color is undefined
  38929. */
  38930. private static _GetPerceivedBrightness(color);
  38931. /**
  38932. * Returns the maximum color component value
  38933. * @param color
  38934. * @returns maximum color component value, or zero if color is null or undefined
  38935. */
  38936. private static _GetMaxComponent(color);
  38937. /**
  38938. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  38939. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  38940. * @param mimeType mime type to use for the textures
  38941. * @param images array of glTF image interfaces
  38942. * @param textures array of glTF texture interfaces
  38943. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  38944. * @param imageData map of image file name to data
  38945. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  38946. * @returns glTF PBR Metallic Roughness factors
  38947. */
  38948. private static _ConvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  38949. private static _GetGLTFTextureSampler(texture);
  38950. private static _GetGLTFTextureWrapMode(wrapMode);
  38951. private static _GetGLTFTextureWrapModesSampler(texture);
  38952. /**
  38953. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  38954. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  38955. * @param mimeType mime type to use for the textures
  38956. * @param images array of glTF image interfaces
  38957. * @param textures array of glTF texture interfaces
  38958. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  38959. * @param imageData map of image file name to data
  38960. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  38961. * @returns glTF PBR Metallic Roughness factors
  38962. */
  38963. private static _ConvertSpecGlossFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  38964. /**
  38965. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  38966. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  38967. * @param mimeType mime type to use for the textures
  38968. * @param images array of glTF image interfaces
  38969. * @param textures array of glTF texture interfaces
  38970. * @param materials array of glTF material interfaces
  38971. * @param imageData map of image file name to data
  38972. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  38973. */
  38974. private static _ConvertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], materialMap: {
  38975. [materialID: number]: number;
  38976. }, imageData: {
  38977. [fileName: string]: {
  38978. data: Uint8Array;
  38979. mimeType: ImageMimeType;
  38980. };
  38981. }, hasTextureCoords: boolean): Promise<void>;
  38982. private static SetMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, images, textures, samplers, materials, materialMap, imageData, hasTextureCoords);
  38983. private static GetPixelsFromTexture(babylonTexture);
  38984. /**
  38985. * Extracts a texture from a Babylon texture into file data and glTF data
  38986. * @param babylonTexture Babylon texture to extract
  38987. * @param mimeType Mime Type of the babylonTexture
  38988. * @param images Array of glTF images
  38989. * @param textures Array of glTF textures
  38990. * @param imageData map of image file name and data
  38991. * @return glTF texture info, or null if the texture format is not supported
  38992. */
  38993. private static _ExportTextureAsync(babylonTexture, mimeType, images, textures, samplers, imageData, useAlpha);
  38994. /**
  38995. * Builds a texture from base64 string
  38996. * @param base64Texture base64 texture string
  38997. * @param textureName Name to use for the texture
  38998. * @param mimeType image mime type for the texture
  38999. * @param images array of images
  39000. * @param textures array of textures
  39001. * @param imageData map of image data
  39002. * @returns glTF texture info, or null if the texture format is not supported
  39003. */
  39004. private static _GetTextureInfoFromBase64(base64Texture, textureName, mimeType, images, textures, texCoordIndex, samplerIndex, imageData);
  39005. }
  39006. }
  39007. declare module BABYLON.GLTF2 {
  39008. /**
  39009. * @hidden
  39010. * Interface to store animation data.
  39011. */
  39012. interface _IAnimationData {
  39013. /**
  39014. * Keyframe data.
  39015. */
  39016. inputs: number[];
  39017. /**
  39018. * Value data.
  39019. */
  39020. outputs: number[][];
  39021. /**
  39022. * Animation interpolation data.
  39023. */
  39024. samplerInterpolation: AnimationSamplerInterpolation;
  39025. /**
  39026. * Minimum keyframe value.
  39027. */
  39028. inputsMin: number;
  39029. /**
  39030. * Maximum keyframe value.
  39031. */
  39032. inputsMax: number;
  39033. }
  39034. /**
  39035. * @hidden
  39036. */
  39037. interface _IAnimationInfo {
  39038. /**
  39039. * The target channel for the animation
  39040. */
  39041. animationChannelTargetPath: AnimationChannelTargetPath;
  39042. /**
  39043. * The glTF accessor type for the data.
  39044. */
  39045. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  39046. /**
  39047. * Specifies if quaternions should be used.
  39048. */
  39049. useQuaternion: boolean;
  39050. }
  39051. /**
  39052. * @hidden
  39053. * Utility class for generating glTF animation data from BabylonJS.
  39054. */
  39055. class _GLTFAnimation {
  39056. /**
  39057. * @ignore
  39058. *
  39059. * Creates glTF channel animation from BabylonJS animation.
  39060. * @param babylonTransformNode - BabylonJS mesh.
  39061. * @param animation - animation.
  39062. * @param animationChannelTargetPath - The target animation channel.
  39063. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  39064. * @param useQuaternion - Specifies if quaternions are used.
  39065. * @returns nullable IAnimationData
  39066. */
  39067. private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  39068. private static _DeduceAnimationInfo(animation);
  39069. /**
  39070. * @ignore
  39071. * Create node animations from the transform node animations
  39072. * @param babylonTransformNode
  39073. * @param runtimeGLTFAnimation
  39074. * @param idleGLTFAnimations
  39075. * @param nodeMap
  39076. * @param nodes
  39077. * @param binaryWriter
  39078. * @param bufferViews
  39079. * @param accessors
  39080. * @param convertToRightHandedSystem
  39081. */
  39082. private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  39083. [key: number]: number;
  39084. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  39085. /**
  39086. * @ignore
  39087. * Create node animations from the animation groups
  39088. * @param babylonScene
  39089. * @param glTFAnimations
  39090. * @param nodeMap
  39091. * @param nodes
  39092. * @param binaryWriter
  39093. * @param bufferViews
  39094. * @param accessors
  39095. * @param convertToRightHandedSystem
  39096. */
  39097. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  39098. [key: number]: number;
  39099. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  39100. private static AddAnimation(name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
  39101. /**
  39102. * Create a baked animation
  39103. * @param babylonTransformNode BabylonJS mesh
  39104. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  39105. * @param animationChannelTargetPath animation target channel
  39106. * @param minFrame minimum animation frame
  39107. * @param maxFrame maximum animation frame
  39108. * @param fps frames per second of the animation
  39109. * @param inputs input key frames of the animation
  39110. * @param outputs output key frame data of the animation
  39111. * @param convertToRightHandedSystem converts the values to right-handed
  39112. * @param useQuaternion specifies if quaternions should be used
  39113. */
  39114. private static _CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
  39115. private static _ConvertFactorToVector3OrQuaternion(factor, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  39116. private static _SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39117. /**
  39118. * Creates linear animation from the animation key frames
  39119. * @param babylonTransformNode BabylonJS mesh
  39120. * @param animation BabylonJS animation
  39121. * @param animationChannelTargetPath The target animation channel
  39122. * @param frameDelta The difference between the last and first frame of the animation
  39123. * @param inputs Array to store the key frame times
  39124. * @param outputs Array to store the key frame data
  39125. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  39126. * @param useQuaternion Specifies if quaternions are used in the animation
  39127. */
  39128. private static _CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39129. /**
  39130. * Creates cubic spline animation from the animation key frames
  39131. * @param babylonTransformNode BabylonJS mesh
  39132. * @param animation BabylonJS animation
  39133. * @param animationChannelTargetPath The target animation channel
  39134. * @param frameDelta The difference between the last and first frame of the animation
  39135. * @param inputs Array to store the key frame times
  39136. * @param outputs Array to store the key frame data
  39137. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  39138. * @param useQuaternion Specifies if quaternions are used in the animation
  39139. */
  39140. private static _CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  39141. private static _GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  39142. /**
  39143. * Adds a key frame value
  39144. * @param keyFrame
  39145. * @param animation
  39146. * @param outputs
  39147. * @param animationChannelTargetPath
  39148. * @param basePositionRotationOrScale
  39149. * @param convertToRightHandedSystem
  39150. * @param useQuaternion
  39151. */
  39152. private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, convertToRightHandedSystem, useQuaternion);
  39153. /**
  39154. * Determine the interpolation based on the key frames
  39155. * @param keyFrames
  39156. * @param animationChannelTargetPath
  39157. * @param useQuaternion
  39158. */
  39159. private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
  39160. /**
  39161. * Adds an input tangent or output tangent to the output data
  39162. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  39163. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  39164. * @param outputs The animation data by keyframe
  39165. * @param animationChannelTargetPath The target animation channel
  39166. * @param interpolation The interpolation type
  39167. * @param keyFrame The key frame with the animation data
  39168. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  39169. * @param useQuaternion Specifies if quaternions are used
  39170. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  39171. */
  39172. private static AddSplineTangent(babylonTransformNode, tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
  39173. /**
  39174. * Get the minimum and maximum key frames' frame values
  39175. * @param keyFrames animation key frames
  39176. * @returns the minimum and maximum key frame value
  39177. */
  39178. private static calculateMinMaxKeyFrames(keyFrames);
  39179. }
  39180. }
  39181. declare module BABYLON.GLTF2 {
  39182. /**
  39183. * @hidden
  39184. */
  39185. class _GLTFUtilities {
  39186. /**
  39187. * Creates a buffer view based on the supplied arguments
  39188. * @param bufferIndex index value of the specified buffer
  39189. * @param byteOffset byte offset value
  39190. * @param byteLength byte length of the bufferView
  39191. * @param byteStride byte distance between conequential elements
  39192. * @param name name of the buffer view
  39193. * @returns bufferView for glTF
  39194. */
  39195. static CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  39196. /**
  39197. * Creates an accessor based on the supplied arguments
  39198. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  39199. * @param name The name of the accessor
  39200. * @param type The type of the accessor
  39201. * @param componentType The datatype of components in the attribute
  39202. * @param count The number of attributes referenced by this accessor
  39203. * @param byteOffset The offset relative to the start of the bufferView in bytes
  39204. * @param min Minimum value of each component in this attribute
  39205. * @param max Maximum value of each component in this attribute
  39206. * @returns accessor for glTF
  39207. */
  39208. static CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  39209. /**
  39210. * Calculates the minimum and maximum values of an array of position floats
  39211. * @param positions Positions array of a mesh
  39212. * @param vertexStart Starting vertex offset to calculate min and max values
  39213. * @param vertexCount Number of vertices to check for min and max values
  39214. * @returns min number array and max number array
  39215. */
  39216. static CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  39217. min: number[];
  39218. max: number[];
  39219. };
  39220. /**
  39221. * Converts a new right-handed Vector3
  39222. * @param vector vector3 array
  39223. * @returns right-handed Vector3
  39224. */
  39225. static GetRightHandedPositionVector3(vector: Vector3): Vector3;
  39226. /**
  39227. * Converts a Vector3 to right-handed
  39228. * @param vector Vector3 to convert to right-handed
  39229. */
  39230. static GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  39231. /**
  39232. * Converts a three element number array to right-handed
  39233. * @param vector number array to convert to right-handed
  39234. */
  39235. static GetRightHandedPositionArray3FromRef(vector: number[]): void;
  39236. /**
  39237. * Converts a new right-handed Vector3
  39238. * @param vector vector3 array
  39239. * @returns right-handed Vector3
  39240. */
  39241. static GetRightHandedNormalVector3(vector: Vector3): Vector3;
  39242. /**
  39243. * Converts a Vector3 to right-handed
  39244. * @param vector Vector3 to convert to right-handed
  39245. */
  39246. static GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  39247. /**
  39248. * Converts a three element number array to right-handed
  39249. * @param vector number array to convert to right-handed
  39250. */
  39251. static GetRightHandedNormalArray3FromRef(vector: number[]): void;
  39252. /**
  39253. * Converts a Vector4 to right-handed
  39254. * @param vector Vector4 to convert to right-handed
  39255. */
  39256. static GetRightHandedVector4FromRef(vector: Vector4): void;
  39257. /**
  39258. * Converts a Vector4 to right-handed
  39259. * @param vector Vector4 to convert to right-handed
  39260. */
  39261. static GetRightHandedArray4FromRef(vector: number[]): void;
  39262. /**
  39263. * Converts a Quaternion to right-handed
  39264. * @param quaternion Source quaternion to convert to right-handed
  39265. */
  39266. static GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  39267. /**
  39268. * Converts a Quaternion to right-handed
  39269. * @param quaternion Source quaternion to convert to right-handed
  39270. */
  39271. static GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  39272. }
  39273. }
  39274. /**
  39275. * @ignoreChildren
  39276. * @ignore
  39277. */
  39278. declare module "babylonjs-gltf2interface" {
  39279. export = BABYLON.GLTF2;
  39280. }
  39281. /**
  39282. * Moduel for glTF 2.0 Interface
  39283. */
  39284. declare module BABYLON.GLTF2 {
  39285. /**
  39286. * The datatype of the components in the attribute
  39287. */
  39288. const enum AccessorComponentType {
  39289. /**
  39290. * Byte
  39291. */
  39292. BYTE = 5120,
  39293. /**
  39294. * Unsigned Byte
  39295. */
  39296. UNSIGNED_BYTE = 5121,
  39297. /**
  39298. * Short
  39299. */
  39300. SHORT = 5122,
  39301. /**
  39302. * Unsigned Short
  39303. */
  39304. UNSIGNED_SHORT = 5123,
  39305. /**
  39306. * Unsigned Int
  39307. */
  39308. UNSIGNED_INT = 5125,
  39309. /**
  39310. * Float
  39311. */
  39312. FLOAT = 5126,
  39313. }
  39314. /**
  39315. * Specifies if the attirbute is a scalar, vector, or matrix
  39316. */
  39317. const enum AccessorType {
  39318. /**
  39319. * Scalar
  39320. */
  39321. SCALAR = "SCALAR",
  39322. /**
  39323. * Vector2
  39324. */
  39325. VEC2 = "VEC2",
  39326. /**
  39327. * Vector3
  39328. */
  39329. VEC3 = "VEC3",
  39330. /**
  39331. * Vector4
  39332. */
  39333. VEC4 = "VEC4",
  39334. /**
  39335. * Matrix2x2
  39336. */
  39337. MAT2 = "MAT2",
  39338. /**
  39339. * Matrix3x3
  39340. */
  39341. MAT3 = "MAT3",
  39342. /**
  39343. * Matrix4x4
  39344. */
  39345. MAT4 = "MAT4",
  39346. }
  39347. /**
  39348. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  39349. */
  39350. const enum AnimationChannelTargetPath {
  39351. /**
  39352. * Translation
  39353. */
  39354. TRANSLATION = "translation",
  39355. /**
  39356. * Rotation
  39357. */
  39358. ROTATION = "rotation",
  39359. /**
  39360. * Scale
  39361. */
  39362. SCALE = "scale",
  39363. /**
  39364. * Weights
  39365. */
  39366. WEIGHTS = "weights",
  39367. }
  39368. /**
  39369. * Interpolation algorithm
  39370. */
  39371. const enum AnimationSamplerInterpolation {
  39372. /**
  39373. * The animated values are linearly interpolated between keyframes
  39374. */
  39375. LINEAR = "LINEAR",
  39376. /**
  39377. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  39378. */
  39379. STEP = "STEP",
  39380. /**
  39381. * The animation's interpolation is computed using a cubic spline with specified tangents
  39382. */
  39383. CUBICSPLINE = "CUBICSPLINE",
  39384. }
  39385. /**
  39386. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  39387. */
  39388. const enum CameraType {
  39389. /**
  39390. * A perspective camera containing properties to create a perspective projection matrix
  39391. */
  39392. PERSPECTIVE = "perspective",
  39393. /**
  39394. * An orthographic camera containing properties to create an orthographic projection matrix
  39395. */
  39396. ORTHOGRAPHIC = "orthographic",
  39397. }
  39398. /**
  39399. * The mime-type of the image
  39400. */
  39401. const enum ImageMimeType {
  39402. /**
  39403. * JPEG Mime-type
  39404. */
  39405. JPEG = "image/jpeg",
  39406. /**
  39407. * PNG Mime-type
  39408. */
  39409. PNG = "image/png",
  39410. }
  39411. /**
  39412. * The alpha rendering mode of the material
  39413. */
  39414. const enum MaterialAlphaMode {
  39415. /**
  39416. * The alpha value is ignored and the rendered output is fully opaque
  39417. */
  39418. OPAQUE = "OPAQUE",
  39419. /**
  39420. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  39421. */
  39422. MASK = "MASK",
  39423. /**
  39424. * 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)
  39425. */
  39426. BLEND = "BLEND",
  39427. }
  39428. /**
  39429. * The type of the primitives to render
  39430. */
  39431. const enum MeshPrimitiveMode {
  39432. /**
  39433. * Points
  39434. */
  39435. POINTS = 0,
  39436. /**
  39437. * Lines
  39438. */
  39439. LINES = 1,
  39440. /**
  39441. * Line Loop
  39442. */
  39443. LINE_LOOP = 2,
  39444. /**
  39445. * Line Strip
  39446. */
  39447. LINE_STRIP = 3,
  39448. /**
  39449. * Triangles
  39450. */
  39451. TRIANGLES = 4,
  39452. /**
  39453. * Triangle Strip
  39454. */
  39455. TRIANGLE_STRIP = 5,
  39456. /**
  39457. * Triangle Fan
  39458. */
  39459. TRIANGLE_FAN = 6,
  39460. }
  39461. /**
  39462. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  39463. */
  39464. const enum TextureMagFilter {
  39465. /**
  39466. * Nearest
  39467. */
  39468. NEAREST = 9728,
  39469. /**
  39470. * Linear
  39471. */
  39472. LINEAR = 9729,
  39473. }
  39474. /**
  39475. * Minification filter. All valid values correspond to WebGL enums
  39476. */
  39477. const enum TextureMinFilter {
  39478. /**
  39479. * Nearest
  39480. */
  39481. NEAREST = 9728,
  39482. /**
  39483. * Linear
  39484. */
  39485. LINEAR = 9729,
  39486. /**
  39487. * Nearest Mip-Map Nearest
  39488. */
  39489. NEAREST_MIPMAP_NEAREST = 9984,
  39490. /**
  39491. * Linear Mipmap Nearest
  39492. */
  39493. LINEAR_MIPMAP_NEAREST = 9985,
  39494. /**
  39495. * Nearest Mipmap Linear
  39496. */
  39497. NEAREST_MIPMAP_LINEAR = 9986,
  39498. /**
  39499. * Linear Mipmap Linear
  39500. */
  39501. LINEAR_MIPMAP_LINEAR = 9987,
  39502. }
  39503. /**
  39504. * S (U) wrapping mode. All valid values correspond to WebGL enums
  39505. */
  39506. const enum TextureWrapMode {
  39507. /**
  39508. * Clamp to Edge
  39509. */
  39510. CLAMP_TO_EDGE = 33071,
  39511. /**
  39512. * Mirrored Repeat
  39513. */
  39514. MIRRORED_REPEAT = 33648,
  39515. /**
  39516. * Repeat
  39517. */
  39518. REPEAT = 10497,
  39519. }
  39520. /**
  39521. * glTF Property
  39522. */
  39523. interface IProperty {
  39524. /**
  39525. * Dictionary object with extension-specific objects
  39526. */
  39527. extensions?: {
  39528. [key: string]: any;
  39529. };
  39530. /**
  39531. * Application-Specific data
  39532. */
  39533. extras?: any;
  39534. }
  39535. /**
  39536. * glTF Child of Root Property
  39537. */
  39538. interface IChildRootProperty extends IProperty {
  39539. /**
  39540. * The user-defined name of this object
  39541. */
  39542. name?: string;
  39543. }
  39544. /**
  39545. * Indices of those attributes that deviate from their initialization value
  39546. */
  39547. interface IAccessorSparseIndices extends IProperty {
  39548. /**
  39549. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  39550. */
  39551. bufferView: number;
  39552. /**
  39553. * The offset relative to the start of the bufferView in bytes. Must be aligned
  39554. */
  39555. byteOffset?: number;
  39556. /**
  39557. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  39558. */
  39559. componentType: AccessorComponentType;
  39560. }
  39561. /**
  39562. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  39563. */
  39564. interface IAccessorSparseValues extends IProperty {
  39565. /**
  39566. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  39567. */
  39568. bufferView: number;
  39569. /**
  39570. * The offset relative to the start of the bufferView in bytes. Must be aligned
  39571. */
  39572. byteOffset?: number;
  39573. }
  39574. /**
  39575. * Sparse storage of attributes that deviate from their initialization value
  39576. */
  39577. interface IAccessorSparse extends IProperty {
  39578. /**
  39579. * The number of attributes encoded in this sparse accessor
  39580. */
  39581. count: number;
  39582. /**
  39583. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  39584. */
  39585. indices: IAccessorSparseIndices;
  39586. /**
  39587. * 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
  39588. */
  39589. values: IAccessorSparseValues;
  39590. }
  39591. /**
  39592. * 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
  39593. */
  39594. interface IAccessor extends IChildRootProperty {
  39595. /**
  39596. * The index of the bufferview
  39597. */
  39598. bufferView?: number;
  39599. /**
  39600. * The offset relative to the start of the bufferView in bytes
  39601. */
  39602. byteOffset?: number;
  39603. /**
  39604. * The datatype of components in the attribute
  39605. */
  39606. componentType: AccessorComponentType;
  39607. /**
  39608. * Specifies whether integer data values should be normalized
  39609. */
  39610. normalized?: boolean;
  39611. /**
  39612. * The number of attributes referenced by this accessor
  39613. */
  39614. count: number;
  39615. /**
  39616. * Specifies if the attribute is a scalar, vector, or matrix
  39617. */
  39618. type: AccessorType;
  39619. /**
  39620. * Maximum value of each component in this attribute
  39621. */
  39622. max?: number[];
  39623. /**
  39624. * Minimum value of each component in this attribute
  39625. */
  39626. min?: number[];
  39627. /**
  39628. * Sparse storage of attributes that deviate from their initialization value
  39629. */
  39630. sparse?: IAccessorSparse;
  39631. }
  39632. /**
  39633. * Targets an animation's sampler at a node's property
  39634. */
  39635. interface IAnimationChannel extends IProperty {
  39636. /**
  39637. * The index of a sampler in this animation used to compute the value for the target
  39638. */
  39639. sampler: number;
  39640. /**
  39641. * The index of the node and TRS property to target
  39642. */
  39643. target: IAnimationChannelTarget;
  39644. }
  39645. /**
  39646. * The index of the node and TRS property that an animation channel targets
  39647. */
  39648. interface IAnimationChannelTarget extends IProperty {
  39649. /**
  39650. * The index of the node to target
  39651. */
  39652. node: number;
  39653. /**
  39654. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  39655. */
  39656. path: AnimationChannelTargetPath;
  39657. }
  39658. /**
  39659. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  39660. */
  39661. interface IAnimationSampler extends IProperty {
  39662. /**
  39663. * The index of an accessor containing keyframe input values, e.g., time
  39664. */
  39665. input: number;
  39666. /**
  39667. * Interpolation algorithm
  39668. */
  39669. interpolation?: AnimationSamplerInterpolation;
  39670. /**
  39671. * The index of an accessor, containing keyframe output values
  39672. */
  39673. output: number;
  39674. }
  39675. /**
  39676. * A keyframe animation
  39677. */
  39678. interface IAnimation extends IChildRootProperty {
  39679. /**
  39680. * An array of channels, each of which targets an animation's sampler at a node's property
  39681. */
  39682. channels: IAnimationChannel[];
  39683. /**
  39684. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  39685. */
  39686. samplers: IAnimationSampler[];
  39687. }
  39688. /**
  39689. * Metadata about the glTF asset
  39690. */
  39691. interface IAsset extends IChildRootProperty {
  39692. /**
  39693. * A copyright message suitable for display to credit the content creator
  39694. */
  39695. copyright?: string;
  39696. /**
  39697. * Tool that generated this glTF model. Useful for debugging
  39698. */
  39699. generator?: string;
  39700. /**
  39701. * The glTF version that this asset targets
  39702. */
  39703. version: string;
  39704. /**
  39705. * The minimum glTF version that this asset targets
  39706. */
  39707. minVersion?: string;
  39708. }
  39709. /**
  39710. * A buffer points to binary geometry, animation, or skins
  39711. */
  39712. interface IBuffer extends IChildRootProperty {
  39713. /**
  39714. * 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
  39715. */
  39716. uri?: string;
  39717. /**
  39718. * The length of the buffer in bytes
  39719. */
  39720. byteLength: number;
  39721. }
  39722. /**
  39723. * A view into a buffer generally representing a subset of the buffer
  39724. */
  39725. interface IBufferView extends IChildRootProperty {
  39726. /**
  39727. * The index of the buffer
  39728. */
  39729. buffer: number;
  39730. /**
  39731. * The offset into the buffer in bytes
  39732. */
  39733. byteOffset?: number;
  39734. /**
  39735. * The lenth of the bufferView in bytes
  39736. */
  39737. byteLength: number;
  39738. /**
  39739. * The stride, in bytes
  39740. */
  39741. byteStride?: number;
  39742. }
  39743. /**
  39744. * An orthographic camera containing properties to create an orthographic projection matrix
  39745. */
  39746. interface ICameraOrthographic extends IProperty {
  39747. /**
  39748. * The floating-point horizontal magnification of the view. Must not be zero
  39749. */
  39750. xmag: number;
  39751. /**
  39752. * The floating-point vertical magnification of the view. Must not be zero
  39753. */
  39754. ymag: number;
  39755. /**
  39756. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  39757. */
  39758. zfar: number;
  39759. /**
  39760. * The floating-point distance to the near clipping plane
  39761. */
  39762. znear: number;
  39763. }
  39764. /**
  39765. * A perspective camera containing properties to create a perspective projection matrix
  39766. */
  39767. interface ICameraPerspective extends IProperty {
  39768. /**
  39769. * The floating-point aspect ratio of the field of view
  39770. */
  39771. aspectRatio?: number;
  39772. /**
  39773. * The floating-point vertical field of view in radians
  39774. */
  39775. yfov: number;
  39776. /**
  39777. * The floating-point distance to the far clipping plane
  39778. */
  39779. zfar?: number;
  39780. /**
  39781. * The floating-point distance to the near clipping plane
  39782. */
  39783. znear: number;
  39784. }
  39785. /**
  39786. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  39787. */
  39788. interface ICamera extends IChildRootProperty {
  39789. /**
  39790. * An orthographic camera containing properties to create an orthographic projection matrix
  39791. */
  39792. orthographic?: ICameraOrthographic;
  39793. /**
  39794. * A perspective camera containing properties to create a perspective projection matrix
  39795. */
  39796. perspective?: ICameraPerspective;
  39797. /**
  39798. * Specifies if the camera uses a perspective or orthographic projection
  39799. */
  39800. type: CameraType;
  39801. }
  39802. /**
  39803. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  39804. */
  39805. interface IImage extends IChildRootProperty {
  39806. /**
  39807. * 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
  39808. */
  39809. uri?: string;
  39810. /**
  39811. * The image's MIME type
  39812. */
  39813. mimeType?: ImageMimeType;
  39814. /**
  39815. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  39816. */
  39817. bufferView?: number;
  39818. }
  39819. /**
  39820. * Material Normal Texture Info
  39821. */
  39822. interface IMaterialNormalTextureInfo extends ITextureInfo {
  39823. /**
  39824. * The scalar multiplier applied to each normal vector of the normal texture
  39825. */
  39826. scale?: number;
  39827. }
  39828. /**
  39829. * Material Occlusion Texture Info
  39830. */
  39831. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  39832. /**
  39833. * A scalar multiplier controlling the amount of occlusion applied
  39834. */
  39835. strength?: number;
  39836. }
  39837. /**
  39838. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  39839. */
  39840. interface IMaterialPbrMetallicRoughness {
  39841. /**
  39842. * The material's base color factor
  39843. */
  39844. baseColorFactor?: number[];
  39845. /**
  39846. * The base color texture
  39847. */
  39848. baseColorTexture?: ITextureInfo;
  39849. /**
  39850. * The metalness of the material
  39851. */
  39852. metallicFactor?: number;
  39853. /**
  39854. * The roughness of the material
  39855. */
  39856. roughnessFactor?: number;
  39857. /**
  39858. * The metallic-roughness texture
  39859. */
  39860. metallicRoughnessTexture?: ITextureInfo;
  39861. }
  39862. /**
  39863. * The material appearance of a primitive
  39864. */
  39865. interface IMaterial extends IChildRootProperty {
  39866. /**
  39867. * 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
  39868. */
  39869. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  39870. /**
  39871. * The normal map texture
  39872. */
  39873. normalTexture?: IMaterialNormalTextureInfo;
  39874. /**
  39875. * The occlusion map texture
  39876. */
  39877. occlusionTexture?: IMaterialOcclusionTextureInfo;
  39878. /**
  39879. * The emissive map texture
  39880. */
  39881. emissiveTexture?: ITextureInfo;
  39882. /**
  39883. * 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
  39884. */
  39885. emissiveFactor?: number[];
  39886. /**
  39887. * The alpha rendering mode of the material
  39888. */
  39889. alphaMode?: MaterialAlphaMode;
  39890. /**
  39891. * The alpha cutoff value of the material
  39892. */
  39893. alphaCutoff?: number;
  39894. /**
  39895. * Specifies whether the material is double sided
  39896. */
  39897. doubleSided?: boolean;
  39898. }
  39899. /**
  39900. * Geometry to be rendered with the given material
  39901. */
  39902. interface IMeshPrimitive extends IProperty {
  39903. /**
  39904. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  39905. */
  39906. attributes: {
  39907. [name: string]: number;
  39908. };
  39909. /**
  39910. * The index of the accessor that contains the indices
  39911. */
  39912. indices?: number;
  39913. /**
  39914. * The index of the material to apply to this primitive when rendering
  39915. */
  39916. material?: number;
  39917. /**
  39918. * The type of primitives to render. All valid values correspond to WebGL enums
  39919. */
  39920. mode?: MeshPrimitiveMode;
  39921. /**
  39922. * 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
  39923. */
  39924. targets?: {
  39925. [name: string]: number;
  39926. }[];
  39927. }
  39928. /**
  39929. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  39930. */
  39931. interface IMesh extends IChildRootProperty {
  39932. /**
  39933. * An array of primitives, each defining geometry to be rendered with a material
  39934. */
  39935. primitives: IMeshPrimitive[];
  39936. /**
  39937. * Array of weights to be applied to the Morph Targets
  39938. */
  39939. weights?: number[];
  39940. }
  39941. /**
  39942. * A node in the node hierarchy
  39943. */
  39944. interface INode extends IChildRootProperty {
  39945. /**
  39946. * The index of the camera referenced by this node
  39947. */
  39948. camera?: number;
  39949. /**
  39950. * The indices of this node's children
  39951. */
  39952. children?: number[];
  39953. /**
  39954. * The index of the skin referenced by this node
  39955. */
  39956. skin?: number;
  39957. /**
  39958. * A floating-point 4x4 transformation matrix stored in column-major order
  39959. */
  39960. matrix?: number[];
  39961. /**
  39962. * The index of the mesh in this node
  39963. */
  39964. mesh?: number;
  39965. /**
  39966. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  39967. */
  39968. rotation?: number[];
  39969. /**
  39970. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  39971. */
  39972. scale?: number[];
  39973. /**
  39974. * The node's translation along the x, y, and z axes
  39975. */
  39976. translation?: number[];
  39977. /**
  39978. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  39979. */
  39980. weights?: number[];
  39981. }
  39982. /**
  39983. * Texture sampler properties for filtering and wrapping modes
  39984. */
  39985. interface ISampler extends IChildRootProperty {
  39986. /**
  39987. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  39988. */
  39989. magFilter?: TextureMagFilter;
  39990. /**
  39991. * Minification filter. All valid values correspond to WebGL enums
  39992. */
  39993. minFilter?: TextureMinFilter;
  39994. /**
  39995. * S (U) wrapping mode. All valid values correspond to WebGL enums
  39996. */
  39997. wrapS?: TextureWrapMode;
  39998. /**
  39999. * T (V) wrapping mode. All valid values correspond to WebGL enums
  40000. */
  40001. wrapT?: TextureWrapMode;
  40002. }
  40003. /**
  40004. * The root nodes of a scene
  40005. */
  40006. interface IScene extends IChildRootProperty {
  40007. /**
  40008. * The indices of each root node
  40009. */
  40010. nodes: number[];
  40011. }
  40012. /**
  40013. * Joints and matrices defining a skin
  40014. */
  40015. interface ISkin extends IChildRootProperty {
  40016. /**
  40017. * 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
  40018. */
  40019. inverseBindMatrices?: number;
  40020. /**
  40021. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  40022. */
  40023. skeleton?: number;
  40024. /**
  40025. * 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)
  40026. */
  40027. joints: number[];
  40028. }
  40029. /**
  40030. * A texture and its sampler
  40031. */
  40032. interface ITexture extends IChildRootProperty {
  40033. /**
  40034. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  40035. */
  40036. sampler?: number;
  40037. /**
  40038. * The index of the image used by this texture
  40039. */
  40040. source: number;
  40041. }
  40042. /**
  40043. * Reference to a texture
  40044. */
  40045. interface ITextureInfo extends IProperty {
  40046. /**
  40047. * The index of the texture
  40048. */
  40049. index: number;
  40050. /**
  40051. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  40052. */
  40053. texCoord?: number;
  40054. }
  40055. /**
  40056. * The root object for a glTF asset
  40057. */
  40058. interface IGLTF extends IProperty {
  40059. /**
  40060. * An array of accessors. An accessor is a typed view into a bufferView
  40061. */
  40062. accessors?: IAccessor[];
  40063. /**
  40064. * An array of keyframe animations
  40065. */
  40066. animations?: IAnimation[];
  40067. /**
  40068. * Metadata about the glTF asset
  40069. */
  40070. asset: IAsset;
  40071. /**
  40072. * An array of buffers. A buffer points to binary geometry, animation, or skins
  40073. */
  40074. buffers?: IBuffer[];
  40075. /**
  40076. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  40077. */
  40078. bufferViews?: IBufferView[];
  40079. /**
  40080. * An array of cameras
  40081. */
  40082. cameras?: ICamera[];
  40083. /**
  40084. * Names of glTF extensions used somewhere in this asset
  40085. */
  40086. extensionsUsed?: string[];
  40087. /**
  40088. * Names of glTF extensions required to properly load this asset
  40089. */
  40090. extensionsRequired?: string[];
  40091. /**
  40092. * An array of images. An image defines data used to create a texture
  40093. */
  40094. images?: IImage[];
  40095. /**
  40096. * An array of materials. A material defines the appearance of a primitive
  40097. */
  40098. materials?: IMaterial[];
  40099. /**
  40100. * An array of meshes. A mesh is a set of primitives to be rendered
  40101. */
  40102. meshes?: IMesh[];
  40103. /**
  40104. * An array of nodes
  40105. */
  40106. nodes?: INode[];
  40107. /**
  40108. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  40109. */
  40110. samplers?: ISampler[];
  40111. /**
  40112. * The index of the default scene
  40113. */
  40114. scene?: number;
  40115. /**
  40116. * An array of scenes
  40117. */
  40118. scenes?: IScene[];
  40119. /**
  40120. * An array of skins. A skin is defined by joints and matrices
  40121. */
  40122. skins?: ISkin[];
  40123. /**
  40124. * An array of textures
  40125. */
  40126. textures?: ITexture[];
  40127. }
  40128. }