babylon.d.txt 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547
  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. }
  183. interface Window {
  184. mozIndexedDB: IDBFactory;
  185. webkitIndexedDB: IDBFactory;
  186. msIndexedDB: IDBFactory;
  187. webkitURL: typeof URL;
  188. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  189. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  190. WebGLRenderingContext: WebGLRenderingContext;
  191. MSGesture: MSGesture;
  192. CANNON: any;
  193. AudioContext: AudioContext;
  194. webkitAudioContext: AudioContext;
  195. PointerEvent: any;
  196. Math: Math;
  197. Uint8Array: Uint8ArrayConstructor;
  198. Float32Array: Float32ArrayConstructor;
  199. mozURL: typeof URL;
  200. msURL: typeof URL;
  201. VRFrameData: any;
  202. DracoDecoderModule: any;
  203. }
  204. interface WebGLRenderingContext {
  205. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  206. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  207. vertexAttribDivisor(index: number, divisor: number): void;
  208. createVertexArray(): any;
  209. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  210. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  211. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  212. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  213. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  214. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  215. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  216. createQuery(): WebGLQuery;
  217. deleteQuery(query: WebGLQuery): void;
  218. beginQuery(target: number, query: WebGLQuery): void;
  219. endQuery(target: number): void;
  220. getQueryParameter(query: WebGLQuery, pname: number): any;
  221. getQuery(target: number, pname: number): any;
  222. MAX_SAMPLES: number;
  223. RGBA8: number;
  224. READ_FRAMEBUFFER: number;
  225. DRAW_FRAMEBUFFER: number;
  226. UNIFORM_BUFFER: number;
  227. HALF_FLOAT_OES: number;
  228. RGBA16F: number;
  229. RGBA32F: number;
  230. R32F: number;
  231. RG32F: number;
  232. RGB32F: number;
  233. RED: number;
  234. RG: number;
  235. UNSIGNED_INT_24_8: number;
  236. DEPTH24_STENCIL8: number;
  237. drawBuffers(buffers: number[]): void;
  238. readBuffer(src: number): void;
  239. readonly COLOR_ATTACHMENT0: number;
  240. readonly COLOR_ATTACHMENT1: number;
  241. readonly COLOR_ATTACHMENT2: number;
  242. readonly COLOR_ATTACHMENT3: number;
  243. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  244. ANY_SAMPLES_PASSED: number;
  245. QUERY_RESULT_AVAILABLE: number;
  246. QUERY_RESULT: number;
  247. }
  248. interface Document {
  249. mozCancelFullScreen(): void;
  250. msCancelFullScreen(): void;
  251. mozFullScreen: boolean;
  252. msIsFullScreen: boolean;
  253. fullscreen: boolean;
  254. mozPointerLockElement: HTMLElement;
  255. msPointerLockElement: HTMLElement;
  256. webkitPointerLockElement: HTMLElement;
  257. }
  258. interface HTMLCanvasElement {
  259. msRequestPointerLock?(): void;
  260. mozRequestPointerLock?(): void;
  261. webkitRequestPointerLock?(): void;
  262. }
  263. interface CanvasRenderingContext2D {
  264. msImageSmoothingEnabled: boolean;
  265. }
  266. interface WebGLBuffer {
  267. references: number;
  268. capacity: number;
  269. is32Bits: boolean;
  270. }
  271. interface WebGLProgram {
  272. transformFeedback?: WebGLTransformFeedback | null;
  273. }
  274. interface MouseEvent {
  275. mozMovementX: number;
  276. mozMovementY: number;
  277. webkitMovementX: number;
  278. webkitMovementY: number;
  279. msMovementX: number;
  280. msMovementY: number;
  281. }
  282. interface Navigator {
  283. mozGetVRDevices: (any: any) => any;
  284. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  285. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  286. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  287. webkitGetGamepads(): Gamepad[];
  288. msGetGamepads(): Gamepad[];
  289. webkitGamepads(): Gamepad[];
  290. }
  291. interface HTMLVideoElement {
  292. mozSrcObject: any;
  293. }
  294. interface Screen {
  295. orientation: string;
  296. mozOrientation: string;
  297. }
  298. interface Math {
  299. fround(x: number): number;
  300. imul(a: number, b: number): number;
  301. }
  302. interface EXT_disjoint_timer_query {
  303. QUERY_COUNTER_BITS_EXT: number;
  304. TIME_ELAPSED_EXT: number;
  305. TIMESTAMP_EXT: number;
  306. GPU_DISJOINT_EXT: number;
  307. QUERY_RESULT_EXT: number;
  308. QUERY_RESULT_AVAILABLE_EXT: number;
  309. queryCounterEXT(query: WebGLQuery, target: number): void;
  310. createQueryEXT(): WebGLQuery;
  311. beginQueryEXT(target: number, query: WebGLQuery): void;
  312. endQueryEXT(target: number): void;
  313. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  314. deleteQueryEXT(query: WebGLQuery): void;
  315. }
  316. interface WebGLUniformLocation {
  317. }
  318. declare module BABYLON {
  319. /**
  320. * Node is the basic class for all scene objects (Mesh, Light Camera).
  321. */
  322. class Node {
  323. /**
  324. * Gets or sets the name of the node
  325. */
  326. name: string;
  327. /**
  328. * Gets or sets the id of the node
  329. */
  330. id: string;
  331. /**
  332. * Gets or sets the unique id of the node
  333. */
  334. uniqueId: number;
  335. /**
  336. * Gets or sets a string used to store user defined state for the node
  337. */
  338. state: string;
  339. /**
  340. * Gets or sets an object used to store user defined information for the node
  341. */
  342. metadata: any;
  343. /**
  344. * Gets or sets a boolean used to define if the node must be serialized
  345. */
  346. doNotSerialize: boolean;
  347. /** @hidden */
  348. /**
  349. * Gets a list of Animations associated with the node
  350. */
  351. animations: Animation[];
  352. private _ranges;
  353. /**
  354. * Callback raised when the node is ready to be used
  355. */
  356. onReady: (node: Node) => void;
  357. private _isEnabled;
  358. private _isReady;
  359. /** @hidden */
  360. private _parentRenderId;
  361. protected _childRenderId: number;
  362. /** @hidden */
  363. private _scene;
  364. /** @hidden */
  365. private _parentNode;
  366. private _children;
  367. /**
  368. * Gets a boolean indicating if the node has been disposed
  369. * @returns true if the node was disposed
  370. */
  371. isDisposed(): boolean;
  372. /**
  373. * Gets or sets the parent of the node
  374. */
  375. parent: Nullable<Node>;
  376. private _animationPropertiesOverride;
  377. /**
  378. * Gets or sets the animation properties override
  379. */
  380. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  381. /**
  382. * Gets a string idenfifying the name of the class
  383. * @returns "Node" string
  384. */
  385. getClassName(): string;
  386. /**
  387. * An event triggered when the mesh is disposed
  388. */
  389. onDisposeObservable: Observable<Node>;
  390. private _onDisposeObserver;
  391. /**
  392. * Sets a callback that will be raised when the node will be disposed
  393. */
  394. onDispose: () => void;
  395. /**
  396. * Creates a new Node
  397. * @param {string} name - the name and id to be given to this node
  398. * @param {BABYLON.Scene} the scene this node will be added to
  399. */
  400. constructor(name: string, scene?: Nullable<Scene>);
  401. /**
  402. * Gets the scene of the node
  403. * @returns a {BABYLON.Scene}
  404. */
  405. getScene(): Scene;
  406. /**
  407. * Gets the engine of the node
  408. * @returns a {BABYLON.Engine}
  409. */
  410. getEngine(): Engine;
  411. private _behaviors;
  412. /**
  413. * Attach a behavior to the node
  414. * @see http://doc.babylonjs.com/features/behaviour
  415. * @param behavior defines the behavior to attach
  416. * @returns the current Node
  417. */
  418. addBehavior(behavior: Behavior<Node>): Node;
  419. /**
  420. * Remove an attached behavior
  421. * @see http://doc.babylonjs.com/features/behaviour
  422. * @param behavior defines the behavior to attach
  423. * @returns the current Node
  424. */
  425. removeBehavior(behavior: Behavior<Node>): Node;
  426. /**
  427. * Gets the list of attached behaviors
  428. * @see http://doc.babylonjs.com/features/behaviour
  429. */
  430. readonly behaviors: Behavior<Node>[];
  431. /**
  432. * Gets an attached behavior by name
  433. * @param name defines the name of the behavior to look for
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. * @returns null if behavior was not found else the requested behavior
  436. */
  437. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  438. /**
  439. * Returns the world matrix of the node
  440. * @returns a matrix containing the node's world matrix
  441. */
  442. getWorldMatrix(): Matrix;
  443. /** @hidden */
  444. /** @hidden */
  445. /** @hidden */
  446. updateCache(force?: boolean): void;
  447. /** @hidden */
  448. /** @hidden */
  449. /** @hidden */
  450. /** @hidden */
  451. isSynchronizedWithParent(): boolean;
  452. /** @hidden */
  453. isSynchronized(updateCache?: boolean): boolean;
  454. /** @hidden */
  455. hasNewParent(update?: boolean): boolean;
  456. /**
  457. * Is this node ready to be used/rendered
  458. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  459. * @return true if the node is ready
  460. */
  461. isReady(completeCheck?: boolean): boolean;
  462. /**
  463. * Is this node enabled?
  464. * 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
  465. * @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
  466. * @return whether this node (and its parent) is enabled
  467. */
  468. isEnabled(checkAncestors?: boolean): boolean;
  469. /**
  470. * Set the enabled state of this node
  471. * @param value defines the new enabled state
  472. */
  473. setEnabled(value: boolean): void;
  474. /**
  475. * Is this node a descendant of the given node?
  476. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  477. * @param ancestor defines the parent node to inspect
  478. * @returns a boolean indicating if this node is a descendant of the given node
  479. */
  480. isDescendantOf(ancestor: Node): boolean;
  481. /** @hidden */
  482. /**
  483. * Will return all nodes that have this node as ascendant
  484. * @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
  485. * @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
  486. * @return all children nodes of all types
  487. */
  488. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  489. /**
  490. * Get all child-meshes of this node
  491. * @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
  492. * @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
  493. * @returns an array of {BABYLON.AbstractMesh}
  494. */
  495. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  496. /**
  497. * Get all child-transformNodes of this node
  498. * @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
  499. * @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
  500. * @returns an array of {BABYLON.TransformNode}
  501. */
  502. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  503. /**
  504. * Get all direct children of this node
  505. * @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
  506. * @returns an array of {BABYLON.Node}
  507. */
  508. getChildren(predicate?: (node: Node) => boolean): Node[];
  509. /** @hidden */
  510. /**
  511. * Get an animation by name
  512. * @param name defines the name of the animation to look for
  513. * @returns null if not found else the requested animation
  514. */
  515. getAnimationByName(name: string): Nullable<Animation>;
  516. /**
  517. * Creates an animation range for this node
  518. * @param name defines the name of the range
  519. * @param from defines the starting key
  520. * @param to defines the end key
  521. */
  522. createAnimationRange(name: string, from: number, to: number): void;
  523. /**
  524. * Delete a specific animation range
  525. * @param name defines the name of the range to delete
  526. * @param deleteFrames defines if animation frames from the range must be deleted as well
  527. */
  528. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  529. /**
  530. * Get an animation range by name
  531. * @param name defines the name of the animation range to look for
  532. * @returns null if not found else the requested animation range
  533. */
  534. getAnimationRange(name: string): Nullable<AnimationRange>;
  535. /**
  536. * Will start the animation sequence
  537. * @param name defines the range frames for animation sequence
  538. * @param loop defines if the animation should loop (false by default)
  539. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  540. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  541. * @returns the object created for this animation. If range does not exist, it will return null
  542. */
  543. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  544. /**
  545. * Serialize animation ranges into a JSON compatible object
  546. * @returns serialization object
  547. */
  548. serializeAnimationRanges(): any;
  549. /**
  550. * Computes the world matrix of the node
  551. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  552. * @returns the world matrix
  553. */
  554. computeWorldMatrix(force?: boolean): Matrix;
  555. /**
  556. * Releases resources associated with this node.
  557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  559. */
  560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  561. /**
  562. * Parse animation range data from a serialization object and store them into a given node
  563. * @param node defines where to store the animation ranges
  564. * @param parsedNode defines the serialization object to read data from
  565. * @param scene defines the hosting scene
  566. */
  567. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * Define an interface for all classes that will hold resources
  573. */
  574. interface IDisposable {
  575. /**
  576. * Releases all held resources
  577. */
  578. dispose(): void;
  579. }
  580. /**
  581. * Interface used to let developers provide their own mesh selection mechanism
  582. */
  583. interface IActiveMeshCandidateProvider {
  584. /**
  585. * Return the list of active meshes
  586. * @param scene defines the current scene
  587. * @returns the list of active meshes
  588. */
  589. getMeshes(scene: Scene): AbstractMesh[];
  590. /**
  591. * Indicates if the meshes have been checked to make sure they are isEnabled()
  592. */
  593. readonly checksIsEnabled: boolean;
  594. }
  595. /**
  596. * This class is used by the onRenderingGroupObservable
  597. */
  598. class RenderingGroupInfo {
  599. /**
  600. * The Scene that being rendered
  601. */
  602. scene: Scene;
  603. /**
  604. * The camera currently used for the rendering pass
  605. */
  606. camera: Nullable<Camera>;
  607. /**
  608. * The ID of the renderingGroup being processed
  609. */
  610. renderingGroupId: number;
  611. /**
  612. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  613. */
  614. renderStage: number;
  615. /**
  616. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  617. * This stage will be fired no matter what
  618. */
  619. static STAGE_PRECLEAR: number;
  620. /**
  621. * Called before opaque object are rendered.
  622. * This stage will be fired only if there's 3D Opaque content to render
  623. */
  624. static STAGE_PREOPAQUE: number;
  625. /**
  626. * Called after the opaque objects are rendered and before the transparent ones
  627. * This stage will be fired only if there's 3D transparent content to render
  628. */
  629. static STAGE_PRETRANSPARENT: number;
  630. /**
  631. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  632. * This stage will be fired no matter what
  633. */
  634. static STAGE_POSTTRANSPARENT: number;
  635. }
  636. /**
  637. * Represents a scene to be rendered by the engine.
  638. * @see http://doc.babylonjs.com/features/scene
  639. */
  640. class Scene implements IAnimatable {
  641. private static _FOGMODE_NONE;
  642. private static _FOGMODE_EXP;
  643. private static _FOGMODE_EXP2;
  644. private static _FOGMODE_LINEAR;
  645. private static _uniqueIdCounter;
  646. /**
  647. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  649. */
  650. static MinDeltaTime: number;
  651. /**
  652. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  654. */
  655. static MaxDeltaTime: number;
  656. /** The fog is deactivated */
  657. static readonly FOGMODE_NONE: number;
  658. /** The fog density is following an exponential function */
  659. static readonly FOGMODE_EXP: number;
  660. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  661. static readonly FOGMODE_EXP2: number;
  662. /** The fog density is following a linear function. */
  663. static readonly FOGMODE_LINEAR: number;
  664. /**
  665. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  666. */
  667. autoClear: boolean;
  668. /**
  669. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  670. */
  671. autoClearDepthAndStencil: boolean;
  672. /**
  673. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  674. */
  675. clearColor: Color4;
  676. /**
  677. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  678. */
  679. ambientColor: Color3;
  680. /** @hidden */
  681. /** @hidden */
  682. protected _environmentTexture: BaseTexture;
  683. /**
  684. * Texture used in all pbr material as the reflection texture.
  685. * As in the majority of the scene they are the same (exception for multi room and so on),
  686. * this is easier to reference from here than from all the materials.
  687. */
  688. /**
  689. * Texture used in all pbr material as the reflection texture.
  690. * As in the majority of the scene they are the same (exception for multi room and so on),
  691. * this is easier to set here than in all the materials.
  692. */
  693. environmentTexture: BaseTexture;
  694. /** @hidden */
  695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  696. /**
  697. * Default image processing configuration used either in the rendering
  698. * Forward main pass or through the imageProcessingPostProcess if present.
  699. * As in the majority of the scene they are the same (exception for multi camera),
  700. * this is easier to reference from here than from all the materials and post process.
  701. *
  702. * No setter as we it is a shared configuration, you can set the values instead.
  703. */
  704. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  705. private _forceWireframe;
  706. /**
  707. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  708. */
  709. forceWireframe: boolean;
  710. private _forcePointsCloud;
  711. /**
  712. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  713. */
  714. forcePointsCloud: boolean;
  715. /**
  716. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  717. */
  718. forceShowBoundingBoxes: boolean;
  719. /**
  720. * Gets or sets the active clipplane
  721. */
  722. clipPlane: Nullable<Plane>;
  723. /**
  724. * Gets or sets a boolean indicating if animations are enabled
  725. */
  726. animationsEnabled: boolean;
  727. private _animationPropertiesOverride;
  728. /**
  729. * Gets or sets the animation properties override
  730. */
  731. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  732. /**
  733. * Gets or sets a boolean indicating if a constant deltatime has to be used
  734. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  735. */
  736. useConstantAnimationDeltaTime: boolean;
  737. /**
  738. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  739. * Please note that it requires to run a ray cast through the scene on every frame
  740. */
  741. constantlyUpdateMeshUnderPointer: boolean;
  742. /**
  743. * Defines the HTML cursor to use when hovering over interactive elements
  744. */
  745. hoverCursor: string;
  746. /**
  747. * Defines the HTML default cursor to use (empty by default)
  748. */
  749. defaultCursor: string;
  750. /**
  751. * This is used to call preventDefault() on pointer down
  752. * in order to block unwanted artifacts like system double clicks
  753. */
  754. preventDefaultOnPointerDown: boolean;
  755. /**
  756. * Gets or sets user defined metadata
  757. */
  758. metadata: any;
  759. /**
  760. * Gets the name of the plugin used to load this scene (null by default)
  761. */
  762. loadingPluginName: string;
  763. /**
  764. * Use this array to add regular expressions used to disable offline support for specific urls
  765. */
  766. disableOfflineSupportExceptionRules: RegExp[];
  767. private _spritePredicate;
  768. /**
  769. * An event triggered when the scene is disposed.
  770. */
  771. onDisposeObservable: Observable<Scene>;
  772. private _onDisposeObserver;
  773. /** Sets a function to be executed when this scene is disposed. */
  774. onDispose: () => void;
  775. /**
  776. * An event triggered before rendering the scene (right after animations and physics)
  777. */
  778. onBeforeRenderObservable: Observable<Scene>;
  779. private _onBeforeRenderObserver;
  780. /** Sets a function to be executed before rendering this scene */
  781. beforeRender: Nullable<() => void>;
  782. /**
  783. * An event triggered after rendering the scene
  784. */
  785. onAfterRenderObservable: Observable<Scene>;
  786. private _onAfterRenderObserver;
  787. /** Sets a function to be executed after rendering this scene */
  788. afterRender: Nullable<() => void>;
  789. /**
  790. * An event triggered before animating the scene
  791. */
  792. onBeforeAnimationsObservable: Observable<Scene>;
  793. /**
  794. * An event triggered after animations processing
  795. */
  796. onAfterAnimationsObservable: Observable<Scene>;
  797. /**
  798. * An event triggered before draw calls are ready to be sent
  799. */
  800. onBeforeDrawPhaseObservable: Observable<Scene>;
  801. /**
  802. * An event triggered after draw calls have been sent
  803. */
  804. onAfterDrawPhaseObservable: Observable<Scene>;
  805. /**
  806. * An event triggered when physic simulation is about to be run
  807. */
  808. onBeforePhysicsObservable: Observable<Scene>;
  809. /**
  810. * An event triggered when physic simulation has been done
  811. */
  812. onAfterPhysicsObservable: Observable<Scene>;
  813. /**
  814. * An event triggered when the scene is ready
  815. */
  816. onReadyObservable: Observable<Scene>;
  817. /**
  818. * An event triggered before rendering a camera
  819. */
  820. onBeforeCameraRenderObservable: Observable<Camera>;
  821. private _onBeforeCameraRenderObserver;
  822. /** Sets a function to be executed before rendering a camera*/
  823. beforeCameraRender: () => void;
  824. /**
  825. * An event triggered after rendering a camera
  826. */
  827. onAfterCameraRenderObservable: Observable<Camera>;
  828. private _onAfterCameraRenderObserver;
  829. /** Sets a function to be executed after rendering a camera*/
  830. afterCameraRender: () => void;
  831. /**
  832. * An event triggered when active meshes evaluation is about to start
  833. */
  834. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  835. /**
  836. * An event triggered when active meshes evaluation is done
  837. */
  838. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  839. /**
  840. * An event triggered when particles rendering is about to start
  841. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  842. */
  843. onBeforeParticlesRenderingObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when particles rendering is done
  846. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  847. */
  848. onAfterParticlesRenderingObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when sprites rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  852. */
  853. onBeforeSpritesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when sprites rendering is done
  856. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  857. */
  858. onAfterSpritesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  861. */
  862. onDataLoadedObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when a camera is created
  865. */
  866. onNewCameraAddedObservable: Observable<Camera>;
  867. /**
  868. * An event triggered when a camera is removed
  869. */
  870. onCameraRemovedObservable: Observable<Camera>;
  871. /**
  872. * An event triggered when a light is created
  873. */
  874. onNewLightAddedObservable: Observable<Light>;
  875. /**
  876. * An event triggered when a light is removed
  877. */
  878. onLightRemovedObservable: Observable<Light>;
  879. /**
  880. * An event triggered when a geometry is created
  881. */
  882. onNewGeometryAddedObservable: Observable<Geometry>;
  883. /**
  884. * An event triggered when a geometry is removed
  885. */
  886. onGeometryRemovedObservable: Observable<Geometry>;
  887. /**
  888. * An event triggered when a transform node is created
  889. */
  890. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  891. /**
  892. * An event triggered when a transform node is removed
  893. */
  894. onTransformNodeRemovedObservable: Observable<TransformNode>;
  895. /**
  896. * An event triggered when a mesh is created
  897. */
  898. onNewMeshAddedObservable: Observable<AbstractMesh>;
  899. /**
  900. * An event triggered when a mesh is removed
  901. */
  902. onMeshRemovedObservable: Observable<AbstractMesh>;
  903. /**
  904. * An event triggered when render targets are about to be rendered
  905. * Can happen multiple times per frame.
  906. */
  907. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  908. /**
  909. * An event triggered when render targets were rendered.
  910. * Can happen multiple times per frame.
  911. */
  912. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  913. /**
  914. * An event triggered before calculating deterministic simulation step
  915. */
  916. onBeforeStepObservable: Observable<Scene>;
  917. /**
  918. * An event triggered after calculating deterministic simulation step
  919. */
  920. onAfterStepObservable: Observable<Scene>;
  921. /**
  922. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  924. * 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)
  925. */
  926. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  927. /**
  928. * Gets a list of Animations associated with the scene
  929. */
  930. animations: Animation[];
  931. private _registeredForLateAnimationBindings;
  932. /**
  933. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  934. */
  935. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  936. /**
  937. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  938. */
  939. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  940. /**
  941. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  942. */
  943. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  944. private _onPointerMove;
  945. private _onPointerDown;
  946. private _onPointerUp;
  947. /** Deprecated. Use onPointerObservable instead */
  948. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  949. /** Deprecated. Use onPointerObservable instead */
  950. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  951. /** Deprecated. Use onPointerObservable instead */
  952. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  953. /** Deprecated. Use onPointerObservable instead */
  954. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  955. private _gamepadManager;
  956. /**
  957. * Gets the gamepad manager associated with the scene
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  959. */
  960. readonly gamepadManager: GamepadManager;
  961. /**
  962. * 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).
  963. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  964. */
  965. onPrePointerObservable: Observable<PointerInfoPre>;
  966. /**
  967. * Observable event triggered each time an input event is received from the rendering canvas
  968. */
  969. onPointerObservable: Observable<PointerInfo>;
  970. /**
  971. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  972. */
  973. readonly unTranslatedPointer: Vector2;
  974. /** The distance in pixel that you have to move to prevent some events */
  975. static DragMovementThreshold: number;
  976. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  977. static LongPressDelay: number;
  978. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  979. static DoubleClickDelay: number;
  980. /** If you need to check double click without raising a single click at first click, enable this flag */
  981. static ExclusiveDoubleClickMode: boolean;
  982. private _initClickEvent;
  983. private _initActionManager;
  984. private _delayedSimpleClick;
  985. private _delayedSimpleClickTimeout;
  986. private _previousDelayedSimpleClickTimeout;
  987. private _meshPickProceed;
  988. private _previousButtonPressed;
  989. private _currentPickResult;
  990. private _previousPickResult;
  991. private _totalPointersPressed;
  992. private _doubleClickOccured;
  993. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  994. cameraToUseForPointers: Nullable<Camera>;
  995. private _pointerX;
  996. private _pointerY;
  997. private _unTranslatedPointerX;
  998. private _unTranslatedPointerY;
  999. private _startingPointerPosition;
  1000. private _previousStartingPointerPosition;
  1001. private _startingPointerTime;
  1002. private _previousStartingPointerTime;
  1003. private _timeAccumulator;
  1004. private _currentStepId;
  1005. private _currentInternalStep;
  1006. /** @hidden */
  1007. /**
  1008. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1009. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1010. */
  1011. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1012. /**
  1013. * Observable event triggered each time an keyboard event is received from the hosting window
  1014. */
  1015. onKeyboardObservable: Observable<KeyboardInfo>;
  1016. private _onKeyDown;
  1017. private _onKeyUp;
  1018. private _onCanvasFocusObserver;
  1019. private _onCanvasBlurObserver;
  1020. private _useRightHandedSystem;
  1021. /**
  1022. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1023. */
  1024. useRightHandedSystem: boolean;
  1025. /**
  1026. * Sets the step Id used by deterministic lock step
  1027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1028. * @param newStepId defines the step Id
  1029. */
  1030. setStepId(newStepId: number): void;
  1031. /**
  1032. * Gets the step Id used by deterministic lock step
  1033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1034. * @returns the step Id
  1035. */
  1036. getStepId(): number;
  1037. /**
  1038. * Gets the internal step used by deterministic lock step
  1039. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1040. * @returns the internal step
  1041. */
  1042. getInternalStep(): number;
  1043. private _fogEnabled;
  1044. /**
  1045. * Gets or sets a boolean indicating if fog is enabled on this scene
  1046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1047. */
  1048. fogEnabled: boolean;
  1049. private _fogMode;
  1050. /**
  1051. * Gets or sets the fog mode to use
  1052. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1053. */
  1054. fogMode: number;
  1055. /**
  1056. * Gets or sets the fog color to use
  1057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1058. */
  1059. fogColor: Color3;
  1060. /**
  1061. * Gets or sets the fog density to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogDensity: number;
  1065. /**
  1066. * Gets or sets the fog start distance to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogStart: number;
  1070. /**
  1071. * Gets or sets the fog end distance to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogEnd: number;
  1075. private _shadowsEnabled;
  1076. /**
  1077. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1078. */
  1079. shadowsEnabled: boolean;
  1080. private _lightsEnabled;
  1081. /**
  1082. * Gets or sets a boolean indicating if lights are enabled on this scene
  1083. */
  1084. lightsEnabled: boolean;
  1085. /**
  1086. * All of the lights added to this scene
  1087. * @see http://doc.babylonjs.com/babylon101/lights
  1088. */
  1089. lights: Light[];
  1090. /** All of the cameras added to this scene.
  1091. * @see http://doc.babylonjs.com/babylon101/cameras
  1092. */
  1093. cameras: Camera[];
  1094. /** All of the active cameras added to this scene. */
  1095. activeCameras: Camera[];
  1096. /** The current active camera */
  1097. activeCamera: Nullable<Camera>;
  1098. /**
  1099. * All of the tranform nodes added to this scene
  1100. * @see http://doc.babylonjs.com/how_to/transformnode
  1101. */
  1102. transformNodes: TransformNode[];
  1103. /**
  1104. * All of the (abstract) meshes added to this scene
  1105. */
  1106. meshes: AbstractMesh[];
  1107. /**
  1108. * All of the animation groups added to this scene
  1109. * @see http://doc.babylonjs.com/how_to/group
  1110. */
  1111. animationGroups: AnimationGroup[];
  1112. private _geometries;
  1113. /**
  1114. * All of the materials added to this scene
  1115. * @see http://doc.babylonjs.com/babylon101/materials
  1116. */
  1117. materials: Material[];
  1118. /**
  1119. * All of the multi-materials added to this scene
  1120. * @see http://doc.babylonjs.com/how_to/multi_materials
  1121. */
  1122. multiMaterials: MultiMaterial[];
  1123. private _defaultMaterial;
  1124. /** The default material used on meshes when no material is affected */
  1125. /** The default material used on meshes when no material is affected */
  1126. defaultMaterial: Material;
  1127. private _texturesEnabled;
  1128. /**
  1129. * Gets or sets a boolean indicating if textures are enabled on this scene
  1130. */
  1131. texturesEnabled: boolean;
  1132. /**
  1133. * All of the textures added to this scene
  1134. */
  1135. textures: BaseTexture[];
  1136. /**
  1137. * Gets or sets a boolean indicating if particles are enabled on this scene
  1138. */
  1139. particlesEnabled: boolean;
  1140. /**
  1141. * All of the particle systems added to this scene
  1142. * @see http://doc.babylonjs.com/babylon101/particles
  1143. */
  1144. particleSystems: IParticleSystem[];
  1145. /**
  1146. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1147. */
  1148. spritesEnabled: boolean;
  1149. /**
  1150. * All of the sprite managers added to this scene
  1151. * @see http://doc.babylonjs.com/babylon101/sprites
  1152. */
  1153. spriteManagers: SpriteManager[];
  1154. /**
  1155. * The list of layers (background and foreground) of the scene
  1156. */
  1157. layers: Layer[];
  1158. /**
  1159. * The list of effect layers (highlights/glow) added to the scene
  1160. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1161. * @see http://doc.babylonjs.com/how_to/glow_layer
  1162. */
  1163. effectLayers: EffectLayer[];
  1164. private _skeletonsEnabled;
  1165. /**
  1166. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1167. */
  1168. skeletonsEnabled: boolean;
  1169. /**
  1170. * The list of skeletons added to the scene
  1171. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1172. */
  1173. skeletons: Skeleton[];
  1174. /**
  1175. * The list of morph target managers added to the scene
  1176. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1177. */
  1178. morphTargetManagers: MorphTargetManager[];
  1179. /**
  1180. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1181. */
  1182. lensFlaresEnabled: boolean;
  1183. /**
  1184. * The list of lens flare system added to the scene
  1185. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1186. */
  1187. lensFlareSystems: LensFlareSystem[];
  1188. /**
  1189. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1191. */
  1192. collisionsEnabled: boolean;
  1193. private _workerCollisions;
  1194. /** @hidden */
  1195. collisionCoordinator: ICollisionCoordinator;
  1196. /**
  1197. * Defines the gravity applied to this scene (used only for collisions)
  1198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1199. */
  1200. gravity: Vector3;
  1201. /**
  1202. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1203. */
  1204. postProcessesEnabled: boolean;
  1205. /**
  1206. * The list of postprocesses added to the scene
  1207. */
  1208. postProcesses: PostProcess[];
  1209. /**
  1210. * Gets the current postprocess manager
  1211. */
  1212. postProcessManager: PostProcessManager;
  1213. private _postProcessRenderPipelineManager;
  1214. /**
  1215. * Gets the postprocess render pipeline manager
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1217. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1218. */
  1219. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1220. /**
  1221. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1222. */
  1223. renderTargetsEnabled: boolean;
  1224. /**
  1225. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1226. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1227. */
  1228. dumpNextRenderTargets: boolean;
  1229. /**
  1230. * The list of user defined render targets added to the scene
  1231. */
  1232. customRenderTargets: RenderTargetTexture[];
  1233. /**
  1234. * Defines if texture loading must be delayed
  1235. * If true, textures will only be loaded when they need to be rendered
  1236. */
  1237. useDelayedTextureLoading: boolean;
  1238. /**
  1239. * Gets the list of meshes imported to the scene through SceneLoader
  1240. */
  1241. importedMeshesFiles: String[];
  1242. /**
  1243. * Gets or sets a boolean indicating if probes are enabled on this scene
  1244. */
  1245. probesEnabled: boolean;
  1246. /**
  1247. * The list of reflection probes added to the scene
  1248. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1249. */
  1250. reflectionProbes: ReflectionProbe[];
  1251. /**
  1252. * @hidden
  1253. */
  1254. database: Database;
  1255. /**
  1256. * Gets or sets the action manager associated with the scene
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1258. */
  1259. actionManager: ActionManager;
  1260. /** @hidden */
  1261. private _meshesForIntersections;
  1262. /**
  1263. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1264. */
  1265. proceduralTexturesEnabled: boolean;
  1266. /**
  1267. * The list of procedural textures added to the scene
  1268. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1269. */
  1270. proceduralTextures: ProceduralTexture[];
  1271. private _mainSoundTrack;
  1272. /**
  1273. * The list of sound tracks added to the scene
  1274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1275. */
  1276. soundTracks: SoundTrack[];
  1277. private _audioEnabled;
  1278. private _headphone;
  1279. /**
  1280. * Gets the main soundtrack associated with the scene
  1281. */
  1282. readonly mainSoundTrack: SoundTrack;
  1283. /**
  1284. * Gets or sets the VRExperienceHelper attached to the scene
  1285. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1286. * @ignorenaming
  1287. */
  1288. VRHelper: VRExperienceHelper;
  1289. /**
  1290. * Gets or sets the simplification queue attached to the scene
  1291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1292. */
  1293. simplificationQueue: SimplificationQueue;
  1294. private _engine;
  1295. private _totalVertices;
  1296. /** @hidden */
  1297. /** @hidden */
  1298. /** @hidden */
  1299. private _animationRatio;
  1300. private _animationTimeLast;
  1301. private _animationTime;
  1302. /**
  1303. * Gets or sets a general scale for animation speed
  1304. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1305. */
  1306. animationTimeScale: number;
  1307. /** @hidden */
  1308. /** @hidden */
  1309. /** @hidden */
  1310. private _renderId;
  1311. private _executeWhenReadyTimeoutId;
  1312. private _intermediateRendering;
  1313. private _viewUpdateFlag;
  1314. private _projectionUpdateFlag;
  1315. private _alternateViewUpdateFlag;
  1316. private _alternateProjectionUpdateFlag;
  1317. /** @hidden */
  1318. private _activeRequests;
  1319. private _pendingData;
  1320. private _isDisposed;
  1321. /**
  1322. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1323. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1324. */
  1325. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1326. private _activeMeshes;
  1327. private _processedMaterials;
  1328. private _renderTargets;
  1329. /** @hidden */
  1330. private _activeSkeletons;
  1331. private _softwareSkinnedMeshes;
  1332. private _renderingManager;
  1333. private _physicsEngine;
  1334. /** @hidden */
  1335. private _transformMatrix;
  1336. private _sceneUbo;
  1337. private _alternateSceneUbo;
  1338. private _pickWithRayInverseMatrix;
  1339. private _boundingBoxRenderer;
  1340. private _outlineRenderer;
  1341. private _viewMatrix;
  1342. private _projectionMatrix;
  1343. private _alternateViewMatrix;
  1344. private _alternateProjectionMatrix;
  1345. private _alternateTransformMatrix;
  1346. private _useAlternateCameraConfiguration;
  1347. private _alternateRendering;
  1348. /** @hidden */
  1349. /** @hidden */
  1350. protected readonly _isAlternateRenderingEnabled: boolean;
  1351. private _frustumPlanes;
  1352. /**
  1353. * Gets the list of frustum planes (built from the active camera)
  1354. */
  1355. readonly frustumPlanes: Plane[];
  1356. /**
  1357. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1358. * This is useful if there are more lights that the maximum simulteanous authorized
  1359. */
  1360. requireLightSorting: boolean;
  1361. private _selectionOctree;
  1362. private _pointerOverMesh;
  1363. private _pointerOverSprite;
  1364. private _debugLayer;
  1365. private _depthRenderer;
  1366. private _geometryBufferRenderer;
  1367. /**
  1368. * Gets the current geometry buffer associated to the scene.
  1369. */
  1370. /**
  1371. * Sets the current geometry buffer for the scene.
  1372. */
  1373. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1374. private _pickedDownMesh;
  1375. private _pickedUpMesh;
  1376. private _pickedDownSprite;
  1377. private _externalData;
  1378. private _uid;
  1379. /**
  1380. * Creates a new Scene
  1381. * @param engine defines the engine to use to render this scene
  1382. */
  1383. constructor(engine: Engine);
  1384. /**
  1385. * Gets the debug layer associated with the scene
  1386. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1387. */
  1388. readonly debugLayer: DebugLayer;
  1389. /**
  1390. * Gets a boolean indicating if collisions are processed on a web worker
  1391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1392. */
  1393. workerCollisions: boolean;
  1394. /**
  1395. * Gets the octree used to boost mesh selection (picking)
  1396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1397. */
  1398. readonly selectionOctree: Octree<AbstractMesh>;
  1399. /**
  1400. * Gets the mesh that is currently under the pointer
  1401. */
  1402. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1403. /**
  1404. * Gets the current on-screen X position of the pointer
  1405. */
  1406. readonly pointerX: number;
  1407. /**
  1408. * Gets the current on-screen Y position of the pointer
  1409. */
  1410. readonly pointerY: number;
  1411. /**
  1412. * Gets the cached material (ie. the latest rendered one)
  1413. * @returns the cached material
  1414. */
  1415. getCachedMaterial(): Nullable<Material>;
  1416. /**
  1417. * Gets the cached effect (ie. the latest rendered one)
  1418. * @returns the cached effect
  1419. */
  1420. getCachedEffect(): Nullable<Effect>;
  1421. /**
  1422. * Gets the cached visibility state (ie. the latest rendered one)
  1423. * @returns the cached visibility state
  1424. */
  1425. getCachedVisibility(): Nullable<number>;
  1426. /**
  1427. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1428. * @param material defines the current material
  1429. * @param effect defines the current effect
  1430. * @param visibility defines the current visibility state
  1431. * @returns true if one parameter is not cached
  1432. */
  1433. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1434. /**
  1435. * Gets the bounding box renderer associated with the scene
  1436. * @returns a BoundingBoxRenderer
  1437. */
  1438. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1439. /**
  1440. * Gets the outline renderer associated with the scene
  1441. * @returns a OutlineRenderer
  1442. */
  1443. getOutlineRenderer(): OutlineRenderer;
  1444. /**
  1445. * Gets the engine associated with the scene
  1446. * @returns an Engine
  1447. */
  1448. getEngine(): Engine;
  1449. /**
  1450. * Gets the total number of vertices rendered per frame
  1451. * @returns the total number of vertices rendered per frame
  1452. */
  1453. getTotalVertices(): number;
  1454. /**
  1455. * Gets the performance counter for total vertices
  1456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1457. */
  1458. readonly totalVerticesPerfCounter: PerfCounter;
  1459. /**
  1460. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1461. * @returns the total number of active indices rendered per frame
  1462. */
  1463. getActiveIndices(): number;
  1464. /**
  1465. * Gets the performance counter for active indices
  1466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1467. */
  1468. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1469. /**
  1470. * Gets the total number of active particles rendered per frame
  1471. * @returns the total number of active particles rendered per frame
  1472. */
  1473. getActiveParticles(): number;
  1474. /**
  1475. * Gets the performance counter for active particles
  1476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1477. */
  1478. readonly activeParticlesPerfCounter: PerfCounter;
  1479. /**
  1480. * Gets the total number of active bones rendered per frame
  1481. * @returns the total number of active bones rendered per frame
  1482. */
  1483. getActiveBones(): number;
  1484. /**
  1485. * Gets the performance counter for active bones
  1486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1487. */
  1488. readonly activeBonesPerfCounter: PerfCounter;
  1489. /** @hidden */
  1490. getInterFramePerfCounter(): number;
  1491. /** @hidden */
  1492. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1493. /** @hidden */
  1494. getLastFrameDuration(): number;
  1495. /** @hidden */
  1496. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1497. /** @hidden */
  1498. getEvaluateActiveMeshesDuration(): number;
  1499. /** @hidden */
  1500. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1501. /**
  1502. * Gets the array of active meshes
  1503. * @returns an array of AbstractMesh
  1504. */
  1505. getActiveMeshes(): SmartArray<AbstractMesh>;
  1506. /** @hidden */
  1507. getRenderTargetsDuration(): number;
  1508. /** @hidden */
  1509. getRenderDuration(): number;
  1510. /** @hidden */
  1511. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1512. /** @hidden */
  1513. getParticlesDuration(): number;
  1514. /** @hidden */
  1515. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1516. /** @hidden */
  1517. getSpritesDuration(): number;
  1518. /** @hidden */
  1519. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1520. /**
  1521. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1522. * @returns a number
  1523. */
  1524. getAnimationRatio(): number;
  1525. /**
  1526. * Gets an unique Id for the current frame
  1527. * @returns a number
  1528. */
  1529. getRenderId(): number;
  1530. /** Call this function if you want to manually increment the render Id*/
  1531. incrementRenderId(): void;
  1532. private _updatePointerPosition(evt);
  1533. private _createUbo();
  1534. private _createAlternateUbo();
  1535. /**
  1536. * Use this method to simulate a pointer move on a mesh
  1537. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1538. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1539. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1540. * @returns the current scene
  1541. */
  1542. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1543. private _processPointerMove(pickResult, evt);
  1544. /**
  1545. * Use this method to simulate a pointer down on a mesh
  1546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1549. * @returns the current scene
  1550. */
  1551. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1552. private _processPointerDown(pickResult, evt);
  1553. /**
  1554. * Use this method to simulate a pointer up on a mesh
  1555. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1556. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1557. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1558. * @returns the current scene
  1559. */
  1560. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1561. private _processPointerUp(pickResult, evt, clickInfo);
  1562. /**
  1563. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1564. * @param attachUp defines if you want to attach events to pointerup
  1565. * @param attachDown defines if you want to attach events to pointerdown
  1566. * @param attachMove defines if you want to attach events to pointermove
  1567. */
  1568. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1569. /** Detaches all event handlers*/
  1570. detachControl(): void;
  1571. /**
  1572. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1573. * Delay loaded resources are not taking in account
  1574. * @return true if all required resources are ready
  1575. */
  1576. isReady(): boolean;
  1577. /** Resets all cached information relative to material (including effect and visibility) */
  1578. resetCachedMaterial(): void;
  1579. /**
  1580. * Registers a function to be called before every frame render
  1581. * @param func defines the function to register
  1582. */
  1583. registerBeforeRender(func: () => void): void;
  1584. /**
  1585. * Unregisters a function called before every frame render
  1586. * @param func defines the function to unregister
  1587. */
  1588. unregisterBeforeRender(func: () => void): void;
  1589. /**
  1590. * Registers a function to be called after every frame render
  1591. * @param func defines the function to register
  1592. */
  1593. registerAfterRender(func: () => void): void;
  1594. /**
  1595. * Unregisters a function called after every frame render
  1596. * @param func defines the function to unregister
  1597. */
  1598. unregisterAfterRender(func: () => void): void;
  1599. private _executeOnceBeforeRender(func);
  1600. /**
  1601. * The provided function will run before render once and will be disposed afterwards.
  1602. * A timeout delay can be provided so that the function will be executed in N ms.
  1603. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1604. * @param func The function to be executed.
  1605. * @param timeout optional delay in ms
  1606. */
  1607. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1608. /** @hidden */
  1609. /** @hidden */
  1610. /**
  1611. * Returns the number of items waiting to be loaded
  1612. * @returns the number of items waiting to be loaded
  1613. */
  1614. getWaitingItemsCount(): number;
  1615. /**
  1616. * Returns a boolean indicating if the scene is still loading data
  1617. */
  1618. readonly isLoading: boolean;
  1619. /**
  1620. * Registers a function to be executed when the scene is ready
  1621. * @param {Function} func - the function to be executed
  1622. */
  1623. executeWhenReady(func: () => void): void;
  1624. /**
  1625. * Returns a promise that resolves when the scene is ready
  1626. * @returns A promise that resolves when the scene is ready
  1627. */
  1628. whenReadyAsync(): Promise<void>;
  1629. /** @hidden */
  1630. /**
  1631. * Will start the animation sequence of a given target
  1632. * @param target defines the target
  1633. * @param from defines from which frame should animation start
  1634. * @param to defines until which frame should animation run.
  1635. * @param weight defines the weight to apply to the animation (1.0 by default)
  1636. * @param loop defines if the animation loops
  1637. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1638. * @param onAnimationEnd defines the function to be executed when the animation ends
  1639. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1640. * @returns the animatable object created for this animation
  1641. */
  1642. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1643. /**
  1644. * Will start the animation sequence of a given target
  1645. * @param target defines the target
  1646. * @param from defines from which frame should animation start
  1647. * @param to defines until which frame should animation run.
  1648. * @param loop defines if the animation loops
  1649. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1650. * @param onAnimationEnd defines the function to be executed when the animation ends
  1651. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1652. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1653. * @returns the animatable object created for this animation
  1654. */
  1655. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1656. /**
  1657. * Begin a new animation on a given node
  1658. * @param target defines the target where the animation will take place
  1659. * @param animations defines the list of animations to start
  1660. * @param from defines the initial value
  1661. * @param to defines the final value
  1662. * @param loop defines if you want animation to loop (off by default)
  1663. * @param speedRatio defines the speed ratio to apply to all animations
  1664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1665. * @returns the list of created animatables
  1666. */
  1667. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1668. /**
  1669. * Begin a new animation on a given node and its hierarchy
  1670. * @param target defines the root node where the animation will take place
  1671. * @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.
  1672. * @param animations defines the list of animations to start
  1673. * @param from defines the initial value
  1674. * @param to defines the final value
  1675. * @param loop defines if you want animation to loop (off by default)
  1676. * @param speedRatio defines the speed ratio to apply to all animations
  1677. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1678. * @returns the list of animatables created for all nodes
  1679. */
  1680. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1681. /**
  1682. * Gets the animatable associated with a specific target
  1683. * @param target defines the target of the animatable
  1684. * @returns the required animatable if found
  1685. */
  1686. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1687. /**
  1688. * Gets all animatables associated with a given target
  1689. * @param target defines the target to look animatables for
  1690. * @returns an array of Animatables
  1691. */
  1692. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1693. /**
  1694. * Gets all animatable attached to the scene
  1695. */
  1696. readonly animatables: Animatable[];
  1697. /**
  1698. * Will stop the animation of the given target
  1699. * @param target - the target
  1700. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1701. */
  1702. stopAnimation(target: any, animationName?: string): void;
  1703. /**
  1704. * Stops and removes all animations that have been applied to the scene
  1705. */
  1706. stopAllAnimations(): void;
  1707. private _animate();
  1708. /** @hidden */
  1709. private _processLateAnimationBindingsForMatrices(holder, originalValue);
  1710. private _processLateAnimationBindings();
  1711. /** @hidden */
  1712. /**
  1713. * Gets the current view matrix
  1714. * @returns a Matrix
  1715. */
  1716. getViewMatrix(): Matrix;
  1717. /**
  1718. * Gets the current projection matrix
  1719. * @returns a Matrix
  1720. */
  1721. getProjectionMatrix(): Matrix;
  1722. /**
  1723. * Gets the current transform matrix
  1724. * @returns a Matrix made of View * Projection
  1725. */
  1726. getTransformMatrix(): Matrix;
  1727. /**
  1728. * Sets the current transform matrix
  1729. * @param view defines the View matrix to use
  1730. * @param projection defines the Projection matrix to use
  1731. */
  1732. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1733. /** @hidden */
  1734. /**
  1735. * Gets the uniform buffer used to store scene data
  1736. * @returns a UniformBuffer
  1737. */
  1738. getSceneUniformBuffer(): UniformBuffer;
  1739. /**
  1740. * Gets an unique (relatively to the current scene) Id
  1741. * @returns an unique number for the scene
  1742. */
  1743. getUniqueId(): number;
  1744. /**
  1745. * Add a mesh to the list of scene's meshes
  1746. * @param newMesh defines the mesh to add
  1747. */
  1748. addMesh(newMesh: AbstractMesh): void;
  1749. /**
  1750. * Remove a mesh for the list of scene's meshes
  1751. * @param toRemove defines the mesh to remove
  1752. * @param recursive if all child meshes should also be removed from the scene
  1753. * @returns the index where the mesh was in the mesh list
  1754. */
  1755. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1756. /**
  1757. * Add a transform node to the list of scene's transform nodes
  1758. * @param newTransformNode defines the transform node to add
  1759. */
  1760. addTransformNode(newTransformNode: TransformNode): void;
  1761. /**
  1762. * Remove a transform node for the list of scene's transform nodes
  1763. * @param toRemove defines the transform node to remove
  1764. * @returns the index where the transform node was in the transform node list
  1765. */
  1766. removeTransformNode(toRemove: TransformNode): number;
  1767. /**
  1768. * Remove a skeleton for the list of scene's skeletons
  1769. * @param toRemove defines the skeleton to remove
  1770. * @returns the index where the skeleton was in the skeleton list
  1771. */
  1772. removeSkeleton(toRemove: Skeleton): number;
  1773. /**
  1774. * Remove a morph target for the list of scene's morph targets
  1775. * @param toRemove defines the morph target to remove
  1776. * @returns the index where the morph target was in the morph target list
  1777. */
  1778. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1779. /**
  1780. * Remove a light for the list of scene's lights
  1781. * @param toRemove defines the light to remove
  1782. * @returns the index where the light was in the light list
  1783. */
  1784. removeLight(toRemove: Light): number;
  1785. /**
  1786. * Remove a camera for the list of scene's cameras
  1787. * @param toRemove defines the camera to remove
  1788. * @returns the index where the camera was in the camera list
  1789. */
  1790. removeCamera(toRemove: Camera): number;
  1791. /**
  1792. * Remove a particle system for the list of scene's particle systems
  1793. * @param toRemove defines the particle system to remove
  1794. * @returns the index where the particle system was in the particle system list
  1795. */
  1796. removeParticleSystem(toRemove: IParticleSystem): number;
  1797. /**
  1798. * Remove a animation for the list of scene's animations
  1799. * @param toRemove defines the animation to remove
  1800. * @returns the index where the animation was in the animation list
  1801. */
  1802. removeAnimation(toRemove: Animation): number;
  1803. /**
  1804. * Removes the given animation group from this scene.
  1805. * @param toRemove The animation group to remove
  1806. * @returns The index of the removed animation group
  1807. */
  1808. removeAnimationGroup(toRemove: AnimationGroup): number;
  1809. /**
  1810. * Removes the given multi-material from this scene.
  1811. * @param toRemove The multi-material to remove
  1812. * @returns The index of the removed multi-material
  1813. */
  1814. removeMultiMaterial(toRemove: MultiMaterial): number;
  1815. /**
  1816. * Removes the given material from this scene.
  1817. * @param toRemove The material to remove
  1818. * @returns The index of the removed material
  1819. */
  1820. removeMaterial(toRemove: Material): number;
  1821. /**
  1822. * Removes the given lens flare system from this scene.
  1823. * @param toRemove The lens flare system to remove
  1824. * @returns The index of the removed lens flare system
  1825. */
  1826. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1827. /**
  1828. * Removes the given action manager from this scene.
  1829. * @param toRemove The action manager to remove
  1830. * @returns The index of the removed action manager
  1831. */
  1832. removeActionManager(toRemove: ActionManager): number;
  1833. /**
  1834. * Removes the given effect layer from this scene.
  1835. * @param toRemove defines the effect layer to remove
  1836. * @returns the index of the removed effect layer
  1837. */
  1838. removeEffectLayer(toRemove: EffectLayer): number;
  1839. /**
  1840. * Removes the given texture from this scene.
  1841. * @param toRemove The texture to remove
  1842. * @returns The index of the removed texture
  1843. */
  1844. removeTexture(toRemove: BaseTexture): number;
  1845. /**
  1846. * Adds the given light to this scene
  1847. * @param newLight The light to add
  1848. */
  1849. addLight(newLight: Light): void;
  1850. /**
  1851. * Sorts the list list based on light priorities
  1852. */
  1853. sortLightsByPriority(): void;
  1854. /**
  1855. * Adds the given camera to this scene
  1856. * @param newCamera The camera to add
  1857. */
  1858. addCamera(newCamera: Camera): void;
  1859. /**
  1860. * Adds the given skeleton to this scene
  1861. * @param newSkeleton The skeleton to add
  1862. */
  1863. addSkeleton(newSkeleton: Skeleton): void;
  1864. /**
  1865. * Adds the given particle system to this scene
  1866. * @param newParticleSystem The particle system to add
  1867. */
  1868. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1869. /**
  1870. * Adds the given animation to this scene
  1871. * @param newAnimation The animation to add
  1872. */
  1873. addAnimation(newAnimation: Animation): void;
  1874. /**
  1875. * Adds the given animation group to this scene.
  1876. * @param newAnimationGroup The animation group to add
  1877. */
  1878. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1879. /**
  1880. * Adds the given multi-material to this scene
  1881. * @param newMultiMaterial The multi-material to add
  1882. */
  1883. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1884. /**
  1885. * Adds the given material to this scene
  1886. * @param newMaterial The material to add
  1887. */
  1888. addMaterial(newMaterial: Material): void;
  1889. /**
  1890. * Adds the given morph target to this scene
  1891. * @param newMorphTargetManager The morph target to add
  1892. */
  1893. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1894. /**
  1895. * Adds the given geometry to this scene
  1896. * @param newGeometry The geometry to add
  1897. */
  1898. addGeometry(newGeometry: Geometry): void;
  1899. /**
  1900. * Adds the given lens flare system to this scene
  1901. * @param newLensFlareSystem The lens flare system to add
  1902. */
  1903. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1904. /**
  1905. * Adds the given effect layer to this scene
  1906. * @param newEffectLayer defines the effect layer to add
  1907. */
  1908. addEffectLayer(newEffectLayer: EffectLayer): void;
  1909. /**
  1910. * Adds the given action manager to this scene
  1911. * @param newActionManager The action manager to add
  1912. */
  1913. addActionManager(newActionManager: ActionManager): void;
  1914. /**
  1915. * Adds the given texture to this scene.
  1916. * @param newTexture The texture to add
  1917. */
  1918. addTexture(newTexture: BaseTexture): void;
  1919. /**
  1920. * Switch active camera
  1921. * @param newCamera defines the new active camera
  1922. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1923. */
  1924. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1925. /**
  1926. * sets the active camera of the scene using its ID
  1927. * @param id defines the camera's ID
  1928. * @return the new active camera or null if none found.
  1929. */
  1930. setActiveCameraByID(id: string): Nullable<Camera>;
  1931. /**
  1932. * sets the active camera of the scene using its name
  1933. * @param name defines the camera's name
  1934. * @returns the new active camera or null if none found.
  1935. */
  1936. setActiveCameraByName(name: string): Nullable<Camera>;
  1937. /**
  1938. * get an animation group using its name
  1939. * @param name defines the material's name
  1940. * @return the animation group or null if none found.
  1941. */
  1942. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1943. /**
  1944. * get a material using its id
  1945. * @param id defines the material's ID
  1946. * @return the material or null if none found.
  1947. */
  1948. getMaterialByID(id: string): Nullable<Material>;
  1949. /**
  1950. * Gets a material using its name
  1951. * @param name defines the material's name
  1952. * @return the material or null if none found.
  1953. */
  1954. getMaterialByName(name: string): Nullable<Material>;
  1955. /**
  1956. * Gets a lens flare system using its name
  1957. * @param name defines the name to look for
  1958. * @returns the lens flare system or null if not found
  1959. */
  1960. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1961. /**
  1962. * Gets a lens flare system using its id
  1963. * @param id defines the id to look for
  1964. * @returns the lens flare system or null if not found
  1965. */
  1966. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1967. /**
  1968. * Gets a camera using its id
  1969. * @param id defines the id to look for
  1970. * @returns the camera or null if not found
  1971. */
  1972. getCameraByID(id: string): Nullable<Camera>;
  1973. /**
  1974. * Gets a camera using its unique id
  1975. * @param uniqueId defines the unique id to look for
  1976. * @returns the camera or null if not found
  1977. */
  1978. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1979. /**
  1980. * Gets a camera using its name
  1981. * @param name defines the camera's name
  1982. * @return the camera or null if none found.
  1983. */
  1984. getCameraByName(name: string): Nullable<Camera>;
  1985. /**
  1986. * Gets a bone using its id
  1987. * @param id defines the bone's id
  1988. * @return the bone or null if not found
  1989. */
  1990. getBoneByID(id: string): Nullable<Bone>;
  1991. /**
  1992. * Gets a bone using its id
  1993. * @param name defines the bone's name
  1994. * @return the bone or null if not found
  1995. */
  1996. getBoneByName(name: string): Nullable<Bone>;
  1997. /**
  1998. * Gets a light node using its name
  1999. * @param name defines the the light's name
  2000. * @return the light or null if none found.
  2001. */
  2002. getLightByName(name: string): Nullable<Light>;
  2003. /**
  2004. * Gets a light node using its id
  2005. * @param id defines the light's id
  2006. * @return the light or null if none found.
  2007. */
  2008. getLightByID(id: string): Nullable<Light>;
  2009. /**
  2010. * Gets a light node using its scene-generated unique ID
  2011. * @param uniqueId defines the light's unique id
  2012. * @return the light or null if none found.
  2013. */
  2014. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2015. /**
  2016. * Gets a particle system by id
  2017. * @param id defines the particle system id
  2018. * @return the corresponding system or null if none found
  2019. */
  2020. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2021. /**
  2022. * Gets a geometry using its ID
  2023. * @param id defines the geometry's id
  2024. * @return the geometry or null if none found.
  2025. */
  2026. getGeometryByID(id: string): Nullable<Geometry>;
  2027. /**
  2028. * Add a new geometry to this scene
  2029. * @param geometry defines the geometry to be added to the scene.
  2030. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2031. * @return a boolean defining if the geometry was added or not
  2032. */
  2033. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2034. /**
  2035. * Removes an existing geometry
  2036. * @param geometry defines the geometry to be removed from the scene
  2037. * @return a boolean defining if the geometry was removed or not
  2038. */
  2039. removeGeometry(geometry: Geometry): boolean;
  2040. /**
  2041. * Gets the list of geometries attached to the scene
  2042. * @returns an array of Geometry
  2043. */
  2044. getGeometries(): Geometry[];
  2045. /**
  2046. * Gets the first added mesh found of a given ID
  2047. * @param id defines the id to search for
  2048. * @return the mesh found or null if not found at all
  2049. */
  2050. getMeshByID(id: string): Nullable<AbstractMesh>;
  2051. /**
  2052. * Gets a list of meshes using their id
  2053. * @param id defines the id to search for
  2054. * @returns a list of meshes
  2055. */
  2056. getMeshesByID(id: string): Array<AbstractMesh>;
  2057. /**
  2058. * Gets the first added transform node found of a given ID
  2059. * @param id defines the id to search for
  2060. * @return the found transform node or null if not found at all.
  2061. */
  2062. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2063. /**
  2064. * Gets a list of transform nodes using their id
  2065. * @param id defines the id to search for
  2066. * @returns a list of transform nodes
  2067. */
  2068. getTransformNodesByID(id: string): Array<TransformNode>;
  2069. /**
  2070. * Gets a mesh with its auto-generated unique id
  2071. * @param uniqueId defines the unique id to search for
  2072. * @return the found mesh or null if not found at all.
  2073. */
  2074. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2075. /**
  2076. * Gets a the last added mesh using a given id
  2077. * @param id defines the id to search for
  2078. * @return the found mesh or null if not found at all.
  2079. */
  2080. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2081. /**
  2082. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2083. * @param id defines the id to search for
  2084. * @return the found node or null if not found at all
  2085. */
  2086. getLastEntryByID(id: string): Nullable<Node>;
  2087. /**
  2088. * Gets a node (Mesh, Camera, Light) using a given id
  2089. * @param id defines the id to search for
  2090. * @return the found node or null if not found at all
  2091. */
  2092. getNodeByID(id: string): Nullable<Node>;
  2093. /**
  2094. * Gets a node (Mesh, Camera, Light) using a given name
  2095. * @param name defines the name to search for
  2096. * @return the found node or null if not found at all.
  2097. */
  2098. getNodeByName(name: string): Nullable<Node>;
  2099. /**
  2100. * Gets a mesh using a given name
  2101. * @param name defines the name to search for
  2102. * @return the found mesh or null if not found at all.
  2103. */
  2104. getMeshByName(name: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a transform node using a given name
  2107. * @param name defines the name to search for
  2108. * @return the found transform node or null if not found at all.
  2109. */
  2110. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2111. /**
  2112. * Gets a sound using a given name
  2113. * @param name defines the name to search for
  2114. * @return the found sound or null if not found at all.
  2115. */
  2116. getSoundByName(name: string): Nullable<Sound>;
  2117. /**
  2118. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2119. * @param id defines the id to search for
  2120. * @return the found skeleton or null if not found at all.
  2121. */
  2122. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2123. /**
  2124. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2125. * @param id defines the id to search for
  2126. * @return the found skeleton or null if not found at all.
  2127. */
  2128. getSkeletonById(id: string): Nullable<Skeleton>;
  2129. /**
  2130. * Gets a skeleton using a given name
  2131. * @param name defines the name to search for
  2132. * @return the found skeleton or null if not found at all.
  2133. */
  2134. getSkeletonByName(name: string): Nullable<Skeleton>;
  2135. /**
  2136. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2137. * @param id defines the id to search for
  2138. * @return the found morph target manager or null if not found at all.
  2139. */
  2140. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2141. /**
  2142. * Gets a boolean indicating if the given mesh is active
  2143. * @param mesh defines the mesh to look for
  2144. * @returns true if the mesh is in the active list
  2145. */
  2146. isActiveMesh(mesh: AbstractMesh): boolean;
  2147. /**
  2148. * Return a the first highlight layer of the scene with a given name.
  2149. * @param name The name of the highlight layer to look for.
  2150. * @return The highlight layer if found otherwise null.
  2151. */
  2152. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2153. /**
  2154. * Return a the first highlight layer of the scene with a given name.
  2155. * @param name The name of the highlight layer to look for.
  2156. * @return The highlight layer if found otherwise null.
  2157. */
  2158. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2159. /**
  2160. * Return a unique id as a string which can serve as an identifier for the scene
  2161. */
  2162. readonly uid: string;
  2163. /**
  2164. * Add an externaly attached data from its key.
  2165. * This method call will fail and return false, if such key already exists.
  2166. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2167. * @param key the unique key that identifies the data
  2168. * @param data the data object to associate to the key for this Engine instance
  2169. * @return true if no such key were already present and the data was added successfully, false otherwise
  2170. */
  2171. addExternalData<T>(key: string, data: T): boolean;
  2172. /**
  2173. * Get an externaly attached data from its key
  2174. * @param key the unique key that identifies the data
  2175. * @return the associated data, if present (can be null), or undefined if not present
  2176. */
  2177. getExternalData<T>(key: string): Nullable<T>;
  2178. /**
  2179. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2180. * @param key the unique key that identifies the data
  2181. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2182. * @return the associated data, can be null if the factory returned null.
  2183. */
  2184. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2185. /**
  2186. * Remove an externaly attached data from the Engine instance
  2187. * @param key the unique key that identifies the data
  2188. * @return true if the data was successfully removed, false if it doesn't exist
  2189. */
  2190. removeExternalData(key: string): boolean;
  2191. private _evaluateSubMesh(subMesh, mesh);
  2192. /**
  2193. * Clear the processed materials smart array preventing retention point in material dispose.
  2194. */
  2195. freeProcessedMaterials(): void;
  2196. /**
  2197. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2198. */
  2199. freeActiveMeshes(): void;
  2200. /**
  2201. * Clear the info related to rendering groups preventing retention points during dispose.
  2202. */
  2203. freeRenderingGroups(): void;
  2204. /** @hidden */
  2205. private _activeMeshCandidateProvider;
  2206. /**
  2207. * Defines the current active mesh candidate provider
  2208. * @param provider defines the provider to use
  2209. */
  2210. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2211. /**
  2212. * Gets the current active mesh candidate provider
  2213. * @returns the current active mesh candidate provider
  2214. */
  2215. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2216. private _activeMeshesFrozen;
  2217. /**
  2218. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2219. * @returns the current scene
  2220. */
  2221. freezeActiveMeshes(): Scene;
  2222. /**
  2223. * Use this function to restart evaluating active meshes on every frame
  2224. * @returns the current scene
  2225. */
  2226. unfreezeActiveMeshes(): Scene;
  2227. private _evaluateActiveMeshes();
  2228. private _activeMesh(sourceMesh, mesh);
  2229. /**
  2230. * Update the transform matrix to update from the current active camera
  2231. * @param force defines a boolean used to force the update even if cache is up to date
  2232. */
  2233. updateTransformMatrix(force?: boolean): void;
  2234. /**
  2235. * 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)
  2236. * @param alternateCamera defines the camera to use
  2237. */
  2238. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2239. private _renderForCamera(camera, rigParent?);
  2240. private _processSubCameras(camera);
  2241. private _checkIntersections();
  2242. /**
  2243. * Render the scene
  2244. */
  2245. render(): void;
  2246. private _updateAudioParameters();
  2247. /**
  2248. * Gets or sets if audio support is enabled
  2249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2250. */
  2251. audioEnabled: boolean;
  2252. private _disableAudio();
  2253. private _enableAudio();
  2254. /**
  2255. * Gets or sets if audio will be output to headphones
  2256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2257. */
  2258. headphone: boolean;
  2259. private _switchAudioModeForHeadphones();
  2260. private _switchAudioModeForNormalSpeakers();
  2261. /**
  2262. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2263. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2264. * @returns the created depth renderer
  2265. */
  2266. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2267. /**
  2268. * Disables a depth renderer for a given camera
  2269. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2270. */
  2271. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2272. /**
  2273. * Enables a GeometryBufferRender and associates it with the scene
  2274. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2275. * @returns the GeometryBufferRenderer
  2276. */
  2277. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2278. /**
  2279. * Disables the GeometryBufferRender associated with the scene
  2280. */
  2281. disableGeometryBufferRenderer(): void;
  2282. /**
  2283. * Freeze all materials
  2284. * A frozen material will not be updatable but should be faster to render
  2285. */
  2286. freezeMaterials(): void;
  2287. /**
  2288. * Unfreeze all materials
  2289. * A frozen material will not be updatable but should be faster to render
  2290. */
  2291. unfreezeMaterials(): void;
  2292. /**
  2293. * Releases all held ressources
  2294. */
  2295. dispose(): void;
  2296. /**
  2297. * Gets if the scene is already disposed
  2298. */
  2299. readonly isDisposed: boolean;
  2300. /**
  2301. * Releases sounds & soundtracks
  2302. */
  2303. disposeSounds(): void;
  2304. /**
  2305. * Get the world extend vectors with an optional filter
  2306. *
  2307. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2308. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2309. */
  2310. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2311. min: Vector3;
  2312. max: Vector3;
  2313. };
  2314. /**
  2315. * Creates or updates the octree used to boost selection (picking)
  2316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2317. * @param maxCapacity defines the maximum capacity per leaf
  2318. * @param maxDepth defines the maximum depth of the octree
  2319. * @returns an octree of AbstractMesh
  2320. */
  2321. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2322. /**
  2323. * Creates a ray that can be used to pick in the scene
  2324. * @param x defines the x coordinate of the origin (on-screen)
  2325. * @param y defines the y coordinate of the origin (on-screen)
  2326. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2327. * @param camera defines the camera to use for the picking
  2328. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2329. * @returns a Ray
  2330. */
  2331. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2332. /**
  2333. * Creates a ray that can be used to pick in the scene
  2334. * @param x defines the x coordinate of the origin (on-screen)
  2335. * @param y defines the y coordinate of the origin (on-screen)
  2336. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2337. * @param result defines the ray where to store the picking ray
  2338. * @param camera defines the camera to use for the picking
  2339. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2340. * @returns the current scene
  2341. */
  2342. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2343. /**
  2344. * Creates a ray that can be used to pick in the scene
  2345. * @param x defines the x coordinate of the origin (on-screen)
  2346. * @param y defines the y coordinate of the origin (on-screen)
  2347. * @param camera defines the camera to use for the picking
  2348. * @returns a Ray
  2349. */
  2350. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2351. /**
  2352. * Creates a ray that can be used to pick in the scene
  2353. * @param x defines the x coordinate of the origin (on-screen)
  2354. * @param y defines the y coordinate of the origin (on-screen)
  2355. * @param result defines the ray where to store the picking ray
  2356. * @param camera defines the camera to use for the picking
  2357. * @returns the current scene
  2358. */
  2359. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2360. private _internalPick(rayFunction, predicate?, fastCheck?);
  2361. private _internalMultiPick(rayFunction, predicate?);
  2362. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2363. private _tempPickingRay;
  2364. /** Launch a ray to try to pick a mesh in the scene
  2365. * @param x position on screen
  2366. * @param y position on screen
  2367. * @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
  2368. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2369. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2370. * @returns a PickingInfo
  2371. */
  2372. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2373. /** Launch a ray to try to pick a sprite in the scene
  2374. * @param x position on screen
  2375. * @param y position on screen
  2376. * @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
  2377. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2378. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2379. * @returns a PickingInfo
  2380. */
  2381. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2382. private _cachedRayForTransform;
  2383. /** Use the given ray to pick a mesh in the scene
  2384. * @param ray The ray to use to pick meshes
  2385. * @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
  2386. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2387. * @returns a PickingInfo
  2388. */
  2389. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2390. /**
  2391. * Launch a ray to try to pick a mesh in the scene
  2392. * @param x X position on screen
  2393. * @param y Y position on screen
  2394. * @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
  2395. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2396. * @returns an array of PickingInfo
  2397. */
  2398. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2399. /**
  2400. * Launch a ray to try to pick a mesh in the scene
  2401. * @param ray Ray to use
  2402. * @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
  2403. * @returns an array of PickingInfo
  2404. */
  2405. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2406. /**
  2407. * Force the value of meshUnderPointer
  2408. * @param mesh defines the mesh to use
  2409. */
  2410. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2411. /**
  2412. * Gets the mesh under the pointer
  2413. * @returns a Mesh or null if no mesh is under the pointer
  2414. */
  2415. getPointerOverMesh(): Nullable<AbstractMesh>;
  2416. /**
  2417. * Force the sprite under the pointer
  2418. * @param sprite defines the sprite to use
  2419. */
  2420. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2421. /**
  2422. * Gets the sprite under the pointer
  2423. * @returns a Sprite or null if no sprite is under the pointer
  2424. */
  2425. getPointerOverSprite(): Nullable<Sprite>;
  2426. /**
  2427. * Gets the current physics engine
  2428. * @returns a PhysicsEngine or null if none attached
  2429. */
  2430. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2431. /**
  2432. * Enables physics to the current scene
  2433. * @param gravity defines the scene's gravity for the physics engine
  2434. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2435. * @return a boolean indicating if the physics engine was initialized
  2436. */
  2437. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2438. /**
  2439. * Disables and disposes the physics engine associated with the scene
  2440. */
  2441. disablePhysicsEngine(): void;
  2442. /**
  2443. * Gets a boolean indicating if there is an active physics engine
  2444. * @returns a boolean indicating if there is an active physics engine
  2445. */
  2446. isPhysicsEnabled(): boolean;
  2447. /**
  2448. * Deletes a physics compound impostor
  2449. * @param compound defines the compound to delete
  2450. */
  2451. deleteCompoundImpostor(compound: any): void;
  2452. /** @hidden */
  2453. /** @hidden */
  2454. /**
  2455. * Creates a default light for the scene.
  2456. * @param replace Whether to replace the existing lights in the scene.
  2457. */
  2458. createDefaultLight(replace?: boolean): void;
  2459. /**
  2460. * Creates a default camera for the scene.
  2461. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2462. * @param replace Whether to replace the existing active camera in the scene.
  2463. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2464. */
  2465. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2466. /**
  2467. * Creates a default camera and a default light
  2468. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2469. * @param replace defines if the camera and/or light will replace the existing ones
  2470. * @param attachCameraControls defines if attachControl will be called on the new camera
  2471. */
  2472. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2473. /**
  2474. * Creates a new sky box
  2475. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2476. * @param environmentTexture defines the texture to use as environment texture
  2477. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2478. * @param scale defines the overall scale of the skybox
  2479. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2480. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2481. * @returns a new mesh holding the sky box
  2482. */
  2483. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2484. /**
  2485. * Creates a new environment
  2486. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2487. * @param options defines the options you can use to configure the environment
  2488. * @returns the new EnvironmentHelper
  2489. */
  2490. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2491. /**
  2492. * Creates a new VREXperienceHelper
  2493. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2494. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2495. * @returns a new VREXperienceHelper
  2496. */
  2497. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2498. private _getByTags(list, tagsQuery, forEach?);
  2499. /**
  2500. * Get a list of meshes by tags
  2501. * @param tagsQuery defines the tags query to use
  2502. * @param forEach defines a predicate used to filter results
  2503. * @returns an array of Mesh
  2504. */
  2505. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2506. /**
  2507. * Get a list of cameras by tags
  2508. * @param tagsQuery defines the tags query to use
  2509. * @param forEach defines a predicate used to filter results
  2510. * @returns an array of Camera
  2511. */
  2512. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2513. /**
  2514. * Get a list of lights by tags
  2515. * @param tagsQuery defines the tags query to use
  2516. * @param forEach defines a predicate used to filter results
  2517. * @returns an array of Light
  2518. */
  2519. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2520. /**
  2521. * Get a list of materials by tags
  2522. * @param tagsQuery defines the tags query to use
  2523. * @param forEach defines a predicate used to filter results
  2524. * @returns an array of Material
  2525. */
  2526. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2527. /**
  2528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2529. * This allowed control for front to back rendering or reversly depending of the special needs.
  2530. *
  2531. * @param renderingGroupId The rendering group id corresponding to its index
  2532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2535. */
  2536. 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;
  2537. /**
  2538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2539. *
  2540. * @param renderingGroupId The rendering group id corresponding to its index
  2541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2544. */
  2545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2546. /**
  2547. * Will flag all materials as dirty to trigger new shader compilation
  2548. * @param flag defines the flag used to specify which material part must be marked as dirty
  2549. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2550. */
  2551. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2552. /** @hidden */
  2553. /** @hidden */
  2554. }
  2555. }
  2556. declare module BABYLON {
  2557. type Nullable<T> = T | null;
  2558. type float = number;
  2559. type double = number;
  2560. type int = number;
  2561. type FloatArray = number[] | Float32Array;
  2562. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2563. /**
  2564. * Alias for types that can be used by a Buffer or VertexBuffer.
  2565. */
  2566. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2567. }
  2568. declare module BABYLON {
  2569. /**
  2570. * The action to be carried out following a trigger
  2571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2572. */
  2573. class Action {
  2574. /** the trigger, with or without parameters, for the action */
  2575. triggerOptions: any;
  2576. /**
  2577. * Trigger for the action
  2578. */
  2579. trigger: number;
  2580. /**
  2581. * Internal only - manager for action
  2582. * @hidden
  2583. */
  2584. private _nextActiveAction;
  2585. private _child;
  2586. private _condition?;
  2587. private _triggerParameter;
  2588. /**
  2589. * An event triggered prior to action being executed.
  2590. */
  2591. onBeforeExecuteObservable: Observable<Action>;
  2592. /**
  2593. * Creates a new Action
  2594. * @param triggerOptions the trigger, with or without parameters, for the action
  2595. * @param condition an optional determinant of action
  2596. */
  2597. constructor(
  2598. /** the trigger, with or without parameters, for the action */
  2599. triggerOptions: any, condition?: Condition);
  2600. /**
  2601. * Internal only
  2602. * @hidden
  2603. */
  2604. /**
  2605. * Gets the trigger parameters
  2606. * @returns the trigger parameters
  2607. */
  2608. getTriggerParameter(): any;
  2609. /**
  2610. * Internal only - executes current action event
  2611. * @hidden
  2612. */
  2613. /**
  2614. * Execute placeholder for child classes
  2615. * @param evt optional action event
  2616. */
  2617. execute(evt?: ActionEvent): void;
  2618. /**
  2619. * Skips to next active action
  2620. */
  2621. skipToNextActiveAction(): void;
  2622. /**
  2623. * Adds action to chain of actions, may be a DoNothingAction
  2624. * @param action defines the next action to execute
  2625. * @returns The action passed in
  2626. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2627. */
  2628. then(action: Action): Action;
  2629. /**
  2630. * Internal only
  2631. * @hidden
  2632. */
  2633. /**
  2634. * Internal only
  2635. * @hidden
  2636. */
  2637. /**
  2638. * Serialize placeholder for child classes
  2639. * @param parent of child
  2640. * @returns the serialized object
  2641. */
  2642. serialize(parent: any): any;
  2643. /**
  2644. * Internal only called by serialize
  2645. * @hidden
  2646. */
  2647. protected _serialize(serializedAction: any, parent?: any): any;
  2648. /**
  2649. * Internal only
  2650. * @hidden
  2651. */
  2652. private static _SerializeValueAsString: (value: any) => string;
  2653. /**
  2654. * Internal only
  2655. * @hidden
  2656. */
  2657. private static _GetTargetProperty: (target: Scene | Node) => {
  2658. name: string;
  2659. targetType: string;
  2660. value: string;
  2661. };
  2662. }
  2663. }
  2664. declare module BABYLON {
  2665. /**
  2666. * ActionEvent is the event being sent when an action is triggered.
  2667. */
  2668. class ActionEvent {
  2669. /** The mesh or sprite that triggered the action */
  2670. source: any;
  2671. /** The X mouse cursor position at the time of the event */
  2672. pointerX: number;
  2673. /** The Y mouse cursor position at the time of the event */
  2674. pointerY: number;
  2675. /** The mesh that is currently pointed at (can be null) */
  2676. meshUnderPointer: Nullable<AbstractMesh>;
  2677. /** the original (browser) event that triggered the ActionEvent */
  2678. sourceEvent: any;
  2679. /** additional data for the event */
  2680. additionalData: any;
  2681. /**
  2682. * Creates a new ActionEvent
  2683. * @param source The mesh or sprite that triggered the action
  2684. * @param pointerX The X mouse cursor position at the time of the event
  2685. * @param pointerY The Y mouse cursor position at the time of the event
  2686. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2687. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2688. * @param additionalData additional data for the event
  2689. */
  2690. constructor(
  2691. /** The mesh or sprite that triggered the action */
  2692. source: any,
  2693. /** The X mouse cursor position at the time of the event */
  2694. pointerX: number,
  2695. /** The Y mouse cursor position at the time of the event */
  2696. pointerY: number,
  2697. /** The mesh that is currently pointed at (can be null) */
  2698. meshUnderPointer: Nullable<AbstractMesh>,
  2699. /** the original (browser) event that triggered the ActionEvent */
  2700. sourceEvent?: any,
  2701. /** additional data for the event */
  2702. additionalData?: any);
  2703. /**
  2704. * Helper function to auto-create an ActionEvent from a source mesh.
  2705. * @param source The source mesh that triggered the event
  2706. * @param evt The original (browser) event
  2707. * @param additionalData additional data for the event
  2708. * @returns the new ActionEvent
  2709. */
  2710. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2711. /**
  2712. * Helper function to auto-create an ActionEvent from a source sprite
  2713. * @param source The source sprite that triggered the event
  2714. * @param scene Scene associated with the sprite
  2715. * @param evt The original (browser) event
  2716. * @param additionalData additional data for the event
  2717. * @returns the new ActionEvent
  2718. */
  2719. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2720. /**
  2721. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2722. * @param scene the scene where the event occurred
  2723. * @param evt The original (browser) event
  2724. * @returns the new ActionEvent
  2725. */
  2726. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2727. /**
  2728. * Helper function to auto-create an ActionEvent from a primitive
  2729. * @param prim defines the target primitive
  2730. * @param pointerPos defines the pointer position
  2731. * @param evt The original (browser) event
  2732. * @param additionalData additional data for the event
  2733. * @returns the new ActionEvent
  2734. */
  2735. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2736. }
  2737. /**
  2738. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2739. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2741. */
  2742. class ActionManager {
  2743. private static _NothingTrigger;
  2744. private static _OnPickTrigger;
  2745. private static _OnLeftPickTrigger;
  2746. private static _OnRightPickTrigger;
  2747. private static _OnCenterPickTrigger;
  2748. private static _OnPickDownTrigger;
  2749. private static _OnDoublePickTrigger;
  2750. private static _OnPickUpTrigger;
  2751. private static _OnLongPressTrigger;
  2752. private static _OnPointerOverTrigger;
  2753. private static _OnPointerOutTrigger;
  2754. private static _OnEveryFrameTrigger;
  2755. private static _OnIntersectionEnterTrigger;
  2756. private static _OnIntersectionExitTrigger;
  2757. private static _OnKeyDownTrigger;
  2758. private static _OnKeyUpTrigger;
  2759. private static _OnPickOutTrigger;
  2760. /**
  2761. * Nothing
  2762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2763. */
  2764. static readonly NothingTrigger: number;
  2765. /**
  2766. * On pick
  2767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2768. */
  2769. static readonly OnPickTrigger: number;
  2770. /**
  2771. * On left pick
  2772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2773. */
  2774. static readonly OnLeftPickTrigger: number;
  2775. /**
  2776. * On right pick
  2777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2778. */
  2779. static readonly OnRightPickTrigger: number;
  2780. /**
  2781. * On center pick
  2782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2783. */
  2784. static readonly OnCenterPickTrigger: number;
  2785. /**
  2786. * On pick down
  2787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2788. */
  2789. static readonly OnPickDownTrigger: number;
  2790. /**
  2791. * On double pick
  2792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2793. */
  2794. static readonly OnDoublePickTrigger: number;
  2795. /**
  2796. * On pick up
  2797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2798. */
  2799. static readonly OnPickUpTrigger: number;
  2800. /**
  2801. * On pick out.
  2802. * This trigger will only be raised if you also declared a OnPickDown
  2803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2804. */
  2805. static readonly OnPickOutTrigger: number;
  2806. /**
  2807. * On long press
  2808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2809. */
  2810. static readonly OnLongPressTrigger: number;
  2811. /**
  2812. * On pointer over
  2813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2814. */
  2815. static readonly OnPointerOverTrigger: number;
  2816. /**
  2817. * On pointer out
  2818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2819. */
  2820. static readonly OnPointerOutTrigger: number;
  2821. /**
  2822. * On every frame
  2823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2824. */
  2825. static readonly OnEveryFrameTrigger: number;
  2826. /**
  2827. * On intersection enter
  2828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2829. */
  2830. static readonly OnIntersectionEnterTrigger: number;
  2831. /**
  2832. * On intersection exit
  2833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2834. */
  2835. static readonly OnIntersectionExitTrigger: number;
  2836. /**
  2837. * On key down
  2838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2839. */
  2840. static readonly OnKeyDownTrigger: number;
  2841. /**
  2842. * On key up
  2843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2844. */
  2845. static readonly OnKeyUpTrigger: number;
  2846. /** Gets the list of active triggers */
  2847. static Triggers: {
  2848. [key: string]: number;
  2849. };
  2850. /** Gets the list of actions */
  2851. actions: Action[];
  2852. /** Gets the cursor to use when hovering items */
  2853. hoverCursor: string;
  2854. private _scene;
  2855. /**
  2856. * Creates a new action manager
  2857. * @param scene defines the hosting scene
  2858. */
  2859. constructor(scene: Scene);
  2860. /**
  2861. * Releases all associated resources
  2862. */
  2863. dispose(): void;
  2864. /**
  2865. * Gets hosting scene
  2866. * @returns the hosting scene
  2867. */
  2868. getScene(): Scene;
  2869. /**
  2870. * Does this action manager handles actions of any of the given triggers
  2871. * @param triggers defines the triggers to be tested
  2872. * @return a boolean indicating whether one (or more) of the triggers is handled
  2873. */
  2874. hasSpecificTriggers(triggers: number[]): boolean;
  2875. /**
  2876. * Does this action manager handles actions of a given trigger
  2877. * @param trigger defines the trigger to be tested
  2878. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2879. * @return whether the trigger is handled
  2880. */
  2881. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2882. /**
  2883. * Does this action manager has pointer triggers
  2884. */
  2885. readonly hasPointerTriggers: boolean;
  2886. /**
  2887. * Does this action manager has pick triggers
  2888. */
  2889. readonly hasPickTriggers: boolean;
  2890. /**
  2891. * Does exist one action manager with at least one trigger
  2892. **/
  2893. static readonly HasTriggers: boolean;
  2894. /**
  2895. * Does exist one action manager with at least one pick trigger
  2896. **/
  2897. static readonly HasPickTriggers: boolean;
  2898. /**
  2899. * Does exist one action manager that handles actions of a given trigger
  2900. * @param trigger defines the trigger to be tested
  2901. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2902. **/
  2903. static HasSpecificTrigger(trigger: number): boolean;
  2904. /**
  2905. * Registers an action to this action manager
  2906. * @param action defines the action to be registered
  2907. * @return the action amended (prepared) after registration
  2908. */
  2909. registerAction(action: Action): Nullable<Action>;
  2910. /**
  2911. * Unregisters an action to this action manager
  2912. * @param action defines the action to be unregistered
  2913. * @return a boolean indicating whether the action has been unregistered
  2914. */
  2915. unregisterAction(action: Action): Boolean;
  2916. /**
  2917. * Process a specific trigger
  2918. * @param trigger defines the trigger to process
  2919. * @param evt defines the event details to be processed
  2920. */
  2921. processTrigger(trigger: number, evt?: ActionEvent): void;
  2922. /** @hidden */
  2923. /** @hidden */
  2924. /**
  2925. * Serialize this manager to a JSON object
  2926. * @param name defines the property name to store this manager
  2927. * @returns a JSON representation of this manager
  2928. */
  2929. serialize(name: string): any;
  2930. /**
  2931. * Creates a new ActionManager from a JSON data
  2932. * @param parsedActions defines the JSON data to read from
  2933. * @param object defines the hosting mesh
  2934. * @param scene defines the hosting scene
  2935. */
  2936. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2937. /**
  2938. * Get a trigger name by index
  2939. * @param trigger defines the trigger index
  2940. * @returns a trigger name
  2941. */
  2942. static GetTriggerName(trigger: number): string;
  2943. }
  2944. }
  2945. declare module BABYLON {
  2946. /**
  2947. * A Condition applied to an Action
  2948. */
  2949. class Condition {
  2950. /**
  2951. * Internal only - manager for action
  2952. * @hidden
  2953. */
  2954. /**
  2955. * Internal only
  2956. * @hidden
  2957. */
  2958. /**
  2959. * Internal only
  2960. * @hidden
  2961. */
  2962. /**
  2963. * Creates a new Condition
  2964. * @param actionManager the manager of the action the condition is applied to
  2965. */
  2966. constructor(actionManager: ActionManager);
  2967. /**
  2968. * Check if the current condition is valid
  2969. * @returns a boolean
  2970. */
  2971. isValid(): boolean;
  2972. /**
  2973. * Internal only
  2974. * @hidden
  2975. */
  2976. /**
  2977. * Internal only
  2978. * @hidden
  2979. */
  2980. /**
  2981. * Serialize placeholder for child classes
  2982. * @returns the serialized object
  2983. */
  2984. serialize(): any;
  2985. /**
  2986. * Internal only
  2987. * @hidden
  2988. */
  2989. protected _serialize(serializedCondition: any): any;
  2990. }
  2991. /**
  2992. * Defines specific conditional operators as extensions of Condition
  2993. */
  2994. class ValueCondition extends Condition {
  2995. /** path to specify the property of the target the conditional operator uses */
  2996. propertyPath: string;
  2997. /** the value compared by the conditional operator against the current value of the property */
  2998. value: any;
  2999. /** the conditional operator, default ValueCondition.IsEqual */
  3000. operator: number;
  3001. /**
  3002. * Internal only
  3003. * @hidden
  3004. */
  3005. private static _IsEqual;
  3006. /**
  3007. * Internal only
  3008. * @hidden
  3009. */
  3010. private static _IsDifferent;
  3011. /**
  3012. * Internal only
  3013. * @hidden
  3014. */
  3015. private static _IsGreater;
  3016. /**
  3017. * Internal only
  3018. * @hidden
  3019. */
  3020. private static _IsLesser;
  3021. /**
  3022. * returns the number for IsEqual
  3023. */
  3024. static readonly IsEqual: number;
  3025. /**
  3026. * Returns the number for IsDifferent
  3027. */
  3028. static readonly IsDifferent: number;
  3029. /**
  3030. * Returns the number for IsGreater
  3031. */
  3032. static readonly IsGreater: number;
  3033. /**
  3034. * Returns the number for IsLesser
  3035. */
  3036. static readonly IsLesser: number;
  3037. /**
  3038. * Internal only The action manager for the condition
  3039. * @hidden
  3040. */
  3041. /**
  3042. * Internal only
  3043. * @hidden
  3044. */
  3045. private _target;
  3046. /**
  3047. * Internal only
  3048. * @hidden
  3049. */
  3050. private _effectiveTarget;
  3051. /**
  3052. * Internal only
  3053. * @hidden
  3054. */
  3055. private _property;
  3056. /**
  3057. * Creates a new ValueCondition
  3058. * @param actionManager manager for the action the condition applies to
  3059. * @param target for the action
  3060. * @param propertyPath path to specify the property of the target the conditional operator uses
  3061. * @param value the value compared by the conditional operator against the current value of the property
  3062. * @param operator the conditional operator, default ValueCondition.IsEqual
  3063. */
  3064. constructor(actionManager: ActionManager, target: any,
  3065. /** path to specify the property of the target the conditional operator uses */
  3066. propertyPath: string,
  3067. /** the value compared by the conditional operator against the current value of the property */
  3068. value: any,
  3069. /** the conditional operator, default ValueCondition.IsEqual */
  3070. operator?: number);
  3071. /**
  3072. * Compares the given value with the property value for the specified conditional operator
  3073. * @returns the result of the comparison
  3074. */
  3075. isValid(): boolean;
  3076. /**
  3077. * Serialize the ValueCondition into a JSON compatible object
  3078. * @returns serialization object
  3079. */
  3080. serialize(): any;
  3081. /**
  3082. * Gets the name of the conditional operator for the ValueCondition
  3083. * @param operator the conditional operator
  3084. * @returns the name
  3085. */
  3086. static GetOperatorName(operator: number): string;
  3087. }
  3088. /**
  3089. * Defines a predicate condition as an extension of Condition
  3090. */
  3091. class PredicateCondition extends Condition {
  3092. /** defines the predicate function used to validate the condition */
  3093. predicate: () => boolean;
  3094. /**
  3095. * Internal only - manager for action
  3096. * @hidden
  3097. */
  3098. /**
  3099. * Creates a new PredicateCondition
  3100. * @param actionManager manager for the action the condition applies to
  3101. * @param predicate defines the predicate function used to validate the condition
  3102. */
  3103. constructor(actionManager: ActionManager,
  3104. /** defines the predicate function used to validate the condition */
  3105. predicate: () => boolean);
  3106. /**
  3107. * @returns the validity of the predicate condition
  3108. */
  3109. isValid(): boolean;
  3110. }
  3111. /**
  3112. * Defines a state condition as an extension of Condition
  3113. */
  3114. class StateCondition extends Condition {
  3115. value: string;
  3116. /**
  3117. * Internal only - manager for action
  3118. * @hidden
  3119. */
  3120. /**
  3121. * Internal only
  3122. * @hidden
  3123. */
  3124. private _target;
  3125. /**
  3126. * Creates a new StateCondition
  3127. * @param actionManager manager for the action the condition applies to
  3128. * @param target of the condition
  3129. * @param value to compare with target state
  3130. */
  3131. constructor(actionManager: ActionManager, target: any, value: string);
  3132. /**
  3133. * @returns the validity of the state
  3134. */
  3135. isValid(): boolean;
  3136. /**
  3137. * Serialize the StateCondition into a JSON compatible object
  3138. * @returns serialization object
  3139. */
  3140. serialize(): any;
  3141. }
  3142. }
  3143. declare module BABYLON {
  3144. class SwitchBooleanAction extends Action {
  3145. propertyPath: string;
  3146. private _target;
  3147. private _effectiveTarget;
  3148. private _property;
  3149. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3150. execute(): void;
  3151. serialize(parent: any): any;
  3152. }
  3153. class SetStateAction extends Action {
  3154. value: string;
  3155. private _target;
  3156. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3157. execute(): void;
  3158. serialize(parent: any): any;
  3159. }
  3160. class SetValueAction extends Action {
  3161. propertyPath: string;
  3162. value: any;
  3163. private _target;
  3164. private _effectiveTarget;
  3165. private _property;
  3166. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3167. execute(): void;
  3168. serialize(parent: any): any;
  3169. }
  3170. class IncrementValueAction extends Action {
  3171. propertyPath: string;
  3172. value: any;
  3173. private _target;
  3174. private _effectiveTarget;
  3175. private _property;
  3176. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3177. execute(): void;
  3178. serialize(parent: any): any;
  3179. }
  3180. class PlayAnimationAction extends Action {
  3181. from: number;
  3182. to: number;
  3183. loop: boolean | undefined;
  3184. private _target;
  3185. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3186. execute(): void;
  3187. serialize(parent: any): any;
  3188. }
  3189. class StopAnimationAction extends Action {
  3190. private _target;
  3191. constructor(triggerOptions: any, target: any, condition?: Condition);
  3192. execute(): void;
  3193. serialize(parent: any): any;
  3194. }
  3195. class DoNothingAction extends Action {
  3196. constructor(triggerOptions?: any, condition?: Condition);
  3197. execute(): void;
  3198. serialize(parent: any): any;
  3199. }
  3200. class CombineAction extends Action {
  3201. children: Action[];
  3202. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3203. execute(evt: ActionEvent): void;
  3204. serialize(parent: any): any;
  3205. }
  3206. class ExecuteCodeAction extends Action {
  3207. func: (evt: ActionEvent) => void;
  3208. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3209. execute(evt: ActionEvent): void;
  3210. }
  3211. class SetParentAction extends Action {
  3212. private _parent;
  3213. private _target;
  3214. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3215. execute(): void;
  3216. serialize(parent: any): any;
  3217. }
  3218. class PlaySoundAction extends Action {
  3219. private _sound;
  3220. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3221. execute(): void;
  3222. serialize(parent: any): any;
  3223. }
  3224. class StopSoundAction extends Action {
  3225. private _sound;
  3226. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3227. execute(): void;
  3228. serialize(parent: any): any;
  3229. }
  3230. }
  3231. declare module BABYLON {
  3232. class InterpolateValueAction extends Action {
  3233. propertyPath: string;
  3234. value: any;
  3235. duration: number;
  3236. stopOtherAnimations: boolean | undefined;
  3237. onInterpolationDone: (() => void) | undefined;
  3238. private _target;
  3239. private _effectiveTarget;
  3240. private _property;
  3241. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3242. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3243. execute(): void;
  3244. serialize(parent: any): any;
  3245. }
  3246. }
  3247. declare module BABYLON {
  3248. /**
  3249. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3251. */
  3252. class Analyser {
  3253. /**
  3254. * Gets or sets the smoothing
  3255. * @ignorenaming
  3256. */
  3257. SMOOTHING: number;
  3258. /**
  3259. * Gets or sets the FFT table size
  3260. * @ignorenaming
  3261. */
  3262. FFT_SIZE: number;
  3263. /**
  3264. * Gets or sets the bar graph amplitude
  3265. * @ignorenaming
  3266. */
  3267. BARGRAPHAMPLITUDE: number;
  3268. /**
  3269. * Gets or sets the position of the debug canvas
  3270. * @ignorenaming
  3271. */
  3272. DEBUGCANVASPOS: {
  3273. x: number;
  3274. y: number;
  3275. };
  3276. /**
  3277. * Gets or sets the debug canvas size
  3278. * @ignorenaming
  3279. */
  3280. DEBUGCANVASSIZE: {
  3281. width: number;
  3282. height: number;
  3283. };
  3284. private _byteFreqs;
  3285. private _byteTime;
  3286. private _floatFreqs;
  3287. private _webAudioAnalyser;
  3288. private _debugCanvas;
  3289. private _debugCanvasContext;
  3290. private _scene;
  3291. private _registerFunc;
  3292. private _audioEngine;
  3293. /**
  3294. * Creates a new analyser
  3295. * @param scene defines hosting scene
  3296. */
  3297. constructor(scene: Scene);
  3298. /**
  3299. * Get the number of data values you will have to play with for the visualization
  3300. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3301. * @returns a number
  3302. */
  3303. getFrequencyBinCount(): number;
  3304. /**
  3305. * Gets the current frequency data as a byte array
  3306. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3307. * @returns a Uint8Array
  3308. */
  3309. getByteFrequencyData(): Uint8Array;
  3310. /**
  3311. * Gets the current waveform as a byte array
  3312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3313. * @returns a Uint8Array
  3314. */
  3315. getByteTimeDomainData(): Uint8Array;
  3316. /**
  3317. * Gets the current frequency data as a float array
  3318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3319. * @returns a Float32Array
  3320. */
  3321. getFloatFrequencyData(): Float32Array;
  3322. /**
  3323. * Renders the debug canvas
  3324. */
  3325. drawDebugCanvas(): void;
  3326. /**
  3327. * Stops rendering the debug canvas and removes it
  3328. */
  3329. stopDebugCanvas(): void;
  3330. /**
  3331. * Connects two audio nodes
  3332. * @param inputAudioNode defines first node to connect
  3333. * @param outputAudioNode defines second node to connect
  3334. */
  3335. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3336. /**
  3337. * Releases all associated resources
  3338. */
  3339. dispose(): void;
  3340. }
  3341. }
  3342. declare module BABYLON {
  3343. class AudioEngine {
  3344. private _audioContext;
  3345. private _audioContextInitialized;
  3346. canUseWebAudio: boolean;
  3347. masterGain: GainNode;
  3348. private _connectedAnalyser;
  3349. WarnedWebAudioUnsupported: boolean;
  3350. unlocked: boolean;
  3351. onAudioUnlocked: () => any;
  3352. isMP3supported: boolean;
  3353. isOGGsupported: boolean;
  3354. readonly audioContext: Nullable<AudioContext>;
  3355. constructor();
  3356. private _unlockiOSaudio();
  3357. private _initializeAudioContext();
  3358. dispose(): void;
  3359. getGlobalVolume(): number;
  3360. setGlobalVolume(newVolume: number): void;
  3361. connectToAnalyser(analyser: Analyser): void;
  3362. }
  3363. }
  3364. declare module BABYLON {
  3365. class Sound {
  3366. name: string;
  3367. autoplay: boolean;
  3368. loop: boolean;
  3369. useCustomAttenuation: boolean;
  3370. soundTrackId: number;
  3371. spatialSound: boolean;
  3372. refDistance: number;
  3373. rolloffFactor: number;
  3374. maxDistance: number;
  3375. distanceModel: string;
  3376. private _panningModel;
  3377. onended: () => any;
  3378. private _playbackRate;
  3379. private _streaming;
  3380. private _startTime;
  3381. private _startOffset;
  3382. private _position;
  3383. private _localDirection;
  3384. private _volume;
  3385. private _isReadyToPlay;
  3386. isPlaying: boolean;
  3387. isPaused: boolean;
  3388. private _isDirectional;
  3389. private _readyToPlayCallback;
  3390. private _audioBuffer;
  3391. private _soundSource;
  3392. private _streamingSource;
  3393. private _soundPanner;
  3394. private _soundGain;
  3395. private _inputAudioNode;
  3396. private _ouputAudioNode;
  3397. private _coneInnerAngle;
  3398. private _coneOuterAngle;
  3399. private _coneOuterGain;
  3400. private _scene;
  3401. private _connectedMesh;
  3402. private _customAttenuationFunction;
  3403. private _registerFunc;
  3404. private _isOutputConnected;
  3405. private _htmlAudioElement;
  3406. private _urlType;
  3407. /**
  3408. * Create a sound and attach it to a scene
  3409. * @param name Name of your sound
  3410. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3411. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3412. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3413. */
  3414. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3415. dispose(): void;
  3416. isReady(): boolean;
  3417. private _soundLoaded(audioData);
  3418. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3419. updateOptions(options: any): void;
  3420. private _createSpatialParameters();
  3421. private _updateSpatialParameters();
  3422. switchPanningModelToHRTF(): void;
  3423. switchPanningModelToEqualPower(): void;
  3424. private _switchPanningModel();
  3425. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3426. /**
  3427. * Transform this sound into a directional source
  3428. * @param coneInnerAngle Size of the inner cone in degree
  3429. * @param coneOuterAngle Size of the outer cone in degree
  3430. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3431. */
  3432. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3433. setPosition(newPosition: Vector3): void;
  3434. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3435. private _updateDirection();
  3436. updateDistanceFromListener(): void;
  3437. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3438. /**
  3439. * Play the sound
  3440. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3441. * @param offset (optional) Start the sound setting it at a specific time
  3442. */
  3443. play(time?: number, offset?: number): void;
  3444. private _onended();
  3445. /**
  3446. * Stop the sound
  3447. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3448. */
  3449. stop(time?: number): void;
  3450. pause(): void;
  3451. setVolume(newVolume: number, time?: number): void;
  3452. setPlaybackRate(newPlaybackRate: number): void;
  3453. getVolume(): number;
  3454. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3455. detachFromMesh(): void;
  3456. private _onRegisterAfterWorldMatrixUpdate(node);
  3457. clone(): Nullable<Sound>;
  3458. getAudioBuffer(): AudioBuffer | null;
  3459. serialize(): any;
  3460. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3461. }
  3462. }
  3463. declare module BABYLON {
  3464. class SoundTrack {
  3465. private _outputAudioNode;
  3466. private _scene;
  3467. id: number;
  3468. soundCollection: Array<Sound>;
  3469. private _isMainTrack;
  3470. private _connectedAnalyser;
  3471. private _options;
  3472. private _isInitialized;
  3473. constructor(scene: Scene, options?: any);
  3474. private _initializeSoundTrackAudioGraph();
  3475. dispose(): void;
  3476. AddSound(sound: Sound): void;
  3477. RemoveSound(sound: Sound): void;
  3478. setVolume(newVolume: number): void;
  3479. switchPanningModelToHRTF(): void;
  3480. switchPanningModelToEqualPower(): void;
  3481. connectToAnalyser(analyser: Analyser): void;
  3482. }
  3483. }
  3484. declare module BABYLON {
  3485. class Animatable {
  3486. target: any;
  3487. fromFrame: number;
  3488. toFrame: number;
  3489. loopAnimation: boolean;
  3490. onAnimationEnd: (() => void) | null | undefined;
  3491. private _localDelayOffset;
  3492. private _pausedDelay;
  3493. private _runtimeAnimations;
  3494. private _paused;
  3495. private _scene;
  3496. private _speedRatio;
  3497. private _weight;
  3498. private _syncRoot;
  3499. animationStarted: boolean;
  3500. /**
  3501. * Gets the root Animatable used to synchronize and normalize animations
  3502. */
  3503. readonly syncRoot: Animatable;
  3504. /**
  3505. * Gets the current frame of the first RuntimeAnimation
  3506. * Used to synchronize Animatables
  3507. */
  3508. readonly masterFrame: number;
  3509. /**
  3510. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3511. */
  3512. weight: number;
  3513. /**
  3514. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3515. */
  3516. speedRatio: number;
  3517. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3518. /**
  3519. * Synchronize and normalize current Animatable with a source Animatable
  3520. * This is useful when using animation weights and when animations are not of the same length
  3521. * @param root defines the root Animatable to synchronize with
  3522. * @returns the current Animatable
  3523. */
  3524. syncWith(root: Animatable): Animatable;
  3525. getAnimations(): RuntimeAnimation[];
  3526. appendAnimations(target: any, animations: Animation[]): void;
  3527. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3528. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3529. reset(): void;
  3530. enableBlending(blendingSpeed: number): void;
  3531. disableBlending(): void;
  3532. goToFrame(frame: number): void;
  3533. pause(): void;
  3534. restart(): void;
  3535. stop(animationName?: string): void;
  3536. }
  3537. }
  3538. declare module BABYLON {
  3539. /**
  3540. * Represents the range of an animation
  3541. */
  3542. class AnimationRange {
  3543. /**The name of the animation range**/
  3544. name: string;
  3545. /**The starting frame of the animation */
  3546. from: number;
  3547. /**The ending frame of the animation*/
  3548. to: number;
  3549. /**
  3550. * Initializes the range of an animation
  3551. * @param name The name of the animation range
  3552. * @param from The starting frame of the animation
  3553. * @param to The ending frame of the animation
  3554. */
  3555. constructor(
  3556. /**The name of the animation range**/
  3557. name: string,
  3558. /**The starting frame of the animation */
  3559. from: number,
  3560. /**The ending frame of the animation*/
  3561. to: number);
  3562. /**
  3563. * Makes a copy of the animation range
  3564. * @returns A copy of the animation range
  3565. */
  3566. clone(): AnimationRange;
  3567. }
  3568. /**
  3569. * Composed of a frame, and an action function
  3570. */
  3571. class AnimationEvent {
  3572. /** The frame for which the event is triggered **/
  3573. frame: number;
  3574. /** The event to perform when triggered **/
  3575. action: () => void;
  3576. /** Specifies if the event should be triggered only once**/
  3577. onlyOnce: boolean | undefined;
  3578. /**
  3579. * Specifies if the animation event is done
  3580. */
  3581. isDone: boolean;
  3582. /**
  3583. * Initializes the animation event
  3584. * @param frame The frame for which the event is triggered
  3585. * @param action The event to perform when triggered
  3586. * @param onlyOnce Specifies if the event should be triggered only once
  3587. */
  3588. constructor(
  3589. /** The frame for which the event is triggered **/
  3590. frame: number,
  3591. /** The event to perform when triggered **/
  3592. action: () => void,
  3593. /** Specifies if the event should be triggered only once**/
  3594. onlyOnce?: boolean | undefined);
  3595. }
  3596. /**
  3597. * A cursor which tracks a point on a path
  3598. */
  3599. class PathCursor {
  3600. private path;
  3601. /**
  3602. * Stores path cursor callbacks for when an onchange event is triggered
  3603. */
  3604. private _onchange;
  3605. /**
  3606. * The value of the path cursor
  3607. */
  3608. value: number;
  3609. /**
  3610. * The animation array of the path cursor
  3611. */
  3612. animations: Animation[];
  3613. /**
  3614. * Initializes the path cursor
  3615. * @param path The path to track
  3616. */
  3617. constructor(path: Path2);
  3618. /**
  3619. * Gets the cursor point on the path
  3620. * @returns A point on the path cursor at the cursor location
  3621. */
  3622. getPoint(): Vector3;
  3623. /**
  3624. * Moves the cursor ahead by the step amount
  3625. * @param step The amount to move the cursor forward
  3626. * @returns This path cursor
  3627. */
  3628. moveAhead(step?: number): PathCursor;
  3629. /**
  3630. * Moves the cursor behind by the step amount
  3631. * @param step The amount to move the cursor back
  3632. * @returns This path cursor
  3633. */
  3634. moveBack(step?: number): PathCursor;
  3635. /**
  3636. * Moves the cursor by the step amount
  3637. * If the step amount is greater than one, an exception is thrown
  3638. * @param step The amount to move the cursor
  3639. * @returns This path cursor
  3640. */
  3641. move(step: number): PathCursor;
  3642. /**
  3643. * Ensures that the value is limited between zero and one
  3644. * @returns This path cursor
  3645. */
  3646. private ensureLimits();
  3647. /**
  3648. * Runs onchange callbacks on change (used by the animation engine)
  3649. * @returns This path cursor
  3650. */
  3651. private raiseOnChange();
  3652. /**
  3653. * Executes a function on change
  3654. * @param f A path cursor onchange callback
  3655. * @returns This path cursor
  3656. */
  3657. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3658. }
  3659. /**
  3660. * Defines an interface which represents an animation key frame
  3661. */
  3662. interface IAnimationKey {
  3663. /**
  3664. * Frame of the key frame
  3665. */
  3666. frame: number;
  3667. /**
  3668. * Value at the specifies key frame
  3669. */
  3670. value: any;
  3671. /**
  3672. * The input tangent for the cubic hermite spline
  3673. */
  3674. inTangent?: any;
  3675. /**
  3676. * The output tangent for the cubic hermite spline
  3677. */
  3678. outTangent?: any;
  3679. /**
  3680. * The animation interpolation type
  3681. */
  3682. interpolation?: AnimationKeyInterpolation;
  3683. }
  3684. /**
  3685. * Enum for the animation key frame interpolation type
  3686. */
  3687. enum AnimationKeyInterpolation {
  3688. /**
  3689. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3690. */
  3691. STEP = 1,
  3692. }
  3693. /**
  3694. * Class used to store any kind of animation
  3695. */
  3696. class Animation {
  3697. /**Name of the animation */
  3698. name: string;
  3699. /**Property to animate */
  3700. targetProperty: string;
  3701. /**The frames per second of the animation */
  3702. framePerSecond: number;
  3703. /**The data type of the animation */
  3704. dataType: number;
  3705. /**The loop mode of the animation */
  3706. loopMode: number | undefined;
  3707. /**Specifies if blending should be enabled */
  3708. enableBlending: boolean | undefined;
  3709. /**
  3710. * Use matrix interpolation instead of using direct key value when animating matrices
  3711. */
  3712. static AllowMatricesInterpolation: boolean;
  3713. /**
  3714. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3715. */
  3716. static AllowMatrixDecomposeForInterpolation: boolean;
  3717. /**
  3718. * Stores the key frames of the animation
  3719. */
  3720. private _keys;
  3721. /**
  3722. * Stores the easing function of the animation
  3723. */
  3724. private _easingFunction;
  3725. /**
  3726. * @hidden Internal use only
  3727. */
  3728. /**
  3729. * The set of event that will be linked to this animation
  3730. */
  3731. private _events;
  3732. /**
  3733. * Stores an array of target property paths
  3734. */
  3735. targetPropertyPath: string[];
  3736. /**
  3737. * Stores the blending speed of the animation
  3738. */
  3739. blendingSpeed: number;
  3740. /**
  3741. * Stores the animation ranges for the animation
  3742. */
  3743. private _ranges;
  3744. /**
  3745. * @hidden Internal use
  3746. */
  3747. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3748. /**
  3749. * Sets up an animation
  3750. * @param property The property to animate
  3751. * @param animationType The animation type to apply
  3752. * @param framePerSecond The frames per second of the animation
  3753. * @param easingFunction The easing function used in the animation
  3754. * @returns The created animation
  3755. */
  3756. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3757. /**
  3758. * Create and start an animation on a node
  3759. * @param name defines the name of the global animation that will be run on all nodes
  3760. * @param node defines the root node where the animation will take place
  3761. * @param targetProperty defines property to animate
  3762. * @param framePerSecond defines the number of frame per second yo use
  3763. * @param totalFrame defines the number of frames in total
  3764. * @param from defines the initial value
  3765. * @param to defines the final value
  3766. * @param loopMode defines which loop mode you want to use (off by default)
  3767. * @param easingFunction defines the easing function to use (linear by default)
  3768. * @param onAnimationEnd defines the callback to call when animation end
  3769. * @returns the animatable created for this animation
  3770. */
  3771. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3772. /**
  3773. * Create and start an animation on a node and its descendants
  3774. * @param name defines the name of the global animation that will be run on all nodes
  3775. * @param node defines the root node where the animation will take place
  3776. * @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
  3777. * @param targetProperty defines property to animate
  3778. * @param framePerSecond defines the number of frame per second to use
  3779. * @param totalFrame defines the number of frames in total
  3780. * @param from defines the initial value
  3781. * @param to defines the final value
  3782. * @param loopMode defines which loop mode you want to use (off by default)
  3783. * @param easingFunction defines the easing function to use (linear by default)
  3784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3785. * @returns the list of animatables created for all nodes
  3786. * @example https://www.babylonjs-playground.com/#MH0VLI
  3787. */
  3788. 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[]>;
  3789. /**
  3790. * Creates a new animation, merges it with the existing animations and starts it
  3791. * @param name Name of the animation
  3792. * @param node Node which contains the scene that begins the animations
  3793. * @param targetProperty Specifies which property to animate
  3794. * @param framePerSecond The frames per second of the animation
  3795. * @param totalFrame The total number of frames
  3796. * @param from The frame at the beginning of the animation
  3797. * @param to The frame at the end of the animation
  3798. * @param loopMode Specifies the loop mode of the animation
  3799. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3800. * @param onAnimationEnd Callback to run once the animation is complete
  3801. * @returns Nullable animation
  3802. */
  3803. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3804. /**
  3805. * Transition property of the Camera to the target Value
  3806. * @param property The property to transition
  3807. * @param targetValue The target Value of the property
  3808. * @param host The object where the property to animate belongs
  3809. * @param scene Scene used to run the animation
  3810. * @param frameRate Framerate (in frame/s) to use
  3811. * @param transition The transition type we want to use
  3812. * @param duration The duration of the animation, in milliseconds
  3813. * @param onAnimationEnd Callback trigger at the end of the animation
  3814. * @returns Nullable animation
  3815. */
  3816. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3817. /**
  3818. * Return the array of runtime animations currently using this animation
  3819. */
  3820. readonly runtimeAnimations: RuntimeAnimation[];
  3821. /**
  3822. * Specifies if any of the runtime animations are currently running
  3823. */
  3824. readonly hasRunningRuntimeAnimations: boolean;
  3825. /**
  3826. * Initializes the animation
  3827. * @param name Name of the animation
  3828. * @param targetProperty Property to animate
  3829. * @param framePerSecond The frames per second of the animation
  3830. * @param dataType The data type of the animation
  3831. * @param loopMode The loop mode of the animation
  3832. * @param enableBlendings Specifies if blending should be enabled
  3833. */
  3834. constructor(
  3835. /**Name of the animation */
  3836. name: string,
  3837. /**Property to animate */
  3838. targetProperty: string,
  3839. /**The frames per second of the animation */
  3840. framePerSecond: number,
  3841. /**The data type of the animation */
  3842. dataType: number,
  3843. /**The loop mode of the animation */
  3844. loopMode?: number | undefined,
  3845. /**Specifies if blending should be enabled */
  3846. enableBlending?: boolean | undefined);
  3847. /**
  3848. * Converts the animation to a string
  3849. * @param fullDetails support for multiple levels of logging within scene loading
  3850. * @returns String form of the animation
  3851. */
  3852. toString(fullDetails?: boolean): string;
  3853. /**
  3854. * Add an event to this animation
  3855. * @param event Event to add
  3856. */
  3857. addEvent(event: AnimationEvent): void;
  3858. /**
  3859. * Remove all events found at the given frame
  3860. * @param frame The frame to remove events from
  3861. */
  3862. removeEvents(frame: number): void;
  3863. /**
  3864. * Retrieves all the events from the animation
  3865. * @returns Events from the animation
  3866. */
  3867. getEvents(): AnimationEvent[];
  3868. /**
  3869. * Creates an animation range
  3870. * @param name Name of the animation range
  3871. * @param from Starting frame of the animation range
  3872. * @param to Ending frame of the animation
  3873. */
  3874. createRange(name: string, from: number, to: number): void;
  3875. /**
  3876. * Deletes an animation range by name
  3877. * @param name Name of the animation range to delete
  3878. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3879. */
  3880. deleteRange(name: string, deleteFrames?: boolean): void;
  3881. /**
  3882. * Gets the animation range by name, or null if not defined
  3883. * @param name Name of the animation range
  3884. * @returns Nullable animation range
  3885. */
  3886. getRange(name: string): Nullable<AnimationRange>;
  3887. /**
  3888. * Gets the key frames from the animation
  3889. * @returns The key frames of the animation
  3890. */
  3891. getKeys(): Array<IAnimationKey>;
  3892. /**
  3893. * Gets the highest frame rate of the animation
  3894. * @returns Highest frame rate of the animation
  3895. */
  3896. getHighestFrame(): number;
  3897. /**
  3898. * Gets the easing function of the animation
  3899. * @returns Easing function of the animation
  3900. */
  3901. getEasingFunction(): IEasingFunction;
  3902. /**
  3903. * Sets the easing function of the animation
  3904. * @param easingFunction A custom mathematical formula for animation
  3905. */
  3906. setEasingFunction(easingFunction: EasingFunction): void;
  3907. /**
  3908. * Interpolates a scalar linearly
  3909. * @param startValue Start value of the animation curve
  3910. * @param endValue End value of the animation curve
  3911. * @param gradient Scalar amount to interpolate
  3912. * @returns Interpolated scalar value
  3913. */
  3914. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3915. /**
  3916. * Interpolates a scalar cubically
  3917. * @param startValue Start value of the animation curve
  3918. * @param outTangent End tangent of the animation
  3919. * @param endValue End value of the animation curve
  3920. * @param inTangent Start tangent of the animation curve
  3921. * @param gradient Scalar amount to interpolate
  3922. * @returns Interpolated scalar value
  3923. */
  3924. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3925. /**
  3926. * Interpolates a quaternion using a spherical linear interpolation
  3927. * @param startValue Start value of the animation curve
  3928. * @param endValue End value of the animation curve
  3929. * @param gradient Scalar amount to interpolate
  3930. * @returns Interpolated quaternion value
  3931. */
  3932. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3933. /**
  3934. * Interpolates a quaternion cubically
  3935. * @param startValue Start value of the animation curve
  3936. * @param outTangent End tangent of the animation curve
  3937. * @param endValue End value of the animation curve
  3938. * @param inTangent Start tangent of the animation curve
  3939. * @param gradient Scalar amount to interpolate
  3940. * @returns Interpolated quaternion value
  3941. */
  3942. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3943. /**
  3944. * Interpolates a Vector3 linearl
  3945. * @param startValue Start value of the animation curve
  3946. * @param endValue End value of the animation curve
  3947. * @param gradient Scalar amount to interpolate
  3948. * @returns Interpolated scalar value
  3949. */
  3950. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3951. /**
  3952. * Interpolates a Vector3 cubically
  3953. * @param startValue Start value of the animation curve
  3954. * @param outTangent End tangent of the animation
  3955. * @param endValue End value of the animation curve
  3956. * @param inTangent Start tangent of the animation curve
  3957. * @param gradient Scalar amount to interpolate
  3958. * @returns InterpolatedVector3 value
  3959. */
  3960. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3961. /**
  3962. * Interpolates a Vector2 linearly
  3963. * @param startValue Start value of the animation curve
  3964. * @param endValue End value of the animation curve
  3965. * @param gradient Scalar amount to interpolate
  3966. * @returns Interpolated Vector2 value
  3967. */
  3968. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3969. /**
  3970. * Interpolates a Vector2 cubically
  3971. * @param startValue Start value of the animation curve
  3972. * @param outTangent End tangent of the animation
  3973. * @param endValue End value of the animation curve
  3974. * @param inTangent Start tangent of the animation curve
  3975. * @param gradient Scalar amount to interpolate
  3976. * @returns Interpolated Vector2 value
  3977. */
  3978. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3979. /**
  3980. * Interpolates a size linearly
  3981. * @param startValue Start value of the animation curve
  3982. * @param endValue End value of the animation curve
  3983. * @param gradient Scalar amount to interpolate
  3984. * @returns Interpolated Size value
  3985. */
  3986. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3987. /**
  3988. * Interpolates a Color3 linearly
  3989. * @param startValue Start value of the animation curve
  3990. * @param endValue End value of the animation curve
  3991. * @param gradient Scalar amount to interpolate
  3992. * @returns Interpolated Color3 value
  3993. */
  3994. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3995. /**
  3996. * @hidden Internal use only
  3997. */
  3998. /**
  3999. * @hidden Internal use only
  4000. */
  4001. /**
  4002. * Defines the function to use to interpolate matrices
  4003. * @param startValue defines the start matrix
  4004. * @param endValue defines the end matrix
  4005. * @param gradient defines the gradient between both matrices
  4006. * @param result defines an optional target matrix where to store the interpolation
  4007. * @returns the interpolated matrix
  4008. */
  4009. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4010. /**
  4011. * Makes a copy of the animation
  4012. * @returns Cloned animation
  4013. */
  4014. clone(): Animation;
  4015. /**
  4016. * Sets the key frames of the animation
  4017. * @param values The animation key frames to set
  4018. */
  4019. setKeys(values: Array<IAnimationKey>): void;
  4020. /**
  4021. * Serializes the animation to an object
  4022. * @returns Serialized object
  4023. */
  4024. serialize(): any;
  4025. /**
  4026. * Float animation type
  4027. */
  4028. private static _ANIMATIONTYPE_FLOAT;
  4029. /**
  4030. * Vector3 animation type
  4031. */
  4032. private static _ANIMATIONTYPE_VECTOR3;
  4033. /**
  4034. * Quaternion animation type
  4035. */
  4036. private static _ANIMATIONTYPE_QUATERNION;
  4037. /**
  4038. * Matrix animation type
  4039. */
  4040. private static _ANIMATIONTYPE_MATRIX;
  4041. /**
  4042. * Color3 animation type
  4043. */
  4044. private static _ANIMATIONTYPE_COLOR3;
  4045. /**
  4046. * Vector2 animation type
  4047. */
  4048. private static _ANIMATIONTYPE_VECTOR2;
  4049. /**
  4050. * Size animation type
  4051. */
  4052. private static _ANIMATIONTYPE_SIZE;
  4053. /**
  4054. * Relative Loop Mode
  4055. */
  4056. private static _ANIMATIONLOOPMODE_RELATIVE;
  4057. /**
  4058. * Cycle Loop Mode
  4059. */
  4060. private static _ANIMATIONLOOPMODE_CYCLE;
  4061. /**
  4062. * Constant Loop Mode
  4063. */
  4064. private static _ANIMATIONLOOPMODE_CONSTANT;
  4065. /**
  4066. * Get the float animation type
  4067. */
  4068. static readonly ANIMATIONTYPE_FLOAT: number;
  4069. /**
  4070. * Get the Vector3 animation type
  4071. */
  4072. static readonly ANIMATIONTYPE_VECTOR3: number;
  4073. /**
  4074. * Get the Vectpr2 animation type
  4075. */
  4076. static readonly ANIMATIONTYPE_VECTOR2: number;
  4077. /**
  4078. * Get the Size animation type
  4079. */
  4080. static readonly ANIMATIONTYPE_SIZE: number;
  4081. /**
  4082. * Get the Quaternion animation type
  4083. */
  4084. static readonly ANIMATIONTYPE_QUATERNION: number;
  4085. /**
  4086. * Get the Matrix animation type
  4087. */
  4088. static readonly ANIMATIONTYPE_MATRIX: number;
  4089. /**
  4090. * Get the Color3 animation type
  4091. */
  4092. static readonly ANIMATIONTYPE_COLOR3: number;
  4093. /**
  4094. * Get the Relative Loop Mode
  4095. */
  4096. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4097. /**
  4098. * Get the Cycle Loop Mode
  4099. */
  4100. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4101. /**
  4102. * Get the Constant Loop Mode
  4103. */
  4104. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4105. /**
  4106. * Parses an animation object and creates an animation
  4107. * @param parsedAnimation Parsed animation object
  4108. * @returns Animation object
  4109. */
  4110. static Parse(parsedAnimation: any): Animation;
  4111. /**
  4112. * Appends the serialized animations from the source animations
  4113. * @param source Source containing the animations
  4114. * @param destination Target to store the animations
  4115. */
  4116. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4117. }
  4118. }
  4119. declare module BABYLON {
  4120. /**
  4121. * This class defines the direct association between an animation and a target
  4122. */
  4123. class TargetedAnimation {
  4124. animation: Animation;
  4125. target: any;
  4126. }
  4127. /**
  4128. * Use this class to create coordinated animations on multiple targets
  4129. */
  4130. class AnimationGroup implements IDisposable {
  4131. name: string;
  4132. private _scene;
  4133. private _targetedAnimations;
  4134. private _animatables;
  4135. private _from;
  4136. private _to;
  4137. private _isStarted;
  4138. private _speedRatio;
  4139. onAnimationEndObservable: Observable<TargetedAnimation>;
  4140. /**
  4141. * Gets the first frame
  4142. */
  4143. readonly from: number;
  4144. /**
  4145. * Gets the last frame
  4146. */
  4147. readonly to: number;
  4148. /**
  4149. * Define if the animations are started
  4150. */
  4151. readonly isStarted: boolean;
  4152. /**
  4153. * Gets or sets the speed ratio to use for all animations
  4154. */
  4155. /**
  4156. * Gets or sets the speed ratio to use for all animations
  4157. */
  4158. speedRatio: number;
  4159. /**
  4160. * Gets the targeted animations for this animation group
  4161. */
  4162. readonly targetedAnimations: Array<TargetedAnimation>;
  4163. /**
  4164. * returning the list of animatables controlled by this animation group.
  4165. */
  4166. readonly animatables: Array<Animatable>;
  4167. constructor(name: string, scene?: Nullable<Scene>);
  4168. /**
  4169. * Add an animation (with its target) in the group
  4170. * @param animation defines the animation we want to add
  4171. * @param target defines the target of the animation
  4172. * @returns the {BABYLON.TargetedAnimation} object
  4173. */
  4174. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4175. /**
  4176. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4177. * It can add constant keys at begin or end
  4178. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  4179. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  4180. */
  4181. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  4182. /**
  4183. * Start all animations on given targets
  4184. * @param loop defines if animations must loop
  4185. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4186. * @param from defines the from key (optional)
  4187. * @param to defines the to key (optional)
  4188. * @returns the current animation group
  4189. */
  4190. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4191. /**
  4192. * Pause all animations
  4193. */
  4194. pause(): AnimationGroup;
  4195. /**
  4196. * Play all animations to initial state
  4197. * This function will start() the animations if they were not started or will restart() them if they were paused
  4198. * @param loop defines if animations must loop
  4199. */
  4200. play(loop?: boolean): AnimationGroup;
  4201. /**
  4202. * Reset all animations to initial state
  4203. */
  4204. reset(): AnimationGroup;
  4205. /**
  4206. * Restart animations from key 0
  4207. */
  4208. restart(): AnimationGroup;
  4209. /**
  4210. * Stop all animations
  4211. */
  4212. stop(): AnimationGroup;
  4213. /**
  4214. * Set animation weight for all animatables
  4215. * @param weight defines the weight to use
  4216. * @return the animationGroup
  4217. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4218. */
  4219. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4220. /**
  4221. * Synchronize and normalize all animatables with a source animatable
  4222. * @param root defines the root animatable to synchronize with
  4223. * @return the animationGroup
  4224. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4225. */
  4226. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4227. /**
  4228. * Goes to a specific frame in this animation group
  4229. * @param frame the frame number to go to
  4230. * @return the animationGroup
  4231. */
  4232. goToFrame(frame: number): AnimationGroup;
  4233. /**
  4234. * Dispose all associated resources
  4235. */
  4236. dispose(): void;
  4237. }
  4238. }
  4239. declare module BABYLON {
  4240. /**
  4241. * Class used to override all child animations of a given target
  4242. */
  4243. class AnimationPropertiesOverride {
  4244. /**
  4245. * Gets or sets a value indicating if animation blending must be used
  4246. */
  4247. enableBlending: boolean;
  4248. /**
  4249. * Gets or sets the blending speed to use when enableBlending is true
  4250. */
  4251. blendingSpeed: number;
  4252. /**
  4253. * Gets or sets the default loop mode to use
  4254. */
  4255. loopMode: number;
  4256. }
  4257. }
  4258. declare module BABYLON {
  4259. interface IEasingFunction {
  4260. ease(gradient: number): number;
  4261. }
  4262. class EasingFunction implements IEasingFunction {
  4263. private static _EASINGMODE_EASEIN;
  4264. private static _EASINGMODE_EASEOUT;
  4265. private static _EASINGMODE_EASEINOUT;
  4266. static readonly EASINGMODE_EASEIN: number;
  4267. static readonly EASINGMODE_EASEOUT: number;
  4268. static readonly EASINGMODE_EASEINOUT: number;
  4269. private _easingMode;
  4270. setEasingMode(easingMode: number): void;
  4271. getEasingMode(): number;
  4272. easeInCore(gradient: number): number;
  4273. ease(gradient: number): number;
  4274. }
  4275. class CircleEase extends EasingFunction implements IEasingFunction {
  4276. easeInCore(gradient: number): number;
  4277. }
  4278. class BackEase extends EasingFunction implements IEasingFunction {
  4279. amplitude: number;
  4280. constructor(amplitude?: number);
  4281. easeInCore(gradient: number): number;
  4282. }
  4283. class BounceEase extends EasingFunction implements IEasingFunction {
  4284. bounces: number;
  4285. bounciness: number;
  4286. constructor(bounces?: number, bounciness?: number);
  4287. easeInCore(gradient: number): number;
  4288. }
  4289. class CubicEase extends EasingFunction implements IEasingFunction {
  4290. easeInCore(gradient: number): number;
  4291. }
  4292. class ElasticEase extends EasingFunction implements IEasingFunction {
  4293. oscillations: number;
  4294. springiness: number;
  4295. constructor(oscillations?: number, springiness?: number);
  4296. easeInCore(gradient: number): number;
  4297. }
  4298. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4299. exponent: number;
  4300. constructor(exponent?: number);
  4301. easeInCore(gradient: number): number;
  4302. }
  4303. class PowerEase extends EasingFunction implements IEasingFunction {
  4304. power: number;
  4305. constructor(power?: number);
  4306. easeInCore(gradient: number): number;
  4307. }
  4308. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4309. easeInCore(gradient: number): number;
  4310. }
  4311. class QuarticEase extends EasingFunction implements IEasingFunction {
  4312. easeInCore(gradient: number): number;
  4313. }
  4314. class QuinticEase extends EasingFunction implements IEasingFunction {
  4315. easeInCore(gradient: number): number;
  4316. }
  4317. class SineEase extends EasingFunction implements IEasingFunction {
  4318. easeInCore(gradient: number): number;
  4319. }
  4320. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4321. x1: number;
  4322. y1: number;
  4323. x2: number;
  4324. y2: number;
  4325. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4326. easeInCore(gradient: number): number;
  4327. }
  4328. }
  4329. declare module BABYLON {
  4330. /**
  4331. * Defines a runtime animation
  4332. */
  4333. class RuntimeAnimation {
  4334. /**
  4335. * The current frame of the runtime animation
  4336. */
  4337. private _currentFrame;
  4338. /**
  4339. * The animation used by the runtime animation
  4340. */
  4341. private _animation;
  4342. /**
  4343. * The target of the runtime animation
  4344. */
  4345. private _target;
  4346. /**
  4347. * The initiating animatable
  4348. */
  4349. private _host;
  4350. /**
  4351. * The original value of the runtime animation
  4352. */
  4353. private _originalValue;
  4354. /**
  4355. * The original blend value of the runtime animation
  4356. */
  4357. private _originalBlendValue;
  4358. /**
  4359. * The offsets cache of the runtime animation
  4360. */
  4361. private _offsetsCache;
  4362. /**
  4363. * The high limits cache of the runtime animation
  4364. */
  4365. private _highLimitsCache;
  4366. /**
  4367. * Specifies if the runtime animation has been stopped
  4368. */
  4369. private _stopped;
  4370. /**
  4371. * The blending factor of the runtime animation
  4372. */
  4373. private _blendingFactor;
  4374. /**
  4375. * The BabylonJS scene
  4376. */
  4377. private _scene;
  4378. /**
  4379. * The current value of the runtime animation
  4380. */
  4381. private _currentValue;
  4382. /** @hidden */
  4383. /**
  4384. * The active target of the runtime animation
  4385. */
  4386. private _activeTarget;
  4387. /**
  4388. * The target path of the runtime animation
  4389. */
  4390. private _targetPath;
  4391. /**
  4392. * The weight of the runtime animation
  4393. */
  4394. private _weight;
  4395. /**
  4396. * The ratio offset of the runtime animation
  4397. */
  4398. private _ratioOffset;
  4399. /**
  4400. * The previous delay of the runtime animation
  4401. */
  4402. private _previousDelay;
  4403. /**
  4404. * The previous ratio of the runtime animation
  4405. */
  4406. private _previousRatio;
  4407. /**
  4408. * Gets the current frame of the runtime animation
  4409. */
  4410. readonly currentFrame: number;
  4411. /**
  4412. * Gets the weight of the runtime animation
  4413. */
  4414. readonly weight: number;
  4415. /**
  4416. * Gets the original value of the runtime animation
  4417. */
  4418. readonly originalValue: any;
  4419. /**
  4420. * Gets the current value of the runtime animation
  4421. */
  4422. readonly currentValue: any;
  4423. /**
  4424. * Gets the target path of the runtime animation
  4425. */
  4426. readonly targetPath: string;
  4427. /**
  4428. * Gets the actual target of the runtime animation
  4429. */
  4430. readonly target: any;
  4431. /**
  4432. * Create a new RuntimeAnimation object
  4433. * @param target defines the target of the animation
  4434. * @param animation defines the source animation object
  4435. * @param scene defines the hosting scene
  4436. * @param host defines the initiating Animatable
  4437. */
  4438. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4439. /**
  4440. * Gets the animation from the runtime animation
  4441. */
  4442. readonly animation: Animation;
  4443. /**
  4444. * Resets the runtime animation to the beginning
  4445. * @param restoreOriginal defines whether to restore the target property to the original value
  4446. */
  4447. reset(restoreOriginal?: boolean): void;
  4448. /**
  4449. * Specifies if the runtime animation is stopped
  4450. * @returns Boolean specifying if the runtime animation is stopped
  4451. */
  4452. isStopped(): boolean;
  4453. /**
  4454. * Disposes of the runtime animation
  4455. */
  4456. dispose(): void;
  4457. /**
  4458. * Interpolates the animation from the current frame
  4459. * @param currentFrame The frame to interpolate the animation to
  4460. * @param repeatCount The number of times that the animation should loop
  4461. * @param loopMode The type of looping mode to use
  4462. * @param offsetValue Animation offset value
  4463. * @param highLimitValue The high limit value
  4464. * @returns The interpolated value
  4465. */
  4466. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4467. /**
  4468. * Apply the interpolated value to the target
  4469. * @param currentValue defines the value computed by the animation
  4470. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4471. */
  4472. setValue(currentValue: any, weight?: number): void;
  4473. private _setValue(target, currentValue, weight);
  4474. /**
  4475. * Gets the loop pmode of the runtime animation
  4476. * @returns Loop Mode
  4477. */
  4478. private _getCorrectLoopMode();
  4479. /**
  4480. * Move the current animation to a given frame
  4481. * @param frame defines the frame to move to
  4482. */
  4483. goToFrame(frame: number): void;
  4484. /**
  4485. * @hidden Internal use only
  4486. */
  4487. /**
  4488. * Execute the current animation
  4489. * @param delay defines the delay to add to the current frame
  4490. * @param from defines the lower bound of the animation range
  4491. * @param to defines the upper bound of the animation range
  4492. * @param loop defines if the current animation must loop
  4493. * @param speedRatio defines the current speed ratio
  4494. * @param weight defines the weight of the animation (default is -1 so no weight)
  4495. * @returns a boolean indicating if the animation has ended
  4496. */
  4497. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4498. }
  4499. }
  4500. declare module BABYLON {
  4501. interface Behavior<T extends Node> {
  4502. name: string;
  4503. init(): void;
  4504. attach(node: T): void;
  4505. detach(): void;
  4506. }
  4507. }
  4508. declare module BABYLON {
  4509. /**
  4510. * Class used to store bone information
  4511. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4512. */
  4513. class Bone extends Node {
  4514. /**
  4515. * defines the bone name
  4516. */
  4517. name: string;
  4518. private static _tmpVecs;
  4519. private static _tmpQuat;
  4520. private static _tmpMats;
  4521. /**
  4522. * Gets the list of child bones
  4523. */
  4524. children: Bone[];
  4525. /** Gets the animations associated with this bone */
  4526. animations: Animation[];
  4527. /**
  4528. * Gets or sets bone length
  4529. */
  4530. length: number;
  4531. /**
  4532. * @hidden Internal only
  4533. * Set this value to map this bone to a different index in the transform matrices
  4534. * Set this value to -1 to exclude the bone from the transform matrices
  4535. */
  4536. private _skeleton;
  4537. private _localMatrix;
  4538. private _restPose;
  4539. private _baseMatrix;
  4540. private _absoluteTransform;
  4541. private _invertedAbsoluteTransform;
  4542. private _parent;
  4543. private _scalingDeterminant;
  4544. private _worldTransform;
  4545. private _localScaling;
  4546. private _localRotation;
  4547. private _localPosition;
  4548. private _needToDecompose;
  4549. private _needToCompose;
  4550. /** @hidden */
  4551. /** @hidden */
  4552. /**
  4553. * Create a new bone
  4554. * @param name defines the bone name
  4555. * @param skeleton defines the parent skeleton
  4556. * @param parentBone defines the parent (can be null if the bone is the root)
  4557. * @param localMatrix defines the local matrix
  4558. * @param restPose defines the rest pose matrix
  4559. * @param baseMatrix defines the base matrix
  4560. * @param index defines index of the bone in the hiearchy
  4561. */
  4562. constructor(
  4563. /**
  4564. * defines the bone name
  4565. */
  4566. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4567. /**
  4568. * Gets the parent skeleton
  4569. * @returns a skeleton
  4570. */
  4571. getSkeleton(): Skeleton;
  4572. /**
  4573. * Gets parent bone
  4574. * @returns a bone or null if the bone is the root of the bone hierarchy
  4575. */
  4576. getParent(): Nullable<Bone>;
  4577. /**
  4578. * Sets the parent bone
  4579. * @param parent defines the parent (can be null if the bone is the root)
  4580. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4581. */
  4582. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4583. /**
  4584. * Gets the local matrix
  4585. * @returns a matrix
  4586. */
  4587. getLocalMatrix(): Matrix;
  4588. /**
  4589. * Gets the base matrix (initial matrix which remains unchanged)
  4590. * @returns a matrix
  4591. */
  4592. getBaseMatrix(): Matrix;
  4593. /**
  4594. * Gets the rest pose matrix
  4595. * @returns a matrix
  4596. */
  4597. getRestPose(): Matrix;
  4598. /**
  4599. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4600. */
  4601. getWorldMatrix(): Matrix;
  4602. /**
  4603. * Sets the local matrix to rest pose matrix
  4604. */
  4605. returnToRest(): void;
  4606. /**
  4607. * Gets the inverse of the absolute transform matrix.
  4608. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4609. * @returns a matrix
  4610. */
  4611. getInvertedAbsoluteTransform(): Matrix;
  4612. /**
  4613. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4614. * @returns a matrix
  4615. */
  4616. getAbsoluteTransform(): Matrix;
  4617. /** Gets or sets current position (in local space) */
  4618. position: Vector3;
  4619. /** Gets or sets current rotation (in local space) */
  4620. rotation: Vector3;
  4621. /** Gets or sets current rotation quaternion (in local space) */
  4622. rotationQuaternion: Quaternion;
  4623. /** Gets or sets current scaling (in local space) */
  4624. scaling: Vector3;
  4625. /**
  4626. * Gets the animation properties override
  4627. */
  4628. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4629. private _decompose();
  4630. private _compose();
  4631. /**
  4632. * Update the base and local matrices
  4633. * @param matrix defines the new base or local matrix
  4634. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4635. * @param updateLocalMatrix defines if the local matrix should be updated
  4636. */
  4637. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4638. /** @hidden */
  4639. /**
  4640. * Flag the bone as dirty (Forcing it to update everything)
  4641. */
  4642. markAsDirty(): void;
  4643. private _markAsDirtyAndCompose();
  4644. private _markAsDirtyAndDecompose();
  4645. /**
  4646. * Copy an animation range from another bone
  4647. * @param source defines the source bone
  4648. * @param rangeName defines the range name to copy
  4649. * @param frameOffset defines the frame offset
  4650. * @param rescaleAsRequired defines if rescaling must be applied if required
  4651. * @param skelDimensionsRatio defines the scaling ratio
  4652. * @returns true if operation was successful
  4653. */
  4654. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4655. /**
  4656. * Translate the bone in local or world space
  4657. * @param vec The amount to translate the bone
  4658. * @param space The space that the translation is in
  4659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4660. */
  4661. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4662. /**
  4663. * Set the postion of the bone in local or world space
  4664. * @param position The position to set the bone
  4665. * @param space The space that the position is in
  4666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4667. */
  4668. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4669. /**
  4670. * Set the absolute position of the bone (world space)
  4671. * @param position The position to set the bone
  4672. * @param mesh The mesh that this bone is attached to
  4673. */
  4674. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4675. /**
  4676. * Scale the bone on the x, y and z axes (in local space)
  4677. * @param x The amount to scale the bone on the x axis
  4678. * @param y The amount to scale the bone on the y axis
  4679. * @param z The amount to scale the bone on the z axis
  4680. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4681. */
  4682. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4683. /**
  4684. * Set the bone scaling in local space
  4685. * @param scale defines the scaling vector
  4686. */
  4687. setScale(scale: Vector3): void;
  4688. /**
  4689. * Gets the current scaling in local space
  4690. * @returns the current scaling vector
  4691. */
  4692. getScale(): Vector3;
  4693. /**
  4694. * Gets the current scaling in local space and stores it in a target vector
  4695. * @param result defines the target vector
  4696. */
  4697. getScaleToRef(result: Vector3): void;
  4698. /**
  4699. * Set the yaw, pitch, and roll of the bone in local or world space
  4700. * @param yaw The rotation of the bone on the y axis
  4701. * @param pitch The rotation of the bone on the x axis
  4702. * @param roll The rotation of the bone on the z axis
  4703. * @param space The space that the axes of rotation are in
  4704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4705. */
  4706. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4707. /**
  4708. * Add a rotation to the bone on an axis in local or world space
  4709. * @param axis The axis to rotate the bone on
  4710. * @param amount The amount to rotate the bone
  4711. * @param space The space that the axis is in
  4712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4713. */
  4714. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4715. /**
  4716. * Set the rotation of the bone to a particular axis angle in local or world space
  4717. * @param axis The axis to rotate the bone on
  4718. * @param angle The angle that the bone should be rotated to
  4719. * @param space The space that the axis is in
  4720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4721. */
  4722. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4723. /**
  4724. * Set the euler rotation of the bone in local of world space
  4725. * @param rotation The euler rotation that the bone should be set to
  4726. * @param space The space that the rotation is in
  4727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4728. */
  4729. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4730. /**
  4731. * Set the quaternion rotation of the bone in local of world space
  4732. * @param quat The quaternion rotation that the bone should be set to
  4733. * @param space The space that the rotation is in
  4734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4735. */
  4736. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4737. /**
  4738. * Set the rotation matrix of the bone in local of world space
  4739. * @param rotMat The rotation matrix that the bone should be set to
  4740. * @param space The space that the rotation is in
  4741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4742. */
  4743. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4744. private _rotateWithMatrix(rmat, space?, mesh?);
  4745. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4746. /**
  4747. * Get the position of the bone in local or world space
  4748. * @param space The space that the returned position is in
  4749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4750. * @returns The position of the bone
  4751. */
  4752. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4753. /**
  4754. * Copy the position of the bone to a vector3 in local or world space
  4755. * @param space The space that the returned position is in
  4756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4757. * @param result The vector3 to copy the position to
  4758. */
  4759. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4760. /**
  4761. * Get the absolute position of the bone (world space)
  4762. * @param mesh The mesh that this bone is attached to
  4763. * @returns The absolute position of the bone
  4764. */
  4765. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4766. /**
  4767. * Copy the absolute position of the bone (world space) to the result param
  4768. * @param mesh The mesh that this bone is attached to
  4769. * @param result The vector3 to copy the absolute position to
  4770. */
  4771. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4772. /**
  4773. * Compute the absolute transforms of this bone and its children
  4774. */
  4775. computeAbsoluteTransforms(): void;
  4776. /**
  4777. * Get the world direction from an axis that is in the local space of the bone
  4778. * @param localAxis The local direction that is used to compute the world direction
  4779. * @param mesh The mesh that this bone is attached to
  4780. * @returns The world direction
  4781. */
  4782. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4783. /**
  4784. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4785. * @param localAxis The local direction that is used to compute the world direction
  4786. * @param mesh The mesh that this bone is attached to
  4787. * @param result The vector3 that the world direction will be copied to
  4788. */
  4789. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4790. /**
  4791. * Get the euler rotation of the bone in local or world space
  4792. * @param space The space that the rotation should be in
  4793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4794. * @returns The euler rotation
  4795. */
  4796. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4797. /**
  4798. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4799. * @param space The space that the rotation should be in
  4800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4801. * @param result The vector3 that the rotation should be copied to
  4802. */
  4803. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4804. /**
  4805. * Get the quaternion rotation of the bone in either local or world space
  4806. * @param space The space that the rotation should be in
  4807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4808. * @returns The quaternion rotation
  4809. */
  4810. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4811. /**
  4812. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4813. * @param space The space that the rotation should be in
  4814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4815. * @param result The quaternion that the rotation should be copied to
  4816. */
  4817. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4818. /**
  4819. * Get the rotation matrix of the bone in local or world space
  4820. * @param space The space that the rotation should be in
  4821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4822. * @returns The rotation matrix
  4823. */
  4824. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4825. /**
  4826. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4827. * @param space The space that the rotation should be in
  4828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4829. * @param result The quaternion that the rotation should be copied to
  4830. */
  4831. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4832. /**
  4833. * Get the world position of a point that is in the local space of the bone
  4834. * @param position The local position
  4835. * @param mesh The mesh that this bone is attached to
  4836. * @returns The world position
  4837. */
  4838. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4839. /**
  4840. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4841. * @param position The local position
  4842. * @param mesh The mesh that this bone is attached to
  4843. * @param result The vector3 that the world position should be copied to
  4844. */
  4845. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4846. /**
  4847. * Get the local position of a point that is in world space
  4848. * @param position The world position
  4849. * @param mesh The mesh that this bone is attached to
  4850. * @returns The local position
  4851. */
  4852. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4853. /**
  4854. * Get the local position of a point that is in world space and copy it to the result param
  4855. * @param position The world position
  4856. * @param mesh The mesh that this bone is attached to
  4857. * @param result The vector3 that the local position should be copied to
  4858. */
  4859. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4860. }
  4861. }
  4862. declare module BABYLON {
  4863. /**
  4864. * Class used to apply inverse kinematics to bones
  4865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4866. */
  4867. class BoneIKController {
  4868. private static _tmpVecs;
  4869. private static _tmpQuat;
  4870. private static _tmpMats;
  4871. /**
  4872. * Gets or sets the target mesh
  4873. */
  4874. targetMesh: AbstractMesh;
  4875. /** Gets or sets the mesh used as pole */
  4876. poleTargetMesh: AbstractMesh;
  4877. /**
  4878. * Gets or sets the bone used as pole
  4879. */
  4880. poleTargetBone: Nullable<Bone>;
  4881. /**
  4882. * Gets or sets the target position
  4883. */
  4884. targetPosition: Vector3;
  4885. /**
  4886. * Gets or sets the pole target position
  4887. */
  4888. poleTargetPosition: Vector3;
  4889. /**
  4890. * Gets or sets the pole target local offset
  4891. */
  4892. poleTargetLocalOffset: Vector3;
  4893. /**
  4894. * Gets or sets the pole angle
  4895. */
  4896. poleAngle: number;
  4897. /**
  4898. * Gets or sets the mesh associated with the controller
  4899. */
  4900. mesh: AbstractMesh;
  4901. /**
  4902. * 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)
  4903. */
  4904. slerpAmount: number;
  4905. private _bone1Quat;
  4906. private _bone1Mat;
  4907. private _bone2Ang;
  4908. private _bone1;
  4909. private _bone2;
  4910. private _bone1Length;
  4911. private _bone2Length;
  4912. private _maxAngle;
  4913. private _maxReach;
  4914. private _rightHandedSystem;
  4915. private _bendAxis;
  4916. private _slerping;
  4917. private _adjustRoll;
  4918. /**
  4919. * Gets or sets maximum allowed angle
  4920. */
  4921. maxAngle: number;
  4922. /**
  4923. * Creates a new BoneIKController
  4924. * @param mesh defines the mesh to control
  4925. * @param bone defines the bone to control
  4926. * @param options defines options to set up the controller
  4927. */
  4928. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4929. targetMesh?: AbstractMesh;
  4930. poleTargetMesh?: AbstractMesh;
  4931. poleTargetBone?: Bone;
  4932. poleTargetLocalOffset?: Vector3;
  4933. poleAngle?: number;
  4934. bendAxis?: Vector3;
  4935. maxAngle?: number;
  4936. slerpAmount?: number;
  4937. });
  4938. private _setMaxAngle(ang);
  4939. /**
  4940. * Force the controller to update the bones
  4941. */
  4942. update(): void;
  4943. }
  4944. }
  4945. declare module BABYLON {
  4946. /**
  4947. * Class used to make a bone look toward a point in space
  4948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  4949. */
  4950. class BoneLookController {
  4951. private static _tmpVecs;
  4952. private static _tmpQuat;
  4953. private static _tmpMats;
  4954. /**
  4955. * The target Vector3 that the bone will look at
  4956. */
  4957. target: Vector3;
  4958. /**
  4959. * The mesh that the bone is attached to
  4960. */
  4961. mesh: AbstractMesh;
  4962. /**
  4963. * The bone that will be looking to the target
  4964. */
  4965. bone: Bone;
  4966. /**
  4967. * The up axis of the coordinate system that is used when the bone is rotated
  4968. */
  4969. upAxis: Vector3;
  4970. /**
  4971. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  4972. */
  4973. upAxisSpace: Space;
  4974. /**
  4975. * Used to make an adjustment to the yaw of the bone
  4976. */
  4977. adjustYaw: number;
  4978. /**
  4979. * Used to make an adjustment to the pitch of the bone
  4980. */
  4981. adjustPitch: number;
  4982. /**
  4983. * Used to make an adjustment to the roll of the bone
  4984. */
  4985. adjustRoll: number;
  4986. /**
  4987. * 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)
  4988. */
  4989. slerpAmount: number;
  4990. private _minYaw;
  4991. private _maxYaw;
  4992. private _minPitch;
  4993. private _maxPitch;
  4994. private _minYawSin;
  4995. private _minYawCos;
  4996. private _maxYawSin;
  4997. private _maxYawCos;
  4998. private _midYawConstraint;
  4999. private _minPitchTan;
  5000. private _maxPitchTan;
  5001. private _boneQuat;
  5002. private _slerping;
  5003. private _transformYawPitch;
  5004. private _transformYawPitchInv;
  5005. private _firstFrameSkipped;
  5006. private _yawRange;
  5007. private _fowardAxis;
  5008. /**
  5009. * Gets or sets the minimum yaw angle that the bone can look to
  5010. */
  5011. minYaw: number;
  5012. /**
  5013. * Gets or sets the maximum yaw angle that the bone can look to
  5014. */
  5015. maxYaw: number;
  5016. /**
  5017. * Gets or sets the minimum pitch angle that the bone can look to
  5018. */
  5019. minPitch: number;
  5020. /**
  5021. * Gets or sets the maximum pitch angle that the bone can look to
  5022. */
  5023. maxPitch: number;
  5024. /**
  5025. * Create a BoneLookController
  5026. * @param mesh the mesh that the bone belongs to
  5027. * @param bone the bone that will be looking to the target
  5028. * @param target the target Vector3 to look at
  5029. * @param settings optional settings:
  5030. * * maxYaw: the maximum angle the bone will yaw to
  5031. * * minYaw: the minimum angle the bone will yaw to
  5032. * * maxPitch: the maximum angle the bone will pitch to
  5033. * * minPitch: the minimum angle the bone will yaw to
  5034. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5035. * * upAxis: the up axis of the coordinate system
  5036. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5037. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5038. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5039. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5040. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5041. * * adjustRoll: used to make an adjustment to the roll of the bone
  5042. **/
  5043. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5044. maxYaw?: number;
  5045. minYaw?: number;
  5046. maxPitch?: number;
  5047. minPitch?: number;
  5048. slerpAmount?: number;
  5049. upAxis?: Vector3;
  5050. upAxisSpace?: Space;
  5051. yawAxis?: Vector3;
  5052. pitchAxis?: Vector3;
  5053. adjustYaw?: number;
  5054. adjustPitch?: number;
  5055. adjustRoll?: number;
  5056. });
  5057. /**
  5058. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5059. */
  5060. update(): void;
  5061. private _getAngleDiff(ang1, ang2);
  5062. private _getAngleBetween(ang1, ang2);
  5063. private _isAngleBetween(ang, ang1, ang2);
  5064. }
  5065. }
  5066. declare module BABYLON {
  5067. /**
  5068. * Class used to handle skinning animations
  5069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5070. */
  5071. class Skeleton implements IAnimatable {
  5072. /** defines the skeleton name */
  5073. name: string;
  5074. /** defines the skeleton Id */
  5075. id: string;
  5076. /**
  5077. * Gets the list of child bones
  5078. */
  5079. bones: Bone[];
  5080. /**
  5081. * Gets an estimate of the dimension of the skeleton at rest
  5082. */
  5083. dimensionsAtRest: Vector3;
  5084. /**
  5085. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5086. */
  5087. needInitialSkinMatrix: boolean;
  5088. /**
  5089. * Gets the list of animations attached to this skeleton
  5090. */
  5091. animations: Array<Animation>;
  5092. private _scene;
  5093. private _isDirty;
  5094. private _transformMatrices;
  5095. private _meshesWithPoseMatrix;
  5096. private _animatables;
  5097. private _identity;
  5098. private _synchronizedWithMesh;
  5099. private _ranges;
  5100. private _lastAbsoluteTransformsUpdateId;
  5101. /**
  5102. * Specifies if the skeleton should be serialized
  5103. */
  5104. doNotSerialize: boolean;
  5105. private _animationPropertiesOverride;
  5106. /**
  5107. * Gets or sets the animation properties override
  5108. */
  5109. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5110. /**
  5111. * An observable triggered before computing the skeleton's matrices
  5112. */
  5113. onBeforeComputeObservable: Observable<Skeleton>;
  5114. /**
  5115. * Creates a new skeleton
  5116. * @param name defines the skeleton name
  5117. * @param id defines the skeleton Id
  5118. * @param scene defines the hosting scene
  5119. */
  5120. constructor(
  5121. /** defines the skeleton name */
  5122. name: string,
  5123. /** defines the skeleton Id */
  5124. id: string, scene: Scene);
  5125. /**
  5126. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5127. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5128. * @returns a Float32Array containing matrices data
  5129. */
  5130. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5131. /**
  5132. * Gets the current hosting scene
  5133. * @returns a scene object
  5134. */
  5135. getScene(): Scene;
  5136. /**
  5137. * Gets a string representing the current skeleton data
  5138. * @param fullDetails defines a boolean indicating if we want a verbose version
  5139. * @returns a string representing the current skeleton data
  5140. */
  5141. toString(fullDetails?: boolean): string;
  5142. /**
  5143. * Get bone's index searching by name
  5144. * @param name defines bone's name to search for
  5145. * @return the indice of the bone. Returns -1 if not found
  5146. */
  5147. getBoneIndexByName(name: string): number;
  5148. /**
  5149. * Creater a new animation range
  5150. * @param name defines the name of the range
  5151. * @param from defines the start key
  5152. * @param to defines the end key
  5153. */
  5154. createAnimationRange(name: string, from: number, to: number): void;
  5155. /**
  5156. * Delete a specific animation range
  5157. * @param name defines the name of the range
  5158. * @param deleteFrames defines if frames must be removed as well
  5159. */
  5160. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5161. /**
  5162. * Gets a specific animation range
  5163. * @param name defines the name of the range to look for
  5164. * @returns the requested animation range or null if not found
  5165. */
  5166. getAnimationRange(name: string): Nullable<AnimationRange>;
  5167. /**
  5168. * Gets the list of all animation ranges defined on this skeleton
  5169. * @returns an array
  5170. */
  5171. getAnimationRanges(): Nullable<AnimationRange>[];
  5172. /**
  5173. * Copy animation range from a source skeleton.
  5174. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5175. * @param source defines the source skeleton
  5176. * @param name defines the name of the range to copy
  5177. * @param rescaleAsRequired defines if rescaling must be applied if required
  5178. * @returns true if operation was successful
  5179. */
  5180. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5181. /**
  5182. * Forces the skeleton to go to rest pose
  5183. */
  5184. returnToRest(): void;
  5185. private _getHighestAnimationFrame();
  5186. /**
  5187. * Begin a specific animation range
  5188. * @param name defines the name of the range to start
  5189. * @param loop defines if looping must be turned on (false by default)
  5190. * @param speedRatio defines the speed ratio to apply (1 by default)
  5191. * @param onAnimationEnd defines a callback which will be called when animation will end
  5192. * @returns a new animatable
  5193. */
  5194. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5195. /** @hidden */
  5196. /** @hidden */
  5197. /** @hidden */
  5198. /** @hidden */
  5199. /**
  5200. * Build all resources required to render a skeleton
  5201. */
  5202. prepare(): void;
  5203. /**
  5204. * Gets the list of animatables currently running for this skeleton
  5205. * @returns an array of animatables
  5206. */
  5207. getAnimatables(): IAnimatable[];
  5208. /**
  5209. * Clone the current skeleton
  5210. * @param name defines the name of the new skeleton
  5211. * @param id defines the id of the enw skeleton
  5212. * @returns the new skeleton
  5213. */
  5214. clone(name: string, id: string): Skeleton;
  5215. /**
  5216. * Enable animation blending for this skeleton
  5217. * @param blendingSpeed defines the blending speed to apply
  5218. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5219. */
  5220. enableBlending(blendingSpeed?: number): void;
  5221. /**
  5222. * Releases all resources associated with the current skeleton
  5223. */
  5224. dispose(): void;
  5225. /**
  5226. * Serialize the skeleton in a JSON object
  5227. * @returns a JSON object
  5228. */
  5229. serialize(): any;
  5230. /**
  5231. * Creates a new skeleton from serialized data
  5232. * @param parsedSkeleton defines the serialized data
  5233. * @param scene defines the hosting scene
  5234. * @returns a new skeleton
  5235. */
  5236. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5237. /**
  5238. * Compute all node absolute transforms
  5239. * @param forceUpdate defines if computation must be done even if cache is up to date
  5240. */
  5241. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5242. /**
  5243. * Gets the root pose matrix
  5244. * @returns a matrix
  5245. */
  5246. getPoseMatrix(): Nullable<Matrix>;
  5247. /**
  5248. * Sorts bones per internal index
  5249. */
  5250. sortBones(): void;
  5251. private _sortBones(index, bones, visited);
  5252. }
  5253. }
  5254. declare module BABYLON {
  5255. class Collider {
  5256. /** Define if a collision was found */
  5257. collisionFound: boolean;
  5258. /**
  5259. * Define last intersection point in local space
  5260. */
  5261. intersectionPoint: Vector3;
  5262. /**
  5263. * Define last collided mesh
  5264. */
  5265. collidedMesh: Nullable<AbstractMesh>;
  5266. private _collisionPoint;
  5267. private _planeIntersectionPoint;
  5268. private _tempVector;
  5269. private _tempVector2;
  5270. private _tempVector3;
  5271. private _tempVector4;
  5272. private _edge;
  5273. private _baseToVertex;
  5274. private _destinationPoint;
  5275. private _slidePlaneNormal;
  5276. private _displacementVector;
  5277. private _velocity;
  5278. private _basePoint;
  5279. private _epsilon;
  5280. private _velocityWorld;
  5281. private _normalizedVelocity;
  5282. private _nearestDistance;
  5283. private _collisionMask;
  5284. collisionMask: number;
  5285. /**
  5286. * Gets the plane normal used to compute the sliding response (in local space)
  5287. */
  5288. readonly slidePlaneNormal: Vector3;
  5289. }
  5290. }
  5291. declare module BABYLON {
  5292. var CollisionWorker: string;
  5293. interface ICollisionCoordinator {
  5294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5295. init(scene: Scene): void;
  5296. destroy(): void;
  5297. onMeshAdded(mesh: AbstractMesh): void;
  5298. onMeshUpdated(mesh: AbstractMesh): void;
  5299. onMeshRemoved(mesh: AbstractMesh): void;
  5300. onGeometryAdded(geometry: Geometry): void;
  5301. onGeometryUpdated(geometry: Geometry): void;
  5302. onGeometryDeleted(geometry: Geometry): void;
  5303. }
  5304. interface SerializedMesh {
  5305. id: string;
  5306. name: string;
  5307. uniqueId: number;
  5308. geometryId: Nullable<string>;
  5309. sphereCenter: Array<number>;
  5310. sphereRadius: number;
  5311. boxMinimum: Array<number>;
  5312. boxMaximum: Array<number>;
  5313. worldMatrixFromCache: any;
  5314. subMeshes: Array<SerializedSubMesh>;
  5315. checkCollisions: boolean;
  5316. }
  5317. interface SerializedSubMesh {
  5318. position: number;
  5319. verticesStart: number;
  5320. verticesCount: number;
  5321. indexStart: number;
  5322. indexCount: number;
  5323. hasMaterial: boolean;
  5324. sphereCenter: Array<number>;
  5325. sphereRadius: number;
  5326. boxMinimum: Array<number>;
  5327. boxMaximum: Array<number>;
  5328. }
  5329. /**
  5330. * Interface describing the value associated with a geometry
  5331. */
  5332. interface SerializedGeometry {
  5333. /**
  5334. * Defines the unique ID of the geometry
  5335. */
  5336. id: string;
  5337. /**
  5338. * Defines the array containing the positions
  5339. */
  5340. positions: Float32Array;
  5341. /**
  5342. * Defines the array containing the indices
  5343. */
  5344. indices: Uint32Array;
  5345. /**
  5346. * Defines the array containing the normals
  5347. */
  5348. normals: Float32Array;
  5349. }
  5350. interface BabylonMessage {
  5351. taskType: WorkerTaskType;
  5352. payload: InitPayload | CollidePayload | UpdatePayload;
  5353. }
  5354. interface SerializedColliderToWorker {
  5355. position: Array<number>;
  5356. velocity: Array<number>;
  5357. radius: Array<number>;
  5358. }
  5359. /** Defines supported task for worker process */
  5360. enum WorkerTaskType {
  5361. /** Initialization */
  5362. INIT = 0,
  5363. /** Update of geometry */
  5364. UPDATE = 1,
  5365. /** Evaluate collision */
  5366. COLLIDE = 2,
  5367. }
  5368. interface WorkerReply {
  5369. error: WorkerReplyType;
  5370. taskType: WorkerTaskType;
  5371. payload?: any;
  5372. }
  5373. interface CollisionReplyPayload {
  5374. newPosition: Array<number>;
  5375. collisionId: number;
  5376. collidedMeshUniqueId: number;
  5377. }
  5378. interface InitPayload {
  5379. }
  5380. interface CollidePayload {
  5381. collisionId: number;
  5382. collider: SerializedColliderToWorker;
  5383. maximumRetry: number;
  5384. excludedMeshUniqueId: Nullable<number>;
  5385. }
  5386. interface UpdatePayload {
  5387. updatedMeshes: {
  5388. [n: number]: SerializedMesh;
  5389. };
  5390. updatedGeometries: {
  5391. [s: string]: SerializedGeometry;
  5392. };
  5393. removedMeshes: Array<number>;
  5394. removedGeometries: Array<string>;
  5395. }
  5396. /** Defines kind of replies returned by worker */
  5397. enum WorkerReplyType {
  5398. /** Success */
  5399. SUCCESS = 0,
  5400. /** Unkown error */
  5401. UNKNOWN_ERROR = 1,
  5402. }
  5403. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5404. private _scene;
  5405. private _scaledPosition;
  5406. private _scaledVelocity;
  5407. private _collisionsCallbackArray;
  5408. private _init;
  5409. private _runningUpdated;
  5410. private _worker;
  5411. private _addUpdateMeshesList;
  5412. private _addUpdateGeometriesList;
  5413. private _toRemoveMeshesArray;
  5414. private _toRemoveGeometryArray;
  5415. constructor();
  5416. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5417. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5418. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5419. init(scene: Scene): void;
  5420. destroy(): void;
  5421. onMeshAdded(mesh: AbstractMesh): void;
  5422. onMeshUpdated: (transformNode: TransformNode) => void;
  5423. onMeshRemoved(mesh: AbstractMesh): void;
  5424. onGeometryAdded(geometry: Geometry): void;
  5425. onGeometryUpdated: (geometry: Geometry) => void;
  5426. onGeometryDeleted(geometry: Geometry): void;
  5427. private _afterRender;
  5428. private _onMessageFromWorker;
  5429. }
  5430. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5431. private _scene;
  5432. private _scaledPosition;
  5433. private _scaledVelocity;
  5434. private _finalPosition;
  5435. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5436. init(scene: Scene): void;
  5437. destroy(): void;
  5438. onMeshAdded(mesh: AbstractMesh): void;
  5439. onMeshUpdated(mesh: AbstractMesh): void;
  5440. onMeshRemoved(mesh: AbstractMesh): void;
  5441. onGeometryAdded(geometry: Geometry): void;
  5442. onGeometryUpdated(geometry: Geometry): void;
  5443. onGeometryDeleted(geometry: Geometry): void;
  5444. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5445. }
  5446. }
  5447. declare function importScripts(...urls: string[]): void;
  5448. declare const safePostMessage: any;
  5449. declare module BABYLON {
  5450. var WorkerIncluded: boolean;
  5451. class CollisionCache {
  5452. private _meshes;
  5453. private _geometries;
  5454. getMeshes(): {
  5455. [n: number]: SerializedMesh;
  5456. };
  5457. getGeometries(): {
  5458. [s: number]: SerializedGeometry;
  5459. };
  5460. getMesh(id: any): SerializedMesh;
  5461. addMesh(mesh: SerializedMesh): void;
  5462. removeMesh(uniqueId: number): void;
  5463. getGeometry(id: string): SerializedGeometry;
  5464. addGeometry(geometry: SerializedGeometry): void;
  5465. removeGeometry(id: string): void;
  5466. }
  5467. class CollideWorker {
  5468. collider: Collider;
  5469. private _collisionCache;
  5470. private finalPosition;
  5471. private collisionsScalingMatrix;
  5472. private collisionTranformationMatrix;
  5473. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5474. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5475. private checkCollision(mesh);
  5476. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5477. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5478. private checkSubmeshCollision(subMesh);
  5479. }
  5480. interface ICollisionDetector {
  5481. onInit(payload: InitPayload): void;
  5482. onUpdate(payload: UpdatePayload): void;
  5483. onCollision(payload: CollidePayload): void;
  5484. }
  5485. class CollisionDetectorTransferable implements ICollisionDetector {
  5486. private _collisionCache;
  5487. onInit(payload: InitPayload): void;
  5488. onUpdate(payload: UpdatePayload): void;
  5489. onCollision(payload: CollidePayload): void;
  5490. }
  5491. }
  5492. declare module BABYLON {
  5493. class IntersectionInfo {
  5494. bu: Nullable<number>;
  5495. bv: Nullable<number>;
  5496. distance: number;
  5497. faceId: number;
  5498. subMeshId: number;
  5499. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5500. }
  5501. class PickingInfo {
  5502. hit: boolean;
  5503. distance: number;
  5504. pickedPoint: Nullable<Vector3>;
  5505. pickedMesh: Nullable<AbstractMesh>;
  5506. bu: number;
  5507. bv: number;
  5508. faceId: number;
  5509. subMeshId: number;
  5510. pickedSprite: Nullable<Sprite>;
  5511. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5512. getTextureCoordinates(): Nullable<Vector2>;
  5513. }
  5514. }
  5515. declare module BABYLON {
  5516. class BoundingBox implements ICullable {
  5517. vectors: Vector3[];
  5518. center: Vector3;
  5519. centerWorld: Vector3;
  5520. extendSize: Vector3;
  5521. extendSizeWorld: Vector3;
  5522. directions: Vector3[];
  5523. vectorsWorld: Vector3[];
  5524. minimumWorld: Vector3;
  5525. maximumWorld: Vector3;
  5526. minimum: Vector3;
  5527. maximum: Vector3;
  5528. private _worldMatrix;
  5529. /**
  5530. * Creates a new bounding box
  5531. * @param min defines the minimum vector (in local space)
  5532. * @param max defines the maximum vector (in local space)
  5533. */
  5534. constructor(min: Vector3, max: Vector3);
  5535. /**
  5536. * Recreates the entire bounding box from scratch
  5537. * @param min defines the new minimum vector (in local space)
  5538. * @param max defines the new maximum vector (in local space)
  5539. */
  5540. reConstruct(min: Vector3, max: Vector3): void;
  5541. getWorldMatrix(): Matrix;
  5542. setWorldMatrix(matrix: Matrix): BoundingBox;
  5543. isInFrustum(frustumPlanes: Plane[]): boolean;
  5544. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5545. intersectsPoint(point: Vector3): boolean;
  5546. intersectsSphere(sphere: BoundingSphere): boolean;
  5547. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5548. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5549. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5550. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5551. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5552. }
  5553. }
  5554. declare module BABYLON {
  5555. interface ICullable {
  5556. isInFrustum(frustumPlanes: Plane[]): boolean;
  5557. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5558. }
  5559. class BoundingInfo implements ICullable {
  5560. minimum: Vector3;
  5561. maximum: Vector3;
  5562. boundingBox: BoundingBox;
  5563. boundingSphere: BoundingSphere;
  5564. private _isLocked;
  5565. constructor(minimum: Vector3, maximum: Vector3);
  5566. isLocked: boolean;
  5567. update(world: Matrix): void;
  5568. /**
  5569. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5570. * @param center New center of the bounding info
  5571. * @param extend New extend of the bounding info
  5572. */
  5573. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5574. isInFrustum(frustumPlanes: Plane[]): boolean;
  5575. /**
  5576. * Gets the world distance between the min and max points of the bounding box
  5577. */
  5578. readonly diagonalLength: number;
  5579. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5580. intersectsPoint(point: Vector3): boolean;
  5581. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5582. }
  5583. }
  5584. declare module BABYLON {
  5585. class BoundingSphere {
  5586. center: Vector3;
  5587. radius: number;
  5588. centerWorld: Vector3;
  5589. radiusWorld: number;
  5590. minimum: Vector3;
  5591. maximum: Vector3;
  5592. private _tempRadiusVector;
  5593. /**
  5594. * Creates a new bounding sphere
  5595. * @param min defines the minimum vector (in local space)
  5596. * @param max defines the maximum vector (in local space)
  5597. */
  5598. constructor(min: Vector3, max: Vector3);
  5599. /**
  5600. * Recreates the entire bounding sphere from scratch
  5601. * @param min defines the new minimum vector (in local space)
  5602. * @param max defines the new maximum vector (in local space)
  5603. */
  5604. reConstruct(min: Vector3, max: Vector3): void;
  5605. isInFrustum(frustumPlanes: Plane[]): boolean;
  5606. intersectsPoint(point: Vector3): boolean;
  5607. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5608. }
  5609. }
  5610. declare module BABYLON {
  5611. class Ray {
  5612. origin: Vector3;
  5613. direction: Vector3;
  5614. length: number;
  5615. private _edge1;
  5616. private _edge2;
  5617. private _pvec;
  5618. private _tvec;
  5619. private _qvec;
  5620. private _tmpRay;
  5621. constructor(origin: Vector3, direction: Vector3, length?: number);
  5622. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5623. intersectsBox(box: BoundingBox): boolean;
  5624. intersectsSphere(sphere: BoundingSphere): boolean;
  5625. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5626. intersectsPlane(plane: Plane): Nullable<number>;
  5627. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5628. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5629. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5630. private static smallnum;
  5631. private static rayl;
  5632. /**
  5633. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5634. * @param sega the first point of the segment to test the intersection against
  5635. * @param segb the second point of the segment to test the intersection against
  5636. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5637. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5638. */
  5639. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5640. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5641. static Zero(): Ray;
  5642. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5643. /**
  5644. * 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
  5645. * transformed to the given world matrix.
  5646. * @param origin The origin point
  5647. * @param end The end point
  5648. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5649. */
  5650. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5651. static Transform(ray: Ray, matrix: Matrix): Ray;
  5652. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5653. }
  5654. }
  5655. declare module BABYLON {
  5656. class ArcRotateCamera extends TargetCamera {
  5657. alpha: number;
  5658. beta: number;
  5659. radius: number;
  5660. protected _target: Vector3;
  5661. protected _targetHost: Nullable<AbstractMesh>;
  5662. target: Vector3;
  5663. inertialAlphaOffset: number;
  5664. inertialBetaOffset: number;
  5665. inertialRadiusOffset: number;
  5666. lowerAlphaLimit: Nullable<number>;
  5667. upperAlphaLimit: Nullable<number>;
  5668. lowerBetaLimit: number;
  5669. upperBetaLimit: number;
  5670. lowerRadiusLimit: Nullable<number>;
  5671. upperRadiusLimit: Nullable<number>;
  5672. inertialPanningX: number;
  5673. inertialPanningY: number;
  5674. pinchToPanMaxDistance: number;
  5675. panningDistanceLimit: Nullable<number>;
  5676. panningOriginTarget: Vector3;
  5677. panningInertia: number;
  5678. angularSensibilityX: number;
  5679. angularSensibilityY: number;
  5680. pinchPrecision: number;
  5681. pinchDeltaPercentage: number;
  5682. panningSensibility: number;
  5683. keysUp: number[];
  5684. keysDown: number[];
  5685. keysLeft: number[];
  5686. keysRight: number[];
  5687. wheelPrecision: number;
  5688. wheelDeltaPercentage: number;
  5689. zoomOnFactor: number;
  5690. targetScreenOffset: Vector2;
  5691. allowUpsideDown: boolean;
  5692. inputs: ArcRotateCameraInputsManager;
  5693. panningAxis: Vector3;
  5694. protected _localDirection: Vector3;
  5695. protected _transformedDirection: Vector3;
  5696. private _bouncingBehavior;
  5697. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5698. useBouncingBehavior: boolean;
  5699. private _framingBehavior;
  5700. readonly framingBehavior: Nullable<FramingBehavior>;
  5701. useFramingBehavior: boolean;
  5702. private _autoRotationBehavior;
  5703. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5704. useAutoRotationBehavior: boolean;
  5705. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5706. onCollide: (collidedMesh: AbstractMesh) => void;
  5707. checkCollisions: boolean;
  5708. collisionRadius: Vector3;
  5709. protected _collider: Collider;
  5710. protected _previousPosition: Vector3;
  5711. protected _collisionVelocity: Vector3;
  5712. protected _newPosition: Vector3;
  5713. protected _previousAlpha: number;
  5714. protected _previousBeta: number;
  5715. protected _previousRadius: number;
  5716. protected _collisionTriggered: boolean;
  5717. protected _targetBoundingCenter: Nullable<Vector3>;
  5718. private _computationVector;
  5719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5720. protected _getTargetPosition(): Vector3;
  5721. /**
  5722. * Store current camera state (fov, position, etc..)
  5723. */
  5724. private _storedAlpha;
  5725. private _storedBeta;
  5726. private _storedRadius;
  5727. private _storedTarget;
  5728. storeState(): Camera;
  5729. /**
  5730. * Restored camera state. You must call storeState() first
  5731. */
  5732. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5733. detachControl(element: HTMLElement): void;
  5734. protected _checkLimits(): void;
  5735. rebuildAnglesAndRadius(): void;
  5736. setPosition(position: Vector3): void;
  5737. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5738. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5739. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5740. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5741. min: Vector3;
  5742. max: Vector3;
  5743. distance: number;
  5744. }, doNotUpdateMaxZ?: boolean): void;
  5745. /**
  5746. * @override
  5747. * Override Camera.createRigCamera
  5748. */
  5749. createRigCamera(name: string, cameraIndex: number): Camera;
  5750. /**
  5751. * @override
  5752. * Override Camera._updateRigCameras
  5753. */
  5754. dispose(): void;
  5755. getClassName(): string;
  5756. }
  5757. }
  5758. declare module BABYLON {
  5759. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5760. constructor(camera: ArcRotateCamera);
  5761. addMouseWheel(): ArcRotateCameraInputsManager;
  5762. addPointers(): ArcRotateCameraInputsManager;
  5763. addKeyboard(): ArcRotateCameraInputsManager;
  5764. addGamepad(): ArcRotateCameraInputsManager;
  5765. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5766. }
  5767. }
  5768. declare module BABYLON {
  5769. class Camera extends Node {
  5770. inputs: CameraInputsManager<Camera>;
  5771. private static _PERSPECTIVE_CAMERA;
  5772. private static _ORTHOGRAPHIC_CAMERA;
  5773. private static _FOVMODE_VERTICAL_FIXED;
  5774. private static _FOVMODE_HORIZONTAL_FIXED;
  5775. private static _RIG_MODE_NONE;
  5776. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5777. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5778. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5779. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5780. private static _RIG_MODE_VR;
  5781. private static _RIG_MODE_WEBVR;
  5782. static readonly PERSPECTIVE_CAMERA: number;
  5783. static readonly ORTHOGRAPHIC_CAMERA: number;
  5784. /**
  5785. * This is the default FOV mode for perspective cameras.
  5786. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5787. *
  5788. */
  5789. static readonly FOVMODE_VERTICAL_FIXED: number;
  5790. /**
  5791. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5792. *
  5793. */
  5794. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5795. static readonly RIG_MODE_NONE: number;
  5796. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5797. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5798. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5799. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5800. static readonly RIG_MODE_VR: number;
  5801. static readonly RIG_MODE_WEBVR: number;
  5802. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5803. static UseAlternateWebVRRendering: boolean;
  5804. position: Vector3;
  5805. /**
  5806. * The vector the camera should consider as up.
  5807. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5808. */
  5809. upVector: Vector3;
  5810. orthoLeft: Nullable<number>;
  5811. orthoRight: Nullable<number>;
  5812. orthoBottom: Nullable<number>;
  5813. orthoTop: Nullable<number>;
  5814. /**
  5815. * FOV is set in Radians. (default is 0.8)
  5816. */
  5817. fov: number;
  5818. minZ: number;
  5819. maxZ: number;
  5820. inertia: number;
  5821. mode: number;
  5822. isIntermediate: boolean;
  5823. viewport: Viewport;
  5824. /**
  5825. * Restricts the camera to viewing objects with the same layerMask.
  5826. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5827. */
  5828. layerMask: number;
  5829. /**
  5830. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5831. */
  5832. fovMode: number;
  5833. cameraRigMode: number;
  5834. interaxialDistance: number;
  5835. isStereoscopicSideBySide: boolean;
  5836. protected _webvrViewMatrix: Matrix;
  5837. customRenderTargets: RenderTargetTexture[];
  5838. onViewMatrixChangedObservable: Observable<Camera>;
  5839. onProjectionMatrixChangedObservable: Observable<Camera>;
  5840. onAfterCheckInputsObservable: Observable<Camera>;
  5841. onRestoreStateObservable: Observable<Camera>;
  5842. private _computedViewMatrix;
  5843. private _doNotComputeProjectionMatrix;
  5844. private _worldMatrix;
  5845. private _transformMatrix;
  5846. protected _globalPosition: Vector3;
  5847. private _frustumPlanes;
  5848. private _refreshFrustumPlanes;
  5849. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5850. private _storedFov;
  5851. private _stateStored;
  5852. /**
  5853. * Store current camera state (fov, position, etc..)
  5854. */
  5855. storeState(): Camera;
  5856. /**
  5857. * Restores the camera state values if it has been stored. You must call storeState() first
  5858. */
  5859. protected _restoreStateValues(): boolean;
  5860. /**
  5861. * Restored camera state. You must call storeState() first
  5862. */
  5863. restoreState(): boolean;
  5864. getClassName(): string;
  5865. /**
  5866. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5867. */
  5868. toString(fullDetails?: boolean): string;
  5869. readonly globalPosition: Vector3;
  5870. getActiveMeshes(): SmartArray<AbstractMesh>;
  5871. isActiveMesh(mesh: Mesh): boolean;
  5872. /**
  5873. * Is this camera ready to be used/rendered
  5874. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5875. * @return true if the camera is ready
  5876. */
  5877. isReady(completeCheck?: boolean): boolean;
  5878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5879. detachControl(element: HTMLElement): void;
  5880. update(): void;
  5881. readonly rigCameras: Camera[];
  5882. readonly rigPostProcess: Nullable<PostProcess>;
  5883. /**
  5884. * Internal, gets the first post proces.
  5885. * @returns the first post process to be run on this camera.
  5886. */
  5887. private _cascadePostProcessesToRigCams();
  5888. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5889. detachPostProcess(postProcess: PostProcess): void;
  5890. getWorldMatrix(): Matrix;
  5891. getViewMatrix(force?: boolean): Matrix;
  5892. freezeProjectionMatrix(projection?: Matrix): void;
  5893. unfreezeProjectionMatrix(): void;
  5894. getProjectionMatrix(force?: boolean): Matrix;
  5895. getTranformationMatrix(): Matrix;
  5896. private updateFrustumPlanes();
  5897. isInFrustum(target: ICullable): boolean;
  5898. isCompletelyInFrustum(target: ICullable): boolean;
  5899. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5900. /**
  5901. * Releases resources associated with this node.
  5902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5904. */
  5905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5906. readonly leftCamera: Nullable<FreeCamera>;
  5907. readonly rightCamera: Nullable<FreeCamera>;
  5908. getLeftTarget(): Nullable<Vector3>;
  5909. getRightTarget(): Nullable<Vector3>;
  5910. setCameraRigMode(mode: number, rigParams: any): void;
  5911. private _getVRProjectionMatrix();
  5912. protected _updateCameraRotationMatrix(): void;
  5913. protected _updateWebVRCameraRotationMatrix(): void;
  5914. /**
  5915. * This function MUST be overwritten by the different WebVR cameras available.
  5916. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5917. */
  5918. protected _getWebVRProjectionMatrix(): Matrix;
  5919. /**
  5920. * This function MUST be overwritten by the different WebVR cameras available.
  5921. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5922. */
  5923. protected _getWebVRViewMatrix(): Matrix;
  5924. setCameraRigParameter(name: string, value: any): void;
  5925. /**
  5926. * needs to be overridden by children so sub has required properties to be copied
  5927. */
  5928. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5929. /**
  5930. * May need to be overridden by children
  5931. */
  5932. serialize(): any;
  5933. clone(name: string): Camera;
  5934. getDirection(localAxis: Vector3): Vector3;
  5935. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5936. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5937. computeWorldMatrix(): Matrix;
  5938. static Parse(parsedCamera: any, scene: Scene): Camera;
  5939. }
  5940. }
  5941. declare module BABYLON {
  5942. var CameraInputTypes: {};
  5943. interface ICameraInput<TCamera extends Camera> {
  5944. camera: Nullable<TCamera>;
  5945. getClassName(): string;
  5946. getSimpleName(): string;
  5947. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5948. detachControl: (element: Nullable<HTMLElement>) => void;
  5949. checkInputs?: () => void;
  5950. }
  5951. interface CameraInputsMap<TCamera extends Camera> {
  5952. [name: string]: ICameraInput<TCamera>;
  5953. [idx: number]: ICameraInput<TCamera>;
  5954. }
  5955. class CameraInputsManager<TCamera extends Camera> {
  5956. attached: CameraInputsMap<TCamera>;
  5957. attachedElement: Nullable<HTMLElement>;
  5958. noPreventDefault: boolean;
  5959. camera: TCamera;
  5960. checkInputs: () => void;
  5961. constructor(camera: TCamera);
  5962. /**
  5963. * Add an input method to a camera.
  5964. * builtin inputs example: camera.inputs.addGamepad();
  5965. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5966. * @param input camera input method
  5967. */
  5968. add(input: ICameraInput<TCamera>): void;
  5969. /**
  5970. * Remove a specific input method from a camera
  5971. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5972. * @param inputToRemove camera input method
  5973. */
  5974. remove(inputToRemove: ICameraInput<TCamera>): void;
  5975. removeByType(inputType: string): void;
  5976. private _addCheckInputs(fn);
  5977. attachInput(input: ICameraInput<TCamera>): void;
  5978. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5979. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5980. rebuildInputCheck(): void;
  5981. /**
  5982. * Remove all attached input methods from a camera
  5983. */
  5984. clear(): void;
  5985. serialize(serializedCamera: any): void;
  5986. parse(parsedCamera: any): void;
  5987. }
  5988. }
  5989. declare module BABYLON {
  5990. /**
  5991. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5992. * being tilted forward or back and left or right.
  5993. */
  5994. class DeviceOrientationCamera extends FreeCamera {
  5995. private _initialQuaternion;
  5996. private _quaternionCache;
  5997. /**
  5998. * Creates a new device orientation camera
  5999. * @param name The name of the camera
  6000. * @param position The start position camera
  6001. * @param scene The scene the camera belongs to
  6002. */
  6003. constructor(name: string, position: Vector3, scene: Scene);
  6004. /**
  6005. * Gets the current instance class name ("DeviceOrientationCamera").
  6006. * This helps avoiding instanceof at run time.
  6007. * @returns the class name
  6008. */
  6009. getClassName(): string;
  6010. /**
  6011. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6012. */
  6013. /**
  6014. * Reset the camera to its default orientation on the specified axis only.
  6015. * @param axis The axis to reset
  6016. */
  6017. resetToCurrentRotation(axis?: Axis): void;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. class FollowCamera extends TargetCamera {
  6022. radius: number;
  6023. rotationOffset: number;
  6024. heightOffset: number;
  6025. cameraAcceleration: number;
  6026. maxCameraSpeed: number;
  6027. lockedTarget: Nullable<AbstractMesh>;
  6028. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6029. private getRadians(degrees);
  6030. private follow(cameraTarget);
  6031. getClassName(): string;
  6032. }
  6033. class ArcFollowCamera extends TargetCamera {
  6034. alpha: number;
  6035. beta: number;
  6036. radius: number;
  6037. target: Nullable<AbstractMesh>;
  6038. private _cartesianCoordinates;
  6039. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6040. private follow();
  6041. getClassName(): string;
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. class FreeCamera extends TargetCamera {
  6046. ellipsoid: Vector3;
  6047. ellipsoidOffset: Vector3;
  6048. checkCollisions: boolean;
  6049. applyGravity: boolean;
  6050. inputs: FreeCameraInputsManager;
  6051. /**
  6052. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6053. * Higher values reduce sensitivity.
  6054. */
  6055. /**
  6056. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6057. * Higher values reduce sensitivity.
  6058. */
  6059. angularSensibility: number;
  6060. keysUp: number[];
  6061. keysDown: number[];
  6062. keysLeft: number[];
  6063. keysRight: number[];
  6064. onCollide: (collidedMesh: AbstractMesh) => void;
  6065. private _collider;
  6066. private _needMoveForGravity;
  6067. private _oldPosition;
  6068. private _diffPosition;
  6069. private _newPosition;
  6070. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6072. detachControl(element: HTMLElement): void;
  6073. private _collisionMask;
  6074. collisionMask: number;
  6075. private _onCollisionPositionChange;
  6076. dispose(): void;
  6077. getClassName(): string;
  6078. }
  6079. }
  6080. declare module BABYLON {
  6081. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6082. constructor(camera: FreeCamera);
  6083. addKeyboard(): FreeCameraInputsManager;
  6084. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6085. addGamepad(): FreeCameraInputsManager;
  6086. addDeviceOrientation(): FreeCameraInputsManager;
  6087. addTouch(): FreeCameraInputsManager;
  6088. addVirtualJoystick(): FreeCameraInputsManager;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. class GamepadCamera extends UniversalCamera {
  6093. gamepadAngularSensibility: number;
  6094. gamepadMoveSensibility: number;
  6095. constructor(name: string, position: Vector3, scene: Scene);
  6096. getClassName(): string;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6102. */
  6103. class AnaglyphFreeCamera extends FreeCamera {
  6104. /**
  6105. * Creates a new AnaglyphFreeCamera
  6106. * @param name defines camera name
  6107. * @param position defines initial position
  6108. * @param interaxialDistance defines distance between each color axis
  6109. * @param scene defines the hosting scene
  6110. */
  6111. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6112. /**
  6113. * Gets camera class name
  6114. * @returns AnaglyphFreeCamera
  6115. */
  6116. getClassName(): string;
  6117. }
  6118. /**
  6119. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6120. */
  6121. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6122. /**
  6123. * Creates a new AnaglyphArcRotateCamera
  6124. * @param name defines camera name
  6125. * @param alpha defines alpha angle (in radians)
  6126. * @param beta defines beta angle (in radians)
  6127. * @param radius defines radius
  6128. * @param target defines camera target
  6129. * @param interaxialDistance defines distance between each color axis
  6130. * @param scene defines the hosting scene
  6131. */
  6132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6133. /**
  6134. * Gets camera class name
  6135. * @returns AnaglyphArcRotateCamera
  6136. */
  6137. getClassName(): string;
  6138. }
  6139. /**
  6140. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6141. */
  6142. class AnaglyphGamepadCamera extends GamepadCamera {
  6143. /**
  6144. * Creates a new AnaglyphGamepadCamera
  6145. * @param name defines camera name
  6146. * @param position defines initial position
  6147. * @param interaxialDistance defines distance between each color axis
  6148. * @param scene defines the hosting scene
  6149. */
  6150. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6151. /**
  6152. * Gets camera class name
  6153. * @returns AnaglyphGamepadCamera
  6154. */
  6155. getClassName(): string;
  6156. }
  6157. /**
  6158. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6159. */
  6160. class AnaglyphUniversalCamera extends UniversalCamera {
  6161. /**
  6162. * Creates a new AnaglyphUniversalCamera
  6163. * @param name defines camera name
  6164. * @param position defines initial position
  6165. * @param interaxialDistance defines distance between each color axis
  6166. * @param scene defines the hosting scene
  6167. */
  6168. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6169. /**
  6170. * Gets camera class name
  6171. * @returns AnaglyphUniversalCamera
  6172. */
  6173. getClassName(): string;
  6174. }
  6175. /**
  6176. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6177. */
  6178. class StereoscopicFreeCamera extends FreeCamera {
  6179. /**
  6180. * Creates a new StereoscopicFreeCamera
  6181. * @param name defines camera name
  6182. * @param position defines initial position
  6183. * @param interaxialDistance defines distance between each color axis
  6184. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6185. * @param scene defines the hosting scene
  6186. */
  6187. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6188. /**
  6189. * Gets camera class name
  6190. * @returns StereoscopicFreeCamera
  6191. */
  6192. getClassName(): string;
  6193. }
  6194. /**
  6195. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6196. */
  6197. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6198. /**
  6199. * Creates a new StereoscopicArcRotateCamera
  6200. * @param name defines camera name
  6201. * @param alpha defines alpha angle (in radians)
  6202. * @param beta defines beta angle (in radians)
  6203. * @param radius defines radius
  6204. * @param target defines camera target
  6205. * @param interaxialDistance defines distance between each color axis
  6206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6207. * @param scene defines the hosting scene
  6208. */
  6209. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6210. /**
  6211. * Gets camera class name
  6212. * @returns StereoscopicArcRotateCamera
  6213. */
  6214. getClassName(): string;
  6215. }
  6216. /**
  6217. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6218. */
  6219. class StereoscopicGamepadCamera extends GamepadCamera {
  6220. /**
  6221. * Creates a new StereoscopicGamepadCamera
  6222. * @param name defines camera name
  6223. * @param position defines initial position
  6224. * @param interaxialDistance defines distance between each color axis
  6225. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6226. * @param scene defines the hosting scene
  6227. */
  6228. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6229. /**
  6230. * Gets camera class name
  6231. * @returns StereoscopicGamepadCamera
  6232. */
  6233. getClassName(): string;
  6234. }
  6235. /**
  6236. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6237. */
  6238. class StereoscopicUniversalCamera extends UniversalCamera {
  6239. /**
  6240. * Creates a new StereoscopicUniversalCamera
  6241. * @param name defines camera name
  6242. * @param position defines initial position
  6243. * @param interaxialDistance defines distance between each color axis
  6244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6245. * @param scene defines the hosting scene
  6246. */
  6247. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6248. /**
  6249. * Gets camera class name
  6250. * @returns StereoscopicUniversalCamera
  6251. */
  6252. getClassName(): string;
  6253. }
  6254. }
  6255. declare module BABYLON {
  6256. class TargetCamera extends Camera {
  6257. cameraDirection: Vector3;
  6258. cameraRotation: Vector2;
  6259. rotation: Vector3;
  6260. rotationQuaternion: Quaternion;
  6261. speed: number;
  6262. noRotationConstraint: boolean;
  6263. lockedTarget: any;
  6264. private _rigCamTransformMatrix;
  6265. private _currentUpVector;
  6266. protected _globalCurrentTarget: Vector3;
  6267. protected _globalCurrentUpVector: Vector3;
  6268. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6269. getFrontPosition(distance: number): Vector3;
  6270. /**
  6271. * Store current camera state (fov, position, etc..)
  6272. */
  6273. private _storedPosition;
  6274. private _storedRotation;
  6275. private _storedRotationQuaternion;
  6276. storeState(): Camera;
  6277. /**
  6278. * Restored camera state. You must call storeState() first
  6279. */
  6280. setTarget(target: Vector3): void;
  6281. /**
  6282. * Return the current target position of the camera. This value is expressed in local space.
  6283. */
  6284. getTarget(): Vector3;
  6285. protected _updateCameraRotationMatrix(): void;
  6286. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6287. /**
  6288. * @override
  6289. * Override Camera.createRigCamera
  6290. */
  6291. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6292. /**
  6293. * @override
  6294. * Override Camera._updateRigCameras
  6295. */
  6296. private _getRigCamPosition(halfSpace, result);
  6297. getClassName(): string;
  6298. }
  6299. }
  6300. declare module BABYLON {
  6301. class TouchCamera extends FreeCamera {
  6302. touchAngularSensibility: number;
  6303. touchMoveSensibility: number;
  6304. constructor(name: string, position: Vector3, scene: Scene);
  6305. getClassName(): string;
  6306. }
  6307. }
  6308. declare module BABYLON {
  6309. class UniversalCamera extends TouchCamera {
  6310. gamepadAngularSensibility: number;
  6311. gamepadMoveSensibility: number;
  6312. constructor(name: string, position: Vector3, scene: Scene);
  6313. getClassName(): string;
  6314. }
  6315. }
  6316. declare module BABYLON {
  6317. class VirtualJoysticksCamera extends FreeCamera {
  6318. constructor(name: string, position: Vector3, scene: Scene);
  6319. getClassName(): string;
  6320. }
  6321. }
  6322. interface VRDisplay extends EventTarget {
  6323. /**
  6324. * Dictionary of capabilities describing the VRDisplay.
  6325. */
  6326. readonly capabilities: VRDisplayCapabilities;
  6327. /**
  6328. * z-depth defining the far plane of the eye view frustum
  6329. * enables mapping of values in the render target depth
  6330. * attachment to scene coordinates. Initially set to 10000.0.
  6331. */
  6332. depthFar: number;
  6333. /**
  6334. * z-depth defining the near plane of the eye view frustum
  6335. * enables mapping of values in the render target depth
  6336. * attachment to scene coordinates. Initially set to 0.01.
  6337. */
  6338. depthNear: number;
  6339. /**
  6340. * An identifier for this distinct VRDisplay. Used as an
  6341. * association point in the Gamepad API.
  6342. */
  6343. readonly displayId: number;
  6344. /**
  6345. * A display name, a user-readable name identifying it.
  6346. */
  6347. readonly displayName: string;
  6348. readonly isConnected: boolean;
  6349. readonly isPresenting: boolean;
  6350. /**
  6351. * If this VRDisplay supports room-scale experiences, the optional
  6352. * stage attribute contains details on the room-scale parameters.
  6353. */
  6354. readonly stageParameters: VRStageParameters | null;
  6355. /**
  6356. * Passing the value returned by `requestAnimationFrame` to
  6357. * `cancelAnimationFrame` will unregister the callback.
  6358. */
  6359. cancelAnimationFrame(handle: number): void;
  6360. /**
  6361. * Stops presenting to the VRDisplay.
  6362. */
  6363. exitPresent(): Promise<void>;
  6364. getEyeParameters(whichEye: string): VREyeParameters;
  6365. /**
  6366. * Populates the passed VRFrameData with the information required to render
  6367. * the current frame.
  6368. */
  6369. getFrameData(frameData: VRFrameData): boolean;
  6370. /**
  6371. * Get the layers currently being presented.
  6372. */
  6373. getLayers(): VRLayer[];
  6374. /**
  6375. * Return a VRPose containing the future predicted pose of the VRDisplay
  6376. * when the current frame will be presented. The value returned will not
  6377. * change until JavaScript has returned control to the browser.
  6378. *
  6379. * The VRPose will contain the position, orientation, velocity,
  6380. * and acceleration of each of these properties.
  6381. */
  6382. getPose(): VRPose;
  6383. /**
  6384. * Return the current instantaneous pose of the VRDisplay, with no
  6385. * prediction applied.
  6386. */
  6387. getImmediatePose(): VRPose;
  6388. /**
  6389. * The callback passed to `requestAnimationFrame` will be called
  6390. * any time a new frame should be rendered. When the VRDisplay is
  6391. * presenting the callback will be called at the native refresh
  6392. * rate of the HMD. When not presenting this function acts
  6393. * identically to how window.requestAnimationFrame acts. Content should
  6394. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6395. * asynchronously from other displays and at differing refresh rates.
  6396. */
  6397. requestAnimationFrame(callback: FrameRequestCallback): number;
  6398. /**
  6399. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6400. * Repeat calls while already presenting will update the VRLayers being displayed.
  6401. */
  6402. requestPresent(layers: VRLayer[]): Promise<void>;
  6403. /**
  6404. * Reset the pose for this display, treating its current position and
  6405. * orientation as the "origin/zero" values. VRPose.position,
  6406. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6407. * updated when calling resetPose(). This should be called in only
  6408. * sitting-space experiences.
  6409. */
  6410. resetPose(): void;
  6411. /**
  6412. * The VRLayer provided to the VRDisplay will be captured and presented
  6413. * in the HMD. Calling this function has the same effect on the source
  6414. * canvas as any other operation that uses its source image, and canvases
  6415. * created without preserveDrawingBuffer set to true will be cleared.
  6416. */
  6417. submitFrame(pose?: VRPose): void;
  6418. }
  6419. declare var VRDisplay: {
  6420. prototype: VRDisplay;
  6421. new (): VRDisplay;
  6422. };
  6423. interface VRLayer {
  6424. leftBounds?: number[] | null;
  6425. rightBounds?: number[] | null;
  6426. source?: HTMLCanvasElement | null;
  6427. }
  6428. interface VRDisplayCapabilities {
  6429. readonly canPresent: boolean;
  6430. readonly hasExternalDisplay: boolean;
  6431. readonly hasOrientation: boolean;
  6432. readonly hasPosition: boolean;
  6433. readonly maxLayers: number;
  6434. }
  6435. interface VREyeParameters {
  6436. /** @deprecated */
  6437. readonly fieldOfView: VRFieldOfView;
  6438. readonly offset: Float32Array;
  6439. readonly renderHeight: number;
  6440. readonly renderWidth: number;
  6441. }
  6442. interface VRFieldOfView {
  6443. readonly downDegrees: number;
  6444. readonly leftDegrees: number;
  6445. readonly rightDegrees: number;
  6446. readonly upDegrees: number;
  6447. }
  6448. interface VRFrameData {
  6449. readonly leftProjectionMatrix: Float32Array;
  6450. readonly leftViewMatrix: Float32Array;
  6451. readonly pose: VRPose;
  6452. readonly rightProjectionMatrix: Float32Array;
  6453. readonly rightViewMatrix: Float32Array;
  6454. readonly timestamp: number;
  6455. }
  6456. interface VRPose {
  6457. readonly angularAcceleration: Float32Array | null;
  6458. readonly angularVelocity: Float32Array | null;
  6459. readonly linearAcceleration: Float32Array | null;
  6460. readonly linearVelocity: Float32Array | null;
  6461. readonly orientation: Float32Array | null;
  6462. readonly position: Float32Array | null;
  6463. readonly timestamp: number;
  6464. }
  6465. interface VRStageParameters {
  6466. sittingToStandingTransform?: Float32Array;
  6467. sizeX?: number;
  6468. sizeY?: number;
  6469. }
  6470. interface Navigator {
  6471. getVRDisplays(): Promise<VRDisplay[]>;
  6472. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6473. }
  6474. interface Window {
  6475. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6476. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6477. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6478. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6479. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6480. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6481. }
  6482. interface Gamepad {
  6483. readonly displayId: number;
  6484. }
  6485. declare module BABYLON {
  6486. /**
  6487. * Interface for attribute information associated with buffer instanciation
  6488. */
  6489. class InstancingAttributeInfo {
  6490. /**
  6491. * Index/offset of the attribute in the vertex shader
  6492. */
  6493. index: number;
  6494. /**
  6495. * size of the attribute, 1, 2, 3 or 4
  6496. */
  6497. attributeSize: number;
  6498. /**
  6499. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6500. * default is FLOAT
  6501. */
  6502. attribyteType: number;
  6503. /**
  6504. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6505. */
  6506. normalized: boolean;
  6507. /**
  6508. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6509. */
  6510. offset: number;
  6511. /**
  6512. * Name of the GLSL attribute, for debugging purpose only
  6513. */
  6514. attributeName: string;
  6515. }
  6516. /**
  6517. * Define options used to create a render target texture
  6518. */
  6519. class RenderTargetCreationOptions {
  6520. /**
  6521. * Specifies is mipmaps must be generated
  6522. */
  6523. generateMipMaps?: boolean;
  6524. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6525. generateDepthBuffer?: boolean;
  6526. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6527. generateStencilBuffer?: boolean;
  6528. /** Defines texture type (int by default) */
  6529. type?: number;
  6530. /** Defines sampling mode (trilinear by default) */
  6531. samplingMode?: number;
  6532. /** Defines format (RGBA by default) */
  6533. format?: number;
  6534. }
  6535. /**
  6536. * Define options used to create a depth texture
  6537. */
  6538. class DepthTextureCreationOptions {
  6539. /** Specifies whether or not a stencil should be allocated in the texture */
  6540. generateStencil?: boolean;
  6541. /** Specifies whether or not bilinear filtering is enable on the texture */
  6542. bilinearFiltering?: boolean;
  6543. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6544. comparisonFunction?: number;
  6545. /** Specifies if the created texture is a cube texture */
  6546. isCube?: boolean;
  6547. }
  6548. /**
  6549. * Class used to describe the capabilities of the engine relatively to the current browser
  6550. */
  6551. class EngineCapabilities {
  6552. /** Maximum textures units per fragment shader */
  6553. maxTexturesImageUnits: number;
  6554. /** Maximum texture units per vertex shader */
  6555. maxVertexTextureImageUnits: number;
  6556. /** Maximum textures units in the entire pipeline */
  6557. maxCombinedTexturesImageUnits: number;
  6558. /** Maximum texture size */
  6559. maxTextureSize: number;
  6560. /** Maximum cube texture size */
  6561. maxCubemapTextureSize: number;
  6562. /** Maximum render texture size */
  6563. maxRenderTextureSize: number;
  6564. /** Maximum number of vertex attributes */
  6565. maxVertexAttribs: number;
  6566. /** Maximum number of varyings */
  6567. maxVaryingVectors: number;
  6568. /** Maximum number of uniforms per vertex shader */
  6569. maxVertexUniformVectors: number;
  6570. /** Maximum number of uniforms per fragment shader */
  6571. maxFragmentUniformVectors: number;
  6572. /** Defines if standard derivates (dx/dy) are supported */
  6573. standardDerivatives: boolean;
  6574. /** Defines if s3tc texture compression is supported */
  6575. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6576. /** Defines if pvrtc texture compression is supported */
  6577. pvrtc: any;
  6578. /** Defines if etc1 texture compression is supported */
  6579. etc1: any;
  6580. /** Defines if etc2 texture compression is supported */
  6581. etc2: any;
  6582. /** Defines if astc texture compression is supported */
  6583. astc: any;
  6584. /** Defines if float textures are supported */
  6585. textureFloat: boolean;
  6586. /** Defines if vertex array objects are supported */
  6587. vertexArrayObject: boolean;
  6588. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6589. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6590. /** Gets the maximum level of anisotropy supported */
  6591. maxAnisotropy: number;
  6592. /** Defines if instancing is supported */
  6593. instancedArrays: boolean;
  6594. /** Defines if 32 bits indices are supported */
  6595. uintIndices: boolean;
  6596. /** Defines if high precision shaders are supported */
  6597. highPrecisionShaderSupported: boolean;
  6598. /** Defines if depth reading in the fragment shader is supported */
  6599. fragmentDepthSupported: boolean;
  6600. /** Defines if float texture linear filtering is supported*/
  6601. textureFloatLinearFiltering: boolean;
  6602. /** Defines if rendering to float textures is supported */
  6603. textureFloatRender: boolean;
  6604. /** Defines if half float textures are supported*/
  6605. textureHalfFloat: boolean;
  6606. /** Defines if half float texture linear filtering is supported*/
  6607. textureHalfFloatLinearFiltering: boolean;
  6608. /** Defines if rendering to half float textures is supported */
  6609. textureHalfFloatRender: boolean;
  6610. /** Defines if textureLOD shader command is supported */
  6611. textureLOD: boolean;
  6612. /** Defines if draw buffers extension is supported */
  6613. drawBuffersExtension: boolean;
  6614. /** Defines if depth textures are supported */
  6615. depthTextureExtension: boolean;
  6616. /** Defines if float color buffer are supported */
  6617. colorBufferFloat: boolean;
  6618. /** Gets disjoint timer query extension (null if not supported) */
  6619. timerQuery: EXT_disjoint_timer_query;
  6620. /** Defines if timestamp can be used with timer query */
  6621. canUseTimestampForTimerQuery: boolean;
  6622. }
  6623. /** Interface defining initialization parameters for Engine class */
  6624. interface EngineOptions extends WebGLContextAttributes {
  6625. /**
  6626. * Defines if the engine should no exceed a specified device ratio
  6627. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6628. */
  6629. limitDeviceRatio?: number;
  6630. /**
  6631. * Defines if webvr should be enabled automatically
  6632. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6633. */
  6634. autoEnableWebVR?: boolean;
  6635. /**
  6636. * Defines if webgl2 should be turned off even if supported
  6637. * @see http://doc.babylonjs.com/features/webgl2
  6638. */
  6639. disableWebGL2Support?: boolean;
  6640. /**
  6641. * Defines if webaudio should be initialized as well
  6642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6643. */
  6644. audioEngine?: boolean;
  6645. /**
  6646. * Defines if animations should run using a deterministic lock step
  6647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6648. */
  6649. deterministicLockstep?: boolean;
  6650. /** Defines the maximum steps to use with deterministic lock step mode */
  6651. lockstepMaxSteps?: number;
  6652. /**
  6653. * Defines that engine should ignore context lost events
  6654. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6655. */
  6656. doNotHandleContextLost?: boolean;
  6657. }
  6658. /**
  6659. * Defines the interface used by display changed events
  6660. */
  6661. interface IDisplayChangedEventArgs {
  6662. /** Gets the vrDisplay object (if any) */
  6663. vrDisplay: Nullable<any>;
  6664. /** Gets a boolean indicating if webVR is supported */
  6665. vrSupported: boolean;
  6666. }
  6667. /**
  6668. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6669. */
  6670. class Engine {
  6671. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6672. static ExceptionList: ({
  6673. key: string;
  6674. capture: string;
  6675. captureConstraint: number;
  6676. targets: string[];
  6677. } | {
  6678. key: string;
  6679. capture: null;
  6680. captureConstraint: null;
  6681. targets: string[];
  6682. })[];
  6683. /** Gets the list of created engines */
  6684. static Instances: Engine[];
  6685. /**
  6686. * Gets the latest created engine
  6687. */
  6688. static readonly LastCreatedEngine: Nullable<Engine>;
  6689. /**
  6690. * Gets the latest created scene
  6691. */
  6692. static readonly LastCreatedScene: Nullable<Scene>;
  6693. /**
  6694. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6695. * @param flag defines which part of the materials must be marked as dirty
  6696. * @param predicate defines a predicate used to filter which materials should be affected
  6697. */
  6698. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6699. private static _ALPHA_DISABLE;
  6700. private static _ALPHA_ADD;
  6701. private static _ALPHA_COMBINE;
  6702. private static _ALPHA_SUBTRACT;
  6703. private static _ALPHA_MULTIPLY;
  6704. private static _ALPHA_MAXIMIZED;
  6705. private static _ALPHA_ONEONE;
  6706. private static _ALPHA_PREMULTIPLIED;
  6707. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6708. private static _ALPHA_INTERPOLATE;
  6709. private static _ALPHA_SCREENMODE;
  6710. private static _DELAYLOADSTATE_NONE;
  6711. private static _DELAYLOADSTATE_LOADED;
  6712. private static _DELAYLOADSTATE_LOADING;
  6713. private static _DELAYLOADSTATE_NOTLOADED;
  6714. private static _TEXTUREFORMAT_ALPHA;
  6715. private static _TEXTUREFORMAT_LUMINANCE;
  6716. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6717. private static _TEXTUREFORMAT_RGB;
  6718. private static _TEXTUREFORMAT_RGBA;
  6719. private static _TEXTUREFORMAT_R32F;
  6720. private static _TEXTUREFORMAT_RG32F;
  6721. private static _TEXTUREFORMAT_RGB32F;
  6722. private static _TEXTUREFORMAT_RGBA32F;
  6723. private static _TEXTURETYPE_UNSIGNED_INT;
  6724. private static _TEXTURETYPE_FLOAT;
  6725. private static _TEXTURETYPE_HALF_FLOAT;
  6726. private static _NEVER;
  6727. private static _ALWAYS;
  6728. private static _LESS;
  6729. private static _EQUAL;
  6730. private static _LEQUAL;
  6731. private static _GREATER;
  6732. private static _GEQUAL;
  6733. private static _NOTEQUAL;
  6734. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6735. static readonly NEVER: number;
  6736. /** 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 */
  6737. static readonly ALWAYS: number;
  6738. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6739. static readonly LESS: number;
  6740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6741. static readonly EQUAL: number;
  6742. /** 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 */
  6743. static readonly LEQUAL: number;
  6744. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6745. static readonly GREATER: number;
  6746. /** 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 */
  6747. static readonly GEQUAL: number;
  6748. /** 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 */
  6749. static readonly NOTEQUAL: number;
  6750. private static _KEEP;
  6751. private static _REPLACE;
  6752. private static _INCR;
  6753. private static _DECR;
  6754. private static _INVERT;
  6755. private static _INCR_WRAP;
  6756. private static _DECR_WRAP;
  6757. /** Passed to stencilOperation to specify that stencil value must be kept */
  6758. static readonly KEEP: number;
  6759. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6760. static readonly REPLACE: number;
  6761. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6762. static readonly INCR: number;
  6763. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6764. static readonly DECR: number;
  6765. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6766. static readonly INVERT: number;
  6767. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6768. static readonly INCR_WRAP: number;
  6769. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6770. static readonly DECR_WRAP: number;
  6771. /** Defines that alpha blending is disabled */
  6772. static readonly ALPHA_DISABLE: number;
  6773. /** Defines that alpha blending to SRC + DEST */
  6774. static readonly ALPHA_ONEONE: number;
  6775. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6776. static readonly ALPHA_ADD: number;
  6777. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6778. static readonly ALPHA_COMBINE: number;
  6779. /** Defines that alpha blending to DEST - SRC * DEST */
  6780. static readonly ALPHA_SUBTRACT: number;
  6781. /** Defines that alpha blending to SRC * DEST */
  6782. static readonly ALPHA_MULTIPLY: number;
  6783. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6784. static readonly ALPHA_MAXIMIZED: number;
  6785. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6786. static readonly ALPHA_PREMULTIPLIED: number;
  6787. /**
  6788. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6789. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6790. */
  6791. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6792. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6793. static readonly ALPHA_INTERPOLATE: number;
  6794. /**
  6795. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6796. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6797. */
  6798. static readonly ALPHA_SCREENMODE: number;
  6799. /** Defines that the ressource is not delayed*/
  6800. static readonly DELAYLOADSTATE_NONE: number;
  6801. /** Defines that the ressource was successfully delay loaded */
  6802. static readonly DELAYLOADSTATE_LOADED: number;
  6803. /** Defines that the ressource is currently delay loading */
  6804. static readonly DELAYLOADSTATE_LOADING: number;
  6805. /** Defines that the ressource is delayed and has not started loading */
  6806. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6807. /** ALPHA */
  6808. static readonly TEXTUREFORMAT_ALPHA: number;
  6809. /** LUMINANCE */
  6810. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6811. /**
  6812. * R32F
  6813. */
  6814. static readonly TEXTUREFORMAT_R32F: number;
  6815. /**
  6816. * RG32F
  6817. */
  6818. static readonly TEXTUREFORMAT_RG32F: number;
  6819. /**
  6820. * RGB32F
  6821. */
  6822. static readonly TEXTUREFORMAT_RGB32F: number;
  6823. /**
  6824. * RGBA32F
  6825. */
  6826. static readonly TEXTUREFORMAT_RGBA32F: number;
  6827. /** LUMINANCE_ALPHA */
  6828. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6829. /** RGB */
  6830. static readonly TEXTUREFORMAT_RGB: number;
  6831. /** RGBA */
  6832. static readonly TEXTUREFORMAT_RGBA: number;
  6833. /** UNSIGNED_INT */
  6834. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6835. /** FLOAT */
  6836. static readonly TEXTURETYPE_FLOAT: number;
  6837. /** HALF_FLOAT */
  6838. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6839. private static _SCALEMODE_FLOOR;
  6840. private static _SCALEMODE_NEAREST;
  6841. private static _SCALEMODE_CEILING;
  6842. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6843. static readonly SCALEMODE_FLOOR: number;
  6844. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6845. static readonly SCALEMODE_NEAREST: number;
  6846. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6847. static readonly SCALEMODE_CEILING: number;
  6848. /**
  6849. * Returns the current version of the framework
  6850. */
  6851. static readonly Version: string;
  6852. /**
  6853. * Gets or sets the epsilon value used by collision engine
  6854. */
  6855. static CollisionsEpsilon: number;
  6856. /**
  6857. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6858. */
  6859. static CodeRepository: string;
  6860. /**
  6861. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6862. */
  6863. static ShadersRepository: string;
  6864. /**
  6865. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6866. */
  6867. forcePOTTextures: boolean;
  6868. /**
  6869. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6870. */
  6871. isFullscreen: boolean;
  6872. /**
  6873. * Gets a boolean indicating if the pointer is currently locked
  6874. */
  6875. isPointerLock: boolean;
  6876. /**
  6877. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6878. */
  6879. cullBackFaces: boolean;
  6880. /**
  6881. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6882. */
  6883. renderEvenInBackground: boolean;
  6884. /**
  6885. * Gets or sets a boolean indicating that cache can be kept between frames
  6886. */
  6887. preventCacheWipeBetweenFrames: boolean;
  6888. /**
  6889. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6890. **/
  6891. enableOfflineSupport: boolean;
  6892. /**
  6893. * 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)
  6894. **/
  6895. disableManifestCheck: boolean;
  6896. /**
  6897. * Gets the list of created scenes
  6898. */
  6899. scenes: Scene[];
  6900. /**
  6901. * Gets the list of created postprocesses
  6902. */
  6903. postProcesses: PostProcess[];
  6904. /**
  6905. * Observable event triggered each time the rendering canvas is resized
  6906. */
  6907. onResizeObservable: Observable<Engine>;
  6908. /**
  6909. * Observable event triggered each time the canvas loses focus
  6910. */
  6911. onCanvasBlurObservable: Observable<Engine>;
  6912. /**
  6913. * Observable event triggered each time the canvas gains focus
  6914. */
  6915. onCanvasFocusObservable: Observable<Engine>;
  6916. /**
  6917. * Observable event triggered each time the canvas receives pointerout event
  6918. */
  6919. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6920. /**
  6921. * Observable event triggered before each texture is initialized
  6922. */
  6923. onBeforeTextureInitObservable: Observable<Texture>;
  6924. private _vrDisplay;
  6925. private _vrSupported;
  6926. private _oldSize;
  6927. private _oldHardwareScaleFactor;
  6928. private _vrExclusivePointerMode;
  6929. private _webVRInitPromise;
  6930. /**
  6931. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6932. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6933. */
  6934. readonly isInVRExclusivePointerMode: boolean;
  6935. /**
  6936. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6937. */
  6938. disableUniformBuffers: boolean;
  6939. /** @hidden */
  6940. /**
  6941. * Gets a boolean indicating that the engine supports uniform buffers
  6942. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6943. */
  6944. readonly supportsUniformBuffers: boolean;
  6945. /**
  6946. * Observable raised when the engine begins a new frame
  6947. */
  6948. onBeginFrameObservable: Observable<Engine>;
  6949. /**
  6950. * Observable raised when the engine ends the current frame
  6951. */
  6952. onEndFrameObservable: Observable<Engine>;
  6953. /**
  6954. * Observable raised when the engine is about to compile a shader
  6955. */
  6956. onBeforeShaderCompilationObservable: Observable<Engine>;
  6957. /**
  6958. * Observable raised when the engine has jsut compiled a shader
  6959. */
  6960. onAfterShaderCompilationObservable: Observable<Engine>;
  6961. private _gl;
  6962. private _renderingCanvas;
  6963. private _windowIsBackground;
  6964. private _webGLVersion;
  6965. /**
  6966. * Gets a boolean indicating that only power of 2 textures are supported
  6967. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6968. */
  6969. readonly needPOTTextures: boolean;
  6970. /** @hidden */
  6971. /** @hidden */
  6972. /**
  6973. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6974. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6975. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6976. */
  6977. disableTextureBindingOptimization: boolean;
  6978. /**
  6979. * Gets the audio engine
  6980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6981. * @ignorenaming
  6982. */
  6983. static audioEngine: AudioEngine;
  6984. private _onFocus;
  6985. private _onBlur;
  6986. private _onCanvasPointerOut;
  6987. private _onCanvasBlur;
  6988. private _onCanvasFocus;
  6989. private _onFullscreenChange;
  6990. private _onPointerLockChange;
  6991. private _onVRDisplayPointerRestricted;
  6992. private _onVRDisplayPointerUnrestricted;
  6993. private _onVrDisplayConnect;
  6994. private _onVrDisplayDisconnect;
  6995. private _onVrDisplayPresentChange;
  6996. /**
  6997. * Observable signaled when VR display mode changes
  6998. */
  6999. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7000. /**
  7001. * Observable signaled when VR request present is complete
  7002. */
  7003. onVRRequestPresentComplete: Observable<boolean>;
  7004. /**
  7005. * Observable signaled when VR request present starts
  7006. */
  7007. onVRRequestPresentStart: Observable<Engine>;
  7008. private _hardwareScalingLevel;
  7009. /** @hidden */
  7010. protected _caps: EngineCapabilities;
  7011. private _pointerLockRequested;
  7012. private _isStencilEnable;
  7013. private _colorWrite;
  7014. private _loadingScreen;
  7015. /** @hidden */
  7016. /** @hidden */
  7017. private _glVersion;
  7018. private _glRenderer;
  7019. private _glVendor;
  7020. private _videoTextureSupported;
  7021. private _renderingQueueLaunched;
  7022. private _activeRenderLoops;
  7023. private _deterministicLockstep;
  7024. private _lockstepMaxSteps;
  7025. /**
  7026. * Observable signaled when a context lost event is raised
  7027. */
  7028. onContextLostObservable: Observable<Engine>;
  7029. /**
  7030. * Observable signaled when a context restored event is raised
  7031. */
  7032. onContextRestoredObservable: Observable<Engine>;
  7033. private _onContextLost;
  7034. private _onContextRestored;
  7035. private _contextWasLost;
  7036. private _doNotHandleContextLost;
  7037. private _performanceMonitor;
  7038. private _fps;
  7039. private _deltaTime;
  7040. /**
  7041. * Turn this value on if you want to pause FPS computation when in background
  7042. */
  7043. disablePerformanceMonitorInBackground: boolean;
  7044. /**
  7045. * Gets the performance monitor attached to this engine
  7046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7047. */
  7048. readonly performanceMonitor: PerformanceMonitor;
  7049. /** @hidden */
  7050. protected _depthCullingState: _DepthCullingState;
  7051. /** @hidden */
  7052. protected _stencilState: _StencilState;
  7053. /** @hidden */
  7054. protected _alphaState: _AlphaState;
  7055. /** @hidden */
  7056. protected _alphaMode: number;
  7057. private _internalTexturesCache;
  7058. /** @hidden */
  7059. protected _activeChannel: number;
  7060. private _currentTextureChannel;
  7061. /** @hidden */
  7062. protected _boundTexturesCache: {
  7063. [key: string]: Nullable<InternalTexture>;
  7064. };
  7065. /** @hidden */
  7066. protected _currentEffect: Nullable<Effect>;
  7067. /** @hidden */
  7068. protected _currentProgram: Nullable<WebGLProgram>;
  7069. private _compiledEffects;
  7070. private _vertexAttribArraysEnabled;
  7071. /** @hidden */
  7072. protected _cachedViewport: Nullable<Viewport>;
  7073. private _cachedVertexArrayObject;
  7074. /** @hidden */
  7075. protected _cachedVertexBuffers: any;
  7076. /** @hidden */
  7077. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7078. /** @hidden */
  7079. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7080. /** @hidden */
  7081. protected _currentRenderTarget: Nullable<InternalTexture>;
  7082. private _uintIndicesCurrentlySet;
  7083. private _currentBoundBuffer;
  7084. /** @hidden */
  7085. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7086. private _currentBufferPointers;
  7087. private _currentInstanceLocations;
  7088. private _currentInstanceBuffers;
  7089. private _textureUnits;
  7090. private _firstBoundInternalTextureTracker;
  7091. private _lastBoundInternalTextureTracker;
  7092. private _workingCanvas;
  7093. private _workingContext;
  7094. private _rescalePostProcess;
  7095. private _dummyFramebuffer;
  7096. private _externalData;
  7097. private _bindedRenderFunction;
  7098. private _vaoRecordInProgress;
  7099. private _mustWipeVertexAttributes;
  7100. private _emptyTexture;
  7101. private _emptyCubeTexture;
  7102. private _emptyTexture3D;
  7103. private _frameHandler;
  7104. private _nextFreeTextureSlots;
  7105. private _maxSimultaneousTextures;
  7106. private _activeRequests;
  7107. private _texturesSupported;
  7108. private _textureFormatInUse;
  7109. /**
  7110. * Gets the list of texture formats supported
  7111. */
  7112. readonly texturesSupported: Array<string>;
  7113. /**
  7114. * Gets the list of texture formats in use
  7115. */
  7116. readonly textureFormatInUse: Nullable<string>;
  7117. /**
  7118. * Gets the current viewport
  7119. */
  7120. readonly currentViewport: Nullable<Viewport>;
  7121. /**
  7122. * Gets the default empty texture
  7123. */
  7124. readonly emptyTexture: InternalTexture;
  7125. /**
  7126. * Gets the default empty 3D texture
  7127. */
  7128. readonly emptyTexture3D: InternalTexture;
  7129. /**
  7130. * Gets the default empty cube texture
  7131. */
  7132. readonly emptyCubeTexture: InternalTexture;
  7133. /**
  7134. * Creates a new engine
  7135. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7136. * @param antialias defines enable antialiasing (default: false)
  7137. * @param options defines further options to be sent to the getContext() function
  7138. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7139. */
  7140. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7141. private _rebuildInternalTextures();
  7142. private _rebuildEffects();
  7143. private _rebuildBuffers();
  7144. private _initGLContext();
  7145. /**
  7146. * Gets version of the current webGL context
  7147. */
  7148. readonly webGLVersion: number;
  7149. /**
  7150. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7151. */
  7152. readonly isStencilEnable: boolean;
  7153. private _prepareWorkingCanvas();
  7154. /**
  7155. * Reset the texture cache to empty state
  7156. */
  7157. resetTextureCache(): void;
  7158. /**
  7159. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7161. * @returns true if engine is in deterministic lock step mode
  7162. */
  7163. isDeterministicLockStep(): boolean;
  7164. /**
  7165. * Gets the max steps when engine is running in deterministic lock step
  7166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7167. * @returns the max steps
  7168. */
  7169. getLockstepMaxSteps(): number;
  7170. /**
  7171. * Gets an object containing information about the current webGL context
  7172. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7173. */
  7174. getGlInfo(): {
  7175. vendor: string;
  7176. renderer: string;
  7177. version: string;
  7178. };
  7179. /**
  7180. * Gets current aspect ratio
  7181. * @param camera defines the camera to use to get the aspect ratio
  7182. * @param useScreen defines if screen size must be used (or the current render target if any)
  7183. * @returns a number defining the aspect ratio
  7184. */
  7185. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7186. /**
  7187. * Gets the current render width
  7188. * @param useScreen defines if screen size must be used (or the current render target if any)
  7189. * @returns a number defining the current render width
  7190. */
  7191. getRenderWidth(useScreen?: boolean): number;
  7192. /**
  7193. * Gets the current render height
  7194. * @param useScreen defines if screen size must be used (or the current render target if any)
  7195. * @returns a number defining the current render height
  7196. */
  7197. getRenderHeight(useScreen?: boolean): number;
  7198. /**
  7199. * Gets the HTML canvas attached with the current webGL context
  7200. * @returns a HTML canvas
  7201. */
  7202. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7203. /**
  7204. * Gets the client rect of the HTML canvas attached with the current webGL context
  7205. * @returns a client rectanglee
  7206. */
  7207. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7208. /**
  7209. * Defines the hardware scaling level.
  7210. * By default the hardware scaling level is computed from the window device ratio.
  7211. * 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.
  7212. * @param level defines the level to use
  7213. */
  7214. setHardwareScalingLevel(level: number): void;
  7215. /**
  7216. * Gets the current hardware scaling level.
  7217. * By default the hardware scaling level is computed from the window device ratio.
  7218. * 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.
  7219. * @returns a number indicating the current hardware scaling level
  7220. */
  7221. getHardwareScalingLevel(): number;
  7222. /**
  7223. * Gets the list of loaded textures
  7224. * @returns an array containing all loaded textures
  7225. */
  7226. getLoadedTexturesCache(): InternalTexture[];
  7227. /**
  7228. * Gets the object containing all engine capabilities
  7229. * @returns the EngineCapabilities object
  7230. */
  7231. getCaps(): EngineCapabilities;
  7232. /** @hidden */
  7233. readonly drawCalls: number;
  7234. /** @hidden */
  7235. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7236. /**
  7237. * Gets the current depth function
  7238. * @returns a number defining the depth function
  7239. */
  7240. getDepthFunction(): Nullable<number>;
  7241. /**
  7242. * Sets the current depth function
  7243. * @param depthFunc defines the function to use
  7244. */
  7245. setDepthFunction(depthFunc: number): void;
  7246. /**
  7247. * Sets the current depth function to GREATER
  7248. */
  7249. setDepthFunctionToGreater(): void;
  7250. /**
  7251. * Sets the current depth function to GEQUAL
  7252. */
  7253. setDepthFunctionToGreaterOrEqual(): void;
  7254. /**
  7255. * Sets the current depth function to LESS
  7256. */
  7257. setDepthFunctionToLess(): void;
  7258. /**
  7259. * Sets the current depth function to LEQUAL
  7260. */
  7261. setDepthFunctionToLessOrEqual(): void;
  7262. /**
  7263. * Gets a boolean indicating if stencil buffer is enabled
  7264. * @returns the current stencil buffer state
  7265. */
  7266. getStencilBuffer(): boolean;
  7267. /**
  7268. * Enable or disable the stencil buffer
  7269. * @param enable defines if the stencil buffer must be enabled or disabled
  7270. */
  7271. setStencilBuffer(enable: boolean): void;
  7272. /**
  7273. * Gets the current stencil mask
  7274. * @returns a number defining the new stencil mask to use
  7275. */
  7276. getStencilMask(): number;
  7277. /**
  7278. * Sets the current stencil mask
  7279. * @param mask defines the new stencil mask to use
  7280. */
  7281. setStencilMask(mask: number): void;
  7282. /**
  7283. * Gets the current stencil function
  7284. * @returns a number defining the stencil function to use
  7285. */
  7286. getStencilFunction(): number;
  7287. /**
  7288. * Gets the current stencil reference value
  7289. * @returns a number defining the stencil reference value to use
  7290. */
  7291. getStencilFunctionReference(): number;
  7292. /**
  7293. * Gets the current stencil mask
  7294. * @returns a number defining the stencil mask to use
  7295. */
  7296. getStencilFunctionMask(): number;
  7297. /**
  7298. * Sets the current stencil function
  7299. * @param stencilFunc defines the new stencil function to use
  7300. */
  7301. setStencilFunction(stencilFunc: number): void;
  7302. /**
  7303. * Sets the current stencil reference
  7304. * @param reference defines the new stencil reference to use
  7305. */
  7306. setStencilFunctionReference(reference: number): void;
  7307. /**
  7308. * Sets the current stencil mask
  7309. * @param mask defines the new stencil mask to use
  7310. */
  7311. setStencilFunctionMask(mask: number): void;
  7312. /**
  7313. * Gets the current stencil operation when stencil fails
  7314. * @returns a number defining stencil operation to use when stencil fails
  7315. */
  7316. getStencilOperationFail(): number;
  7317. /**
  7318. * Gets the current stencil operation when depth fails
  7319. * @returns a number defining stencil operation to use when depth fails
  7320. */
  7321. getStencilOperationDepthFail(): number;
  7322. /**
  7323. * Gets the current stencil operation when stencil passes
  7324. * @returns a number defining stencil operation to use when stencil passes
  7325. */
  7326. getStencilOperationPass(): number;
  7327. /**
  7328. * Sets the stencil operation to use when stencil fails
  7329. * @param operation defines the stencil operation to use when stencil fails
  7330. */
  7331. setStencilOperationFail(operation: number): void;
  7332. /**
  7333. * Sets the stencil operation to use when depth fails
  7334. * @param operation defines the stencil operation to use when depth fails
  7335. */
  7336. setStencilOperationDepthFail(operation: number): void;
  7337. /**
  7338. * Sets the stencil operation to use when stencil passes
  7339. * @param operation defines the stencil operation to use when stencil passes
  7340. */
  7341. setStencilOperationPass(operation: number): void;
  7342. /**
  7343. * Sets a boolean indicating if the dithering state is enabled or disabled
  7344. * @param value defines the dithering state
  7345. */
  7346. setDitheringState(value: boolean): void;
  7347. /**
  7348. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7349. * @param value defines the rasterizer state
  7350. */
  7351. setRasterizerState(value: boolean): void;
  7352. /**
  7353. * stop executing a render loop function and remove it from the execution array
  7354. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7355. */
  7356. stopRenderLoop(renderFunction?: () => void): void;
  7357. /** @hidden */
  7358. /**
  7359. * Register and execute a render loop. The engine can have more than one render function
  7360. * @param renderFunction defines the function to continuously execute
  7361. */
  7362. runRenderLoop(renderFunction: () => void): void;
  7363. /**
  7364. * Toggle full screen mode
  7365. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7366. * @param options defines an option object to be sent to the requestFullscreen function
  7367. */
  7368. switchFullscreen(requestPointerLock: boolean): void;
  7369. /**
  7370. * Clear the current render buffer or the current render target (if any is set up)
  7371. * @param color defines the color to use
  7372. * @param backBuffer defines if the back buffer must be cleared
  7373. * @param depth defines if the depth buffer must be cleared
  7374. * @param stencil defines if the stencil buffer must be cleared
  7375. */
  7376. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7377. /**
  7378. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7379. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7380. * @param y defines the y-coordinate of the corner of the clear rectangle
  7381. * @param width defines the width of the clear rectangle
  7382. * @param height defines the height of the clear rectangle
  7383. * @param clearColor defines the clear color
  7384. */
  7385. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7386. /**
  7387. * Set the WebGL's viewport
  7388. * @param viewport defines the viewport element to be used
  7389. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7390. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7391. */
  7392. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7393. /**
  7394. * Directly set the WebGL Viewport
  7395. * @param x defines the x coordinate of the viewport (in screen space)
  7396. * @param y defines the y coordinate of the viewport (in screen space)
  7397. * @param width defines the width of the viewport (in screen space)
  7398. * @param height defines the height of the viewport (in screen space)
  7399. * @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
  7400. */
  7401. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7402. /**
  7403. * Begin a new frame
  7404. */
  7405. beginFrame(): void;
  7406. /**
  7407. * Enf the current frame
  7408. */
  7409. endFrame(): void;
  7410. /**
  7411. * Resize the view according to the canvas' size
  7412. */
  7413. resize(): void;
  7414. /**
  7415. * Force a specific size of the canvas
  7416. * @param width defines the new canvas' width
  7417. * @param height defines the new canvas' height
  7418. */
  7419. setSize(width: number, height: number): void;
  7420. /**
  7421. * Gets a boolean indicating if a webVR device was detected
  7422. * @returns true if a webVR device was detected
  7423. */
  7424. isVRDevicePresent(): boolean;
  7425. /**
  7426. * Gets the current webVR device
  7427. * @returns the current webVR device (or null)
  7428. */
  7429. getVRDevice(): any;
  7430. /**
  7431. * Initializes a webVR display and starts listening to display change events
  7432. * The onVRDisplayChangedObservable will be notified upon these changes
  7433. * @returns The onVRDisplayChangedObservable
  7434. */
  7435. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7436. /**
  7437. * Initializes a webVR display and starts listening to display change events
  7438. * The onVRDisplayChangedObservable will be notified upon these changes
  7439. * @returns A promise containing a VRDisplay and if vr is supported
  7440. */
  7441. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7442. /**
  7443. * Call this function to switch to webVR mode
  7444. * Will do nothing if webVR is not supported or if there is no webVR device
  7445. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7446. */
  7447. enableVR(): void;
  7448. /**
  7449. * Call this function to leave webVR mode
  7450. * Will do nothing if webVR is not supported or if there is no webVR device
  7451. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7452. */
  7453. disableVR(): void;
  7454. private _onVRFullScreenTriggered;
  7455. private _getVRDisplaysAsync();
  7456. /**
  7457. * Binds the frame buffer to the specified texture.
  7458. * @param texture The texture to render to or null for the default canvas
  7459. * @param faceIndex The face of the texture to render to in case of cube texture
  7460. * @param requiredWidth The width of the target to render to
  7461. * @param requiredHeight The height of the target to render to
  7462. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7463. * @param depthStencilTexture The depth stencil texture to use to render
  7464. */
  7465. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7466. private bindUnboundFramebuffer(framebuffer);
  7467. /**
  7468. * Unbind the current render target texture from the webGL context
  7469. * @param texture defines the render target texture to unbind
  7470. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7471. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7472. */
  7473. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7474. /**
  7475. * Unbind a list of render target textures from the webGL context
  7476. * This is used only when drawBuffer extension or webGL2 are active
  7477. * @param textures defines the render target textures to unbind
  7478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7480. */
  7481. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7482. /**
  7483. * Force the mipmap generation for the given render target texture
  7484. * @param texture defines the render target texture to use
  7485. */
  7486. generateMipMapsForCubemap(texture: InternalTexture): void;
  7487. /**
  7488. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7489. */
  7490. flushFramebuffer(): void;
  7491. /**
  7492. * Unbind the current render target and bind the default framebuffer
  7493. */
  7494. restoreDefaultFramebuffer(): void;
  7495. /**
  7496. * Create an uniform buffer
  7497. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7498. * @param elements defines the content of the uniform buffer
  7499. * @returns the webGL uniform buffer
  7500. */
  7501. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7502. /**
  7503. * Create a dynamic uniform buffer
  7504. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7505. * @param elements defines the content of the uniform buffer
  7506. * @returns the webGL uniform buffer
  7507. */
  7508. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7509. /**
  7510. * Update an existing uniform buffer
  7511. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7512. * @param uniformBuffer defines the target uniform buffer
  7513. * @param elements defines the content to update
  7514. * @param offset defines the offset in the uniform buffer where update should start
  7515. * @param count defines the size of the data to update
  7516. */
  7517. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7518. private _resetVertexBufferBinding();
  7519. /**
  7520. * Creates a vertex buffer
  7521. * @param data the data for the vertex buffer
  7522. * @returns the new WebGL static buffer
  7523. */
  7524. createVertexBuffer(data: DataArray): WebGLBuffer;
  7525. /**
  7526. * Creates a dynamic vertex buffer
  7527. * @param data the data for the dynamic vertex buffer
  7528. * @returns the new WebGL dynamic buffer
  7529. */
  7530. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7531. /**
  7532. * Update a dynamic index buffer
  7533. * @param indexBuffer defines the target index buffer
  7534. * @param indices defines the data to update
  7535. * @param offset defines the offset in the target index buffer where update should start
  7536. */
  7537. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7538. /**
  7539. * Updates a dynamic vertex buffer.
  7540. * @param vertexBuffer the vertex buffer to update
  7541. * @param data the data used to update the vertex buffer
  7542. * @param byteOffset the byte offset of the data
  7543. * @param byteLength the byte length of the data
  7544. */
  7545. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7546. private _resetIndexBufferBinding();
  7547. /**
  7548. * Creates a new index buffer
  7549. * @param indices defines the content of the index buffer
  7550. * @param updatable defines if the index buffer must be updatable
  7551. * @returns a new webGL buffer
  7552. */
  7553. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7554. /**
  7555. * Bind a webGL buffer to the webGL context
  7556. * @param buffer defines the buffer to bind
  7557. */
  7558. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7559. /**
  7560. * Bind an uniform buffer to the current webGL context
  7561. * @param buffer defines the buffer to bind
  7562. */
  7563. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7564. /**
  7565. * Bind a buffer to the current webGL context at a given location
  7566. * @param buffer defines the buffer to bind
  7567. * @param location defines the index where to bind the buffer
  7568. */
  7569. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7570. /**
  7571. * Bind a specific block at a given index in a specific shader program
  7572. * @param shaderProgram defines the shader program
  7573. * @param blockName defines the block name
  7574. * @param index defines the index where to bind the block
  7575. */
  7576. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7577. private bindIndexBuffer(buffer);
  7578. private bindBuffer(buffer, target);
  7579. /**
  7580. * update the bound buffer with the given data
  7581. * @param data defines the data to update
  7582. */
  7583. updateArrayBuffer(data: Float32Array): void;
  7584. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7585. private _bindIndexBufferWithCache(indexBuffer);
  7586. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7587. /**
  7588. * Records a vertex array object
  7589. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7590. * @param vertexBuffers defines the list of vertex buffers to store
  7591. * @param indexBuffer defines the index buffer to store
  7592. * @param effect defines the effect to store
  7593. * @returns the new vertex array object
  7594. */
  7595. recordVertexArrayObject(vertexBuffers: {
  7596. [key: string]: VertexBuffer;
  7597. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7598. /**
  7599. * Bind a specific vertex array object
  7600. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7601. * @param vertexArrayObject defines the vertex array object to bind
  7602. * @param indexBuffer defines the index buffer to bind
  7603. */
  7604. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7605. /**
  7606. * Bind webGl buffers directly to the webGL context
  7607. * @param vertexBuffer defines the vertex buffer to bind
  7608. * @param indexBuffer defines the index buffer to bind
  7609. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7610. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7611. * @param effect defines the effect associated with the vertex buffer
  7612. */
  7613. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7614. private _unbindVertexArrayObject();
  7615. /**
  7616. * Bind a list of vertex buffers to the webGL context
  7617. * @param vertexBuffers defines the list of vertex buffers to bind
  7618. * @param indexBuffer defines the index buffer to bind
  7619. * @param effect defines the effect associated with the vertex buffers
  7620. */
  7621. bindBuffers(vertexBuffers: {
  7622. [key: string]: Nullable<VertexBuffer>;
  7623. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7624. /**
  7625. * Unbind all instance attributes
  7626. */
  7627. unbindInstanceAttributes(): void;
  7628. /**
  7629. * Release and free the memory of a vertex array object
  7630. * @param vao defines the vertex array object to delete
  7631. */
  7632. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7633. /** @hidden */
  7634. /**
  7635. * Creates a webGL buffer to use with instanciation
  7636. * @param capacity defines the size of the buffer
  7637. * @returns the webGL buffer
  7638. */
  7639. createInstancesBuffer(capacity: number): WebGLBuffer;
  7640. /**
  7641. * Delete a webGL buffer used with instanciation
  7642. * @param buffer defines the webGL buffer to delete
  7643. */
  7644. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7645. /**
  7646. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7647. * @param instancesBuffer defines the webGL buffer to update and bind
  7648. * @param data defines the data to store in the buffer
  7649. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7650. */
  7651. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7652. /**
  7653. * Apply all cached states (depth, culling, stencil and alpha)
  7654. */
  7655. applyStates(): void;
  7656. /**
  7657. * Send a draw order
  7658. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7659. * @param indexStart defines the starting index
  7660. * @param indexCount defines the number of index to draw
  7661. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7662. */
  7663. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7664. /**
  7665. * Draw a list of points
  7666. * @param verticesStart defines the index of first vertex to draw
  7667. * @param verticesCount defines the count of vertices to draw
  7668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7669. */
  7670. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7671. /**
  7672. * Draw a list of unindexed primitives
  7673. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7674. * @param verticesStart defines the index of first vertex to draw
  7675. * @param verticesCount defines the count of vertices to draw
  7676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7677. */
  7678. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7679. /**
  7680. * Draw a list of indexed primitives
  7681. * @param fillMode defines the primitive to use
  7682. * @param indexStart defines the starting index
  7683. * @param indexCount defines the number of index to draw
  7684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7685. */
  7686. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7687. /**
  7688. * Draw a list of unindexed primitives
  7689. * @param fillMode defines the primitive to use
  7690. * @param verticesStart defines the index of first vertex to draw
  7691. * @param verticesCount defines the count of vertices to draw
  7692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7693. */
  7694. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7695. private _drawMode(fillMode);
  7696. /** @hidden */
  7697. /** @hidden */
  7698. /**
  7699. * Create a new effect (used to store vertex/fragment shaders)
  7700. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7701. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7702. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7703. * @param samplers defines an array of string used to represent textures
  7704. * @param defines defines the string containing the defines to use to compile the shaders
  7705. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7706. * @param onCompiled defines a function to call when the effect creation is successful
  7707. * @param onError defines a function to call when the effect creation has failed
  7708. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7709. * @returns the new Effect
  7710. */
  7711. 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;
  7712. /**
  7713. * Create an effect to use with particle systems
  7714. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7715. * @param uniformsNames defines a list of attribute names
  7716. * @param samplers defines an array of string used to represent textures
  7717. * @param defines defines the string containing the defines to use to compile the shaders
  7718. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7719. * @param onCompiled defines a function to call when the effect creation is successful
  7720. * @param onError defines a function to call when the effect creation has failed
  7721. * @returns the new Effect
  7722. */
  7723. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7724. /**
  7725. * Directly creates a webGL program
  7726. * @param vertexCode defines the vertex shader code to use
  7727. * @param fragmentCode defines the fragment shader code to use
  7728. * @param context defines the webGL context to use (if not set, the current one will be used)
  7729. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7730. * @returns the new webGL program
  7731. */
  7732. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7733. /**
  7734. * Creates a webGL program
  7735. * @param vertexCode defines the vertex shader code to use
  7736. * @param fragmentCode defines the fragment shader code to use
  7737. * @param defines defines the string containing the defines to use to compile the shaders
  7738. * @param context defines the webGL context to use (if not set, the current one will be used)
  7739. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7740. * @returns the new webGL program
  7741. */
  7742. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7743. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7744. /**
  7745. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7746. * @param shaderProgram defines the webGL program to use
  7747. * @param uniformsNames defines the list of uniform names
  7748. * @returns an array of webGL uniform locations
  7749. */
  7750. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7751. /**
  7752. * Gets the lsit of active attributes for a given webGL program
  7753. * @param shaderProgram defines the webGL program to use
  7754. * @param attributesNames defines the list of attribute names to get
  7755. * @returns an array of indices indicating the offset of each attribute
  7756. */
  7757. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7758. /**
  7759. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7760. * @param effect defines the effect to activate
  7761. */
  7762. enableEffect(effect: Nullable<Effect>): void;
  7763. /**
  7764. * Set the value of an uniform to an array of int32
  7765. * @param uniform defines the webGL uniform location where to store the value
  7766. * @param array defines the array of int32 to store
  7767. */
  7768. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7769. /**
  7770. * Set the value of an uniform to an array of int32 (stored as vec2)
  7771. * @param uniform defines the webGL uniform location where to store the value
  7772. * @param array defines the array of int32 to store
  7773. */
  7774. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7775. /**
  7776. * Set the value of an uniform to an array of int32 (stored as vec3)
  7777. * @param uniform defines the webGL uniform location where to store the value
  7778. * @param array defines the array of int32 to store
  7779. */
  7780. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7781. /**
  7782. * Set the value of an uniform to an array of int32 (stored as vec4)
  7783. * @param uniform defines the webGL uniform location where to store the value
  7784. * @param array defines the array of int32 to store
  7785. */
  7786. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7787. /**
  7788. * Set the value of an uniform to an array of float32
  7789. * @param uniform defines the webGL uniform location where to store the value
  7790. * @param array defines the array of float32 to store
  7791. */
  7792. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7793. /**
  7794. * Set the value of an uniform to an array of float32 (stored as vec2)
  7795. * @param uniform defines the webGL uniform location where to store the value
  7796. * @param array defines the array of float32 to store
  7797. */
  7798. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7799. /**
  7800. * Set the value of an uniform to an array of float32 (stored as vec3)
  7801. * @param uniform defines the webGL uniform location where to store the value
  7802. * @param array defines the array of float32 to store
  7803. */
  7804. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7805. /**
  7806. * Set the value of an uniform to an array of float32 (stored as vec4)
  7807. * @param uniform defines the webGL uniform location where to store the value
  7808. * @param array defines the array of float32 to store
  7809. */
  7810. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7811. /**
  7812. * Set the value of an uniform to an array of number
  7813. * @param uniform defines the webGL uniform location where to store the value
  7814. * @param array defines the array of number to store
  7815. */
  7816. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7817. /**
  7818. * Set the value of an uniform to an array of number (stored as vec2)
  7819. * @param uniform defines the webGL uniform location where to store the value
  7820. * @param array defines the array of number to store
  7821. */
  7822. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7823. /**
  7824. * Set the value of an uniform to an array of number (stored as vec3)
  7825. * @param uniform defines the webGL uniform location where to store the value
  7826. * @param array defines the array of number to store
  7827. */
  7828. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7829. /**
  7830. * Set the value of an uniform to an array of number (stored as vec4)
  7831. * @param uniform defines the webGL uniform location where to store the value
  7832. * @param array defines the array of number to store
  7833. */
  7834. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7835. /**
  7836. * Set the value of an uniform to an array of float32 (stored as matrices)
  7837. * @param uniform defines the webGL uniform location where to store the value
  7838. * @param matrices defines the array of float32 to store
  7839. */
  7840. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7841. /**
  7842. * Set the value of an uniform to a matrix
  7843. * @param uniform defines the webGL uniform location where to store the value
  7844. * @param matrix defines the matrix to store
  7845. */
  7846. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7847. /**
  7848. * Set the value of an uniform to a matrix (3x3)
  7849. * @param uniform defines the webGL uniform location where to store the value
  7850. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7851. */
  7852. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7853. /**
  7854. * Set the value of an uniform to a matrix (2x2)
  7855. * @param uniform defines the webGL uniform location where to store the value
  7856. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7857. */
  7858. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7859. /**
  7860. * Set the value of an uniform to a number (int)
  7861. * @param uniform defines the webGL uniform location where to store the value
  7862. * @param value defines the int number to store
  7863. */
  7864. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7865. /**
  7866. * Set the value of an uniform to a number (float)
  7867. * @param uniform defines the webGL uniform location where to store the value
  7868. * @param value defines the float number to store
  7869. */
  7870. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7871. /**
  7872. * Set the value of an uniform to a vec2
  7873. * @param uniform defines the webGL uniform location where to store the value
  7874. * @param x defines the 1st component of the value
  7875. * @param y defines the 2nd component of the value
  7876. */
  7877. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7878. /**
  7879. * Set the value of an uniform to a vec3
  7880. * @param uniform defines the webGL uniform location where to store the value
  7881. * @param x defines the 1st component of the value
  7882. * @param y defines the 2nd component of the value
  7883. * @param z defines the 3rd component of the value
  7884. */
  7885. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7886. /**
  7887. * Set the value of an uniform to a boolean
  7888. * @param uniform defines the webGL uniform location where to store the value
  7889. * @param bool defines the boolean to store
  7890. */
  7891. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7892. /**
  7893. * Set the value of an uniform to a vec4
  7894. * @param uniform defines the webGL uniform location where to store the value
  7895. * @param x defines the 1st component of the value
  7896. * @param y defines the 2nd component of the value
  7897. * @param z defines the 3rd component of the value
  7898. * @param w defines the 4th component of the value
  7899. */
  7900. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7901. /**
  7902. * Set the value of an uniform to a Color3
  7903. * @param uniform defines the webGL uniform location where to store the value
  7904. * @param color3 defines the color to store
  7905. */
  7906. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7907. /**
  7908. * Set the value of an uniform to a Color3 and an alpha value
  7909. * @param uniform defines the webGL uniform location where to store the value
  7910. * @param color3 defines the color to store
  7911. * @param alpha defines the alpha component to store
  7912. */
  7913. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7914. /**
  7915. * Sets a Color4 on a uniform variable
  7916. * @param uniform defines the uniform location
  7917. * @param color4 defines the value to be set
  7918. */
  7919. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7920. /**
  7921. * Set various states to the webGL context
  7922. * @param culling defines backface culling state
  7923. * @param zOffset defines the value to apply to zOffset (0 by default)
  7924. * @param force defines if states must be applied even if cache is up to date
  7925. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7926. */
  7927. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7928. /**
  7929. * Set the z offset to apply to current rendering
  7930. * @param value defines the offset to apply
  7931. */
  7932. setZOffset(value: number): void;
  7933. /**
  7934. * Gets the current value of the zOffset
  7935. * @returns the current zOffset state
  7936. */
  7937. getZOffset(): number;
  7938. /**
  7939. * Enable or disable depth buffering
  7940. * @param enable defines the state to set
  7941. */
  7942. setDepthBuffer(enable: boolean): void;
  7943. /**
  7944. * Gets a boolean indicating if depth writing is enabled
  7945. * @returns the current depth writing state
  7946. */
  7947. getDepthWrite(): boolean;
  7948. /**
  7949. * Enable or disable depth writing
  7950. * @param enable defines the state to set
  7951. */
  7952. setDepthWrite(enable: boolean): void;
  7953. /**
  7954. * Enable or disable color writing
  7955. * @param enable defines the state to set
  7956. */
  7957. setColorWrite(enable: boolean): void;
  7958. /**
  7959. * Gets a boolean indicating if color writing is enabled
  7960. * @returns the current color writing state
  7961. */
  7962. getColorWrite(): boolean;
  7963. /**
  7964. * Sets alpha constants used by some alpha blending modes
  7965. * @param r defines the red component
  7966. * @param g defines the green component
  7967. * @param b defines the blue component
  7968. * @param a defines the alpha component
  7969. */
  7970. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7971. /**
  7972. * Sets the current alpha mode
  7973. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7974. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7976. */
  7977. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7978. /**
  7979. * Gets the current alpha mode
  7980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7981. * @returns the current alpha mode
  7982. */
  7983. getAlphaMode(): number;
  7984. /**
  7985. * Force the entire cache to be cleared
  7986. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7987. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7988. */
  7989. wipeCaches(bruteForce?: boolean): void;
  7990. /**
  7991. * Set the compressed texture format to use, based on the formats you have, and the formats
  7992. * supported by the hardware / browser.
  7993. *
  7994. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7995. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7996. * to API arguments needed to compressed textures. This puts the burden on the container
  7997. * generator to house the arcane code for determining these for current & future formats.
  7998. *
  7999. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8000. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8001. *
  8002. * Note: The result of this call is not taken into account when a texture is base64.
  8003. *
  8004. * @param formatsAvailable defines the list of those format families you have created
  8005. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8006. *
  8007. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8008. * @returns The extension selected.
  8009. */
  8010. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8011. /** @hidden */
  8012. /**
  8013. * Usually called from BABYLON.Texture.ts.
  8014. * Passed information to create a WebGLTexture
  8015. * @param urlArg defines a value which contains one of the following:
  8016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8020. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8021. * @param scene needed for loading to the correct scene
  8022. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8023. * @param onLoad optional callback to be called upon successful completion
  8024. * @param onError optional callback to be called upon failure
  8025. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  8026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8028. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8029. */
  8030. 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<ArrayBuffer | HTMLImageElement>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8031. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8032. /**
  8033. * Update a raw texture
  8034. * @param texture defines the texture to update
  8035. * @param data defines the data to store in the texture
  8036. * @param format defines the format of the data
  8037. * @param invertY defines if data must be stored with Y axis inverted
  8038. * @param compression defines the compression used (null by default)
  8039. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8040. */
  8041. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8042. /**
  8043. * Creates a raw texture
  8044. * @param data defines the data to store in the texture
  8045. * @param width defines the width of the texture
  8046. * @param height defines the height of the texture
  8047. * @param format defines the format of the data
  8048. * @param generateMipMaps defines if the engine should generate the mip levels
  8049. * @param invertY defines if data must be stored with Y axis inverted
  8050. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8051. * @param compression defines the compression used (null by default)
  8052. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8053. * @returns the raw texture inside an InternalTexture
  8054. */
  8055. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8056. /**
  8057. * Creates a dynamic texture
  8058. * @param width defines the width of the texture
  8059. * @param height defines the height of the texture
  8060. * @param generateMipMaps defines if the engine should generate the mip levels
  8061. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8062. * @returns the dynamic texture inside an InternalTexture
  8063. */
  8064. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8065. /**
  8066. * Update the sampling mode of a given texture
  8067. * @param samplingMode defines the required sampling mode
  8068. * @param texture defines the texture to update
  8069. */
  8070. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8071. /**
  8072. * Update the content of a dynamic texture
  8073. * @param texture defines the texture to update
  8074. * @param canvas defines the canvas containing the source
  8075. * @param invertY defines if data must be stored with Y axis inverted
  8076. * @param premulAlpha defines if alpha is stored as premultiplied
  8077. * @param format defines the format of the data
  8078. */
  8079. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8080. /**
  8081. * Update a video texture
  8082. * @param texture defines the texture to update
  8083. * @param video defines the video element to use
  8084. * @param invertY defines if data must be stored with Y axis inverted
  8085. */
  8086. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8087. /**
  8088. * Updates a depth texture Comparison Mode and Function.
  8089. * If the comparison Function is equal to 0, the mode will be set to none.
  8090. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8091. * @param texture The texture to set the comparison function for
  8092. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8093. */
  8094. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8095. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8096. /**
  8097. * Creates a depth stencil texture.
  8098. * This is only available in WebGL 2 or with the depth texture extension available.
  8099. * @param size The size of face edge in the texture.
  8100. * @param options The options defining the texture.
  8101. * @returns The texture
  8102. */
  8103. createDepthStencilTexture(size: number | {
  8104. width: number;
  8105. height: number;
  8106. }, options: DepthTextureCreationOptions): InternalTexture;
  8107. /**
  8108. * Creates a depth stencil texture.
  8109. * This is only available in WebGL 2 or with the depth texture extension available.
  8110. * @param size The size of face edge in the texture.
  8111. * @param options The options defining the texture.
  8112. * @returns The texture
  8113. */
  8114. private _createDepthStencilTexture(size, options);
  8115. /**
  8116. * Creates a depth stencil cube texture.
  8117. * This is only available in WebGL 2.
  8118. * @param size The size of face edge in the cube texture.
  8119. * @param options The options defining the cube texture.
  8120. * @returns The cube texture
  8121. */
  8122. private _createDepthStencilCubeTexture(size, options);
  8123. /**
  8124. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8125. * @param renderTarget The render target to set the frame buffer for
  8126. */
  8127. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8128. /**
  8129. * Creates a new render target texture
  8130. * @param size defines the size of the texture
  8131. * @param options defines the options used to create the texture
  8132. * @returns a new render target texture stored in an InternalTexture
  8133. */
  8134. createRenderTargetTexture(size: number | {
  8135. width: number;
  8136. height: number;
  8137. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8138. /**
  8139. * Create a multi render target texture
  8140. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8141. * @param size defines the size of the texture
  8142. * @param options defines the creation options
  8143. * @returns the cube texture as an InternalTexture
  8144. */
  8145. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8146. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8147. /**
  8148. * Updates the sample count of a render target texture
  8149. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8150. * @param texture defines the texture to update
  8151. * @param samples defines the sample count to set
  8152. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8153. */
  8154. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8155. /**
  8156. * Update the sample count for a given multiple render target texture
  8157. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8158. * @param textures defines the textures to update
  8159. * @param samples defines the sample count to set
  8160. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8161. */
  8162. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8163. /** @hidden */
  8164. /** @hidden */
  8165. /**
  8166. * Creates a new render target cube texture
  8167. * @param size defines the size of the texture
  8168. * @param options defines the options used to create the texture
  8169. * @returns a new render target cube texture stored in an InternalTexture
  8170. */
  8171. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8172. /**
  8173. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8174. * @param rootUrl defines the url where the file to load is located
  8175. * @param scene defines the current scene
  8176. * @param scale defines scale to apply to the mip map selection
  8177. * @param offset defines offset to apply to the mip map selection
  8178. * @param onLoad defines an optional callback raised when the texture is loaded
  8179. * @param onError defines an optional callback raised if there is an issue to load the texture
  8180. * @param format defines the format of the data
  8181. * @param forcedExtension defines the extension to use to pick the right loader
  8182. * @returns the cube texture as an InternalTexture
  8183. */
  8184. 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): InternalTexture;
  8185. /**
  8186. * Creates a cube texture
  8187. * @param rootUrl defines the url where the files to load is located
  8188. * @param scene defines the current scene
  8189. * @param files defines the list of files to load (1 per face)
  8190. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8191. * @param onLoad defines an optional callback raised when the texture is loaded
  8192. * @param onError defines an optional callback raised if there is an issue to load the texture
  8193. * @param format defines the format of the data
  8194. * @param forcedExtension defines the extension to use to pick the right loader
  8195. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8196. * @returns the cube texture as an InternalTexture
  8197. */
  8198. 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;
  8199. private setCubeMapTextureParams(gl, loadMipmap);
  8200. /**
  8201. * Update a raw cube texture
  8202. * @param texture defines the texture to udpdate
  8203. * @param data defines the data to store
  8204. * @param format defines the data format
  8205. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8206. * @param invertY defines if data must be stored with Y axis inverted
  8207. * @param compression defines the compression used (null by default)
  8208. * @param level defines which level of the texture to update
  8209. */
  8210. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8211. /**
  8212. * Creates a new raw cube texture
  8213. * @param data defines the array of data to use to create each face
  8214. * @param size defines the size of the textures
  8215. * @param format defines the format of the data
  8216. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8217. * @param generateMipMaps defines if the engine should generate the mip levels
  8218. * @param invertY defines if data must be stored with Y axis inverted
  8219. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8220. * @param compression defines the compression used (null by default)
  8221. * @returns the cube texture as an InternalTexture
  8222. */
  8223. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8224. /**
  8225. * Creates a new raw cube texture from a specified url
  8226. * @param url defines the url where the data is located
  8227. * @param scene defines the current scene
  8228. * @param size defines the size of the textures
  8229. * @param format defines the format of the data
  8230. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8231. * @param noMipmap defines if the engine should avoid generating the mip levels
  8232. * @param callback defines a callback used to extract texture data from loaded data
  8233. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8234. * @param onLoad defines a callback called when texture is loaded
  8235. * @param onError defines a callback called if there is an error
  8236. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8237. * @param invertY defines if data must be stored with Y axis inverted
  8238. * @returns the cube texture as an InternalTexture
  8239. */
  8240. 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;
  8241. /**
  8242. * Update a raw 3D texture
  8243. * @param texture defines the texture to update
  8244. * @param data defines the data to store
  8245. * @param format defines the data format
  8246. * @param invertY defines if data must be stored with Y axis inverted
  8247. * @param compression defines the used compression (can be null)
  8248. */
  8249. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8250. /**
  8251. * Creates a new raw 3D texture
  8252. * @param data defines the data used to create the texture
  8253. * @param width defines the width of the texture
  8254. * @param height defines the height of the texture
  8255. * @param depth defines the depth of the texture
  8256. * @param format defines the format of the texture
  8257. * @param generateMipMaps defines if the engine must generate mip levels
  8258. * @param invertY defines if data must be stored with Y axis inverted
  8259. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8260. * @param compression defines the compressed used (can be null)
  8261. * @returns a new raw 3D texture (stored in an InternalTexture)
  8262. */
  8263. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8264. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8265. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8266. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8267. /** @hidden */
  8268. /** @hidden */
  8269. private setProgram(program);
  8270. private _boundUniforms;
  8271. /**
  8272. * Binds an effect to the webGL context
  8273. * @param effect defines the effect to bind
  8274. */
  8275. bindSamplers(effect: Effect): void;
  8276. private _moveBoundTextureOnTop(internalTexture);
  8277. private _getCorrectTextureChannel(channel, internalTexture);
  8278. private _linkTrackers(previous, next);
  8279. private _removeDesignatedSlot(internalTexture);
  8280. private _activateCurrentTexture();
  8281. /** @hidden */
  8282. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8283. /** @hidden */
  8284. /**
  8285. * Sets a texture to the webGL context from a postprocess
  8286. * @param channel defines the channel to use
  8287. * @param postProcess defines the source postprocess
  8288. */
  8289. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8290. /**
  8291. * Binds the output of the passed in post process to the texture channel specified
  8292. * @param channel The channel the texture should be bound to
  8293. * @param postProcess The post process which's output should be bound
  8294. */
  8295. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8296. /**
  8297. * Unbind all textures from the webGL context
  8298. */
  8299. unbindAllTextures(): void;
  8300. /**
  8301. * Sets a texture to the according uniform.
  8302. * @param channel The texture channel
  8303. * @param uniform The uniform to set
  8304. * @param texture The texture to apply
  8305. */
  8306. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8307. /**
  8308. * Sets a depth stencil texture from a render target to the according uniform.
  8309. * @param channel The texture channel
  8310. * @param uniform The uniform to set
  8311. * @param texture The render target texture containing the depth stencil texture to apply
  8312. */
  8313. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8314. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8315. private _getTextureWrapMode(mode);
  8316. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8317. /**
  8318. * Sets an array of texture to the webGL context
  8319. * @param channel defines the channel where the texture array must be set
  8320. * @param uniform defines the associated uniform location
  8321. * @param textures defines the array of textures to bind
  8322. */
  8323. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8324. /** @hidden */
  8325. private _setTextureParameterFloat(target, parameter, value, texture);
  8326. private _setTextureParameterInteger(target, parameter, value, texture?);
  8327. /**
  8328. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8329. * @param x defines the x coordinate of the rectangle where pixels must be read
  8330. * @param y defines the y coordinate of the rectangle where pixels must be read
  8331. * @param width defines the width of the rectangle where pixels must be read
  8332. * @param height defines the height of the rectangle where pixels must be read
  8333. * @returns a Uint8Array containing RGBA colors
  8334. */
  8335. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8336. /**
  8337. * Add an externaly attached data from its key.
  8338. * This method call will fail and return false, if such key already exists.
  8339. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8340. * @param key the unique key that identifies the data
  8341. * @param data the data object to associate to the key for this Engine instance
  8342. * @return true if no such key were already present and the data was added successfully, false otherwise
  8343. */
  8344. addExternalData<T>(key: string, data: T): boolean;
  8345. /**
  8346. * Get an externaly attached data from its key
  8347. * @param key the unique key that identifies the data
  8348. * @return the associated data, if present (can be null), or undefined if not present
  8349. */
  8350. getExternalData<T>(key: string): T;
  8351. /**
  8352. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8353. * @param key the unique key that identifies the data
  8354. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8355. * @return the associated data, can be null if the factory returned null.
  8356. */
  8357. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8358. /**
  8359. * Remove an externaly attached data from the Engine instance
  8360. * @param key the unique key that identifies the data
  8361. * @return true if the data was successfully removed, false if it doesn't exist
  8362. */
  8363. removeExternalData(key: string): boolean;
  8364. /**
  8365. * Unbind all vertex attributes from the webGL context
  8366. */
  8367. unbindAllAttributes(): void;
  8368. /**
  8369. * 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
  8370. */
  8371. releaseEffects(): void;
  8372. /**
  8373. * Dispose and release all associated resources
  8374. */
  8375. dispose(): void;
  8376. /**
  8377. * Display the loading screen
  8378. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8379. */
  8380. displayLoadingUI(): void;
  8381. /**
  8382. * Hide the loading screen
  8383. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8384. */
  8385. hideLoadingUI(): void;
  8386. /**
  8387. * Gets the current loading screen object
  8388. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8389. */
  8390. /**
  8391. * Sets the current loading screen object
  8392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8393. */
  8394. loadingScreen: ILoadingScreen;
  8395. /**
  8396. * Sets the current loading screen text
  8397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8398. */
  8399. loadingUIText: string;
  8400. /**
  8401. * Sets the current loading screen background color
  8402. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8403. */
  8404. loadingUIBackgroundColor: string;
  8405. /**
  8406. * Attach a new callback raised when context lost event is fired
  8407. * @param callback defines the callback to call
  8408. */
  8409. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8410. /**
  8411. * Attach a new callback raised when context restored event is fired
  8412. * @param callback defines the callback to call
  8413. */
  8414. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8415. /**
  8416. * Gets the source code of the vertex shader associated with a specific webGL program
  8417. * @param program defines the program to use
  8418. * @returns a string containing the source code of the vertex shader associated with the program
  8419. */
  8420. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8421. /**
  8422. * Gets the source code of the fragment shader associated with a specific webGL program
  8423. * @param program defines the program to use
  8424. * @returns a string containing the source code of the fragment shader associated with the program
  8425. */
  8426. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8427. /**
  8428. * Get the current error code of the webGL context
  8429. * @returns the error code
  8430. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8431. */
  8432. getError(): number;
  8433. /**
  8434. * Gets the current framerate
  8435. * @returns a number representing the framerate
  8436. */
  8437. getFps(): number;
  8438. /**
  8439. * Gets the time spent between current and previous frame
  8440. * @returns a number representing the delta time in ms
  8441. */
  8442. getDeltaTime(): number;
  8443. private _measureFps();
  8444. /** @hidden */
  8445. private _canRenderToFloatFramebuffer();
  8446. private _canRenderToHalfFloatFramebuffer();
  8447. private _canRenderToFramebuffer(type);
  8448. /** @hidden */
  8449. private _getInternalFormat(format);
  8450. /** @hidden */
  8451. /** @hidden */
  8452. /**
  8453. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8454. * @return the new query
  8455. */
  8456. createQuery(): WebGLQuery;
  8457. /**
  8458. * Delete and release a webGL query
  8459. * @param query defines the query to delete
  8460. * @return the current engine
  8461. */
  8462. deleteQuery(query: WebGLQuery): Engine;
  8463. /**
  8464. * Check if a given query has resolved and got its value
  8465. * @param query defines the query to check
  8466. * @returns true if the query got its value
  8467. */
  8468. isQueryResultAvailable(query: WebGLQuery): boolean;
  8469. /**
  8470. * Gets the value of a given query
  8471. * @param query defines the query to check
  8472. * @returns the value of the query
  8473. */
  8474. getQueryResult(query: WebGLQuery): number;
  8475. /**
  8476. * Initiates an occlusion query
  8477. * @param algorithmType defines the algorithm to use
  8478. * @param query defines the query to use
  8479. * @returns the current engine
  8480. * @see http://doc.babylonjs.com/features/occlusionquery
  8481. */
  8482. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8483. /**
  8484. * Ends an occlusion query
  8485. * @see http://doc.babylonjs.com/features/occlusionquery
  8486. * @param algorithmType defines the algorithm to use
  8487. * @returns the current engine
  8488. */
  8489. endOcclusionQuery(algorithmType: number): Engine;
  8490. private _createTimeQuery();
  8491. private _deleteTimeQuery(query);
  8492. private _getTimeQueryResult(query);
  8493. private _getTimeQueryAvailability(query);
  8494. private _currentNonTimestampToken;
  8495. /**
  8496. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8497. * Please note that only one query can be issued at a time
  8498. * @returns a time token used to track the time span
  8499. */
  8500. startTimeQuery(): Nullable<_TimeToken>;
  8501. /**
  8502. * Ends a time query
  8503. * @param token defines the token used to measure the time span
  8504. * @returns the time spent (in ns)
  8505. */
  8506. endTimeQuery(token: _TimeToken): int;
  8507. private getGlAlgorithmType(algorithmType);
  8508. /**
  8509. * Creates a webGL transform feedback object
  8510. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8511. * @returns the webGL transform feedback object
  8512. */
  8513. createTransformFeedback(): WebGLTransformFeedback;
  8514. /**
  8515. * Delete a webGL transform feedback object
  8516. * @param value defines the webGL transform feedback object to delete
  8517. */
  8518. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8519. /**
  8520. * Bind a webGL transform feedback object to the webgl context
  8521. * @param value defines the webGL transform feedback object to bind
  8522. */
  8523. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8524. /**
  8525. * Begins a transform feedback operation
  8526. * @param usePoints defines if points or triangles must be used
  8527. */
  8528. beginTransformFeedback(usePoints?: boolean): void;
  8529. /**
  8530. * Ends a transform feedback operation
  8531. */
  8532. endTransformFeedback(): void;
  8533. /**
  8534. * Specify the varyings to use with transform feedback
  8535. * @param program defines the associated webGL program
  8536. * @param value defines the list of strings representing the varying names
  8537. */
  8538. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8539. /**
  8540. * Bind a webGL buffer for a transform feedback operation
  8541. * @param value defines the webGL buffer to bind
  8542. */
  8543. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8544. /** @hidden */
  8545. /** @hidden */
  8546. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8547. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8548. /**
  8549. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8550. * @returns true if the engine can be created
  8551. * @ignorenaming
  8552. */
  8553. static isSupported(): boolean;
  8554. }
  8555. }
  8556. declare module BABYLON {
  8557. class NullEngineOptions {
  8558. renderWidth: number;
  8559. renderHeight: number;
  8560. textureSize: number;
  8561. deterministicLockstep: boolean;
  8562. lockstepMaxSteps: number;
  8563. }
  8564. /**
  8565. * The null engine class provides support for headless version of babylon.js.
  8566. * This can be used in server side scenario or for testing purposes
  8567. */
  8568. class NullEngine extends Engine {
  8569. private _options;
  8570. isDeterministicLockStep(): boolean;
  8571. getLockstepMaxSteps(): number;
  8572. getHardwareScalingLevel(): number;
  8573. constructor(options?: NullEngineOptions);
  8574. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8575. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8576. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8577. getRenderWidth(useScreen?: boolean): number;
  8578. getRenderHeight(useScreen?: boolean): number;
  8579. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8580. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8581. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8582. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8583. bindSamplers(effect: Effect): void;
  8584. enableEffect(effect: Effect): void;
  8585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8586. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8587. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8588. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8589. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8590. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8591. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8592. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8593. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8594. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8595. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8596. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8597. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8598. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8599. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8600. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8601. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8602. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8603. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8604. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8605. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8606. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8607. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8608. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8609. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8610. bindBuffers(vertexBuffers: {
  8611. [key: string]: VertexBuffer;
  8612. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8613. wipeCaches(bruteForce?: boolean): void;
  8614. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8615. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8616. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8617. 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;
  8618. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8619. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8620. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8621. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8622. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8623. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8624. /**
  8625. * Updates a dynamic vertex buffer.
  8626. * @param vertexBuffer the vertex buffer to update
  8627. * @param data the data used to update the vertex buffer
  8628. * @param byteOffset the byte offset of the data (optional)
  8629. * @param byteLength the byte length of the data (optional)
  8630. */
  8631. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8632. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8633. releaseEffects(): void;
  8634. }
  8635. }
  8636. interface WebGLRenderingContext {
  8637. readonly RASTERIZER_DISCARD: number;
  8638. readonly DEPTH_COMPONENT24: number;
  8639. readonly TEXTURE_3D: number;
  8640. readonly TEXTURE_2D_ARRAY: number;
  8641. readonly TEXTURE_COMPARE_FUNC: number;
  8642. readonly TEXTURE_COMPARE_MODE: number;
  8643. readonly COMPARE_REF_TO_TEXTURE: number;
  8644. readonly TEXTURE_WRAP_R: number;
  8645. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8646. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8647. 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;
  8648. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8649. readonly TRANSFORM_FEEDBACK: number;
  8650. readonly INTERLEAVED_ATTRIBS: number;
  8651. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8652. createTransformFeedback(): WebGLTransformFeedback;
  8653. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8654. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8655. beginTransformFeedback(primitiveMode: number): void;
  8656. endTransformFeedback(): void;
  8657. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8658. }
  8659. interface ImageBitmap {
  8660. readonly width: number;
  8661. readonly height: number;
  8662. close(): void;
  8663. }
  8664. interface WebGLQuery extends WebGLObject {
  8665. }
  8666. declare var WebGLQuery: {
  8667. prototype: WebGLQuery;
  8668. new (): WebGLQuery;
  8669. };
  8670. interface WebGLSampler extends WebGLObject {
  8671. }
  8672. declare var WebGLSampler: {
  8673. prototype: WebGLSampler;
  8674. new (): WebGLSampler;
  8675. };
  8676. interface WebGLSync extends WebGLObject {
  8677. }
  8678. declare var WebGLSync: {
  8679. prototype: WebGLSync;
  8680. new (): WebGLSync;
  8681. };
  8682. interface WebGLTransformFeedback extends WebGLObject {
  8683. }
  8684. declare var WebGLTransformFeedback: {
  8685. prototype: WebGLTransformFeedback;
  8686. new (): WebGLTransformFeedback;
  8687. };
  8688. interface WebGLVertexArrayObject extends WebGLObject {
  8689. }
  8690. declare var WebGLVertexArrayObject: {
  8691. prototype: WebGLVertexArrayObject;
  8692. new (): WebGLVertexArrayObject;
  8693. };
  8694. /**
  8695. * Module Debug contains the (visual) components to debug a scene correctly
  8696. */
  8697. declare module BABYLON.Debug {
  8698. /**
  8699. * The Axes viewer will show 3 axes in a specific point in space
  8700. */
  8701. class AxesViewer {
  8702. private _xline;
  8703. private _yline;
  8704. private _zline;
  8705. private _xmesh;
  8706. private _ymesh;
  8707. private _zmesh;
  8708. scene: Nullable<Scene>;
  8709. scaleLines: number;
  8710. constructor(scene: Scene, scaleLines?: number);
  8711. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8712. dispose(): void;
  8713. }
  8714. }
  8715. declare module BABYLON.Debug {
  8716. /**
  8717. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8718. */
  8719. class BoneAxesViewer extends AxesViewer {
  8720. mesh: Nullable<Mesh>;
  8721. bone: Nullable<Bone>;
  8722. pos: Vector3;
  8723. xaxis: Vector3;
  8724. yaxis: Vector3;
  8725. zaxis: Vector3;
  8726. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8727. update(): void;
  8728. dispose(): void;
  8729. }
  8730. }
  8731. declare module BABYLON {
  8732. class DebugLayer {
  8733. private _scene;
  8734. static InspectorURL: string;
  8735. private _inspector;
  8736. private BJSINSPECTOR;
  8737. constructor(scene: Scene);
  8738. /** Creates the inspector window. */
  8739. private _createInspector(config?);
  8740. isVisible(): boolean;
  8741. hide(): void;
  8742. show(config?: {
  8743. popup?: boolean;
  8744. initialTab?: number;
  8745. parentElement?: HTMLElement;
  8746. newColors?: {
  8747. backgroundColor?: string;
  8748. backgroundColorLighter?: string;
  8749. backgroundColorLighter2?: string;
  8750. backgroundColorLighter3?: string;
  8751. color?: string;
  8752. colorTop?: string;
  8753. colorBot?: string;
  8754. };
  8755. }): void;
  8756. }
  8757. }
  8758. declare module BABYLON.Debug {
  8759. /**
  8760. * Used to show the physics impostor around the specific mesh.
  8761. */
  8762. class PhysicsViewer {
  8763. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8764. protected _meshes: Array<Nullable<AbstractMesh>>;
  8765. protected _scene: Nullable<Scene>;
  8766. protected _numMeshes: number;
  8767. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8768. private _renderFunction;
  8769. private _debugBoxMesh;
  8770. private _debugSphereMesh;
  8771. private _debugMaterial;
  8772. constructor(scene: Scene);
  8773. protected _updateDebugMeshes(): void;
  8774. showImpostor(impostor: PhysicsImpostor): void;
  8775. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8776. private _getDebugMaterial(scene);
  8777. private _getDebugBoxMesh(scene);
  8778. private _getDebugSphereMesh(scene);
  8779. private _getDebugMesh(impostor, scene);
  8780. dispose(): void;
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. class RayHelper {
  8785. ray: Nullable<Ray>;
  8786. private _renderPoints;
  8787. private _renderLine;
  8788. private _renderFunction;
  8789. private _scene;
  8790. private _updateToMeshFunction;
  8791. private _attachedToMesh;
  8792. private _meshSpaceDirection;
  8793. private _meshSpaceOrigin;
  8794. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8795. constructor(ray: Ray);
  8796. show(scene: Scene, color: Color3): void;
  8797. hide(): void;
  8798. private _render();
  8799. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  8800. detachFromMesh(): void;
  8801. private _updateToMesh();
  8802. dispose(): void;
  8803. }
  8804. }
  8805. declare module BABYLON.Debug {
  8806. /**
  8807. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  8808. */
  8809. class SkeletonViewer {
  8810. skeleton: Skeleton;
  8811. mesh: AbstractMesh;
  8812. autoUpdateBonesMatrices: boolean;
  8813. renderingGroupId: number;
  8814. color: Color3;
  8815. private _scene;
  8816. private _debugLines;
  8817. private _debugMesh;
  8818. private _isEnabled;
  8819. private _renderFunction;
  8820. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  8821. isEnabled: boolean;
  8822. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  8823. private _getLinesForBonesWithLength(bones, meshMat);
  8824. private _getLinesForBonesNoLength(bones, meshMat);
  8825. update(): void;
  8826. dispose(): void;
  8827. }
  8828. }
  8829. declare module BABYLON {
  8830. class KeyboardEventTypes {
  8831. private static _KEYDOWN: number;
  8832. private static _KEYUP: number;
  8833. static readonly KEYDOWN: number;
  8834. static readonly KEYUP: number;
  8835. }
  8836. class KeyboardInfo {
  8837. type: number;
  8838. event: KeyboardEvent;
  8839. constructor(type: number, event: KeyboardEvent);
  8840. }
  8841. /**
  8842. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8843. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8844. */
  8845. class KeyboardInfoPre extends KeyboardInfo {
  8846. constructor(type: number, event: KeyboardEvent);
  8847. skipOnPointerObservable: boolean;
  8848. }
  8849. }
  8850. declare module BABYLON {
  8851. class PointerEventTypes {
  8852. private static _POINTERDOWN: number;
  8853. private static _POINTERUP: number;
  8854. private static _POINTERMOVE: number;
  8855. private static _POINTERWHEEL: number;
  8856. private static _POINTERPICK: number;
  8857. private static _POINTERTAP: number;
  8858. private static _POINTERDOUBLETAP: number;
  8859. static readonly POINTERDOWN: number;
  8860. static readonly POINTERUP: number;
  8861. static readonly POINTERMOVE: number;
  8862. static readonly POINTERWHEEL: number;
  8863. static readonly POINTERPICK: number;
  8864. static readonly POINTERTAP: number;
  8865. static readonly POINTERDOUBLETAP: number;
  8866. }
  8867. class PointerInfoBase {
  8868. type: number;
  8869. event: PointerEvent | MouseWheelEvent;
  8870. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  8871. }
  8872. /**
  8873. * This class is used to store pointer related info for the onPrePointerObservable event.
  8874. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8875. */
  8876. class PointerInfoPre extends PointerInfoBase {
  8877. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8878. localPosition: Vector2;
  8879. skipOnPointerObservable: boolean;
  8880. }
  8881. /**
  8882. * This type contains all the data related to a pointer event in Babylon.js.
  8883. * 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.
  8884. */
  8885. class PointerInfo extends PointerInfoBase {
  8886. pickInfo: Nullable<PickingInfo>;
  8887. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  8888. }
  8889. }
  8890. declare module BABYLON {
  8891. /**
  8892. * This class can be used to get instrumentation data from a Babylon engine
  8893. */
  8894. class EngineInstrumentation implements IDisposable {
  8895. engine: Engine;
  8896. private _captureGPUFrameTime;
  8897. private _gpuFrameTimeToken;
  8898. private _gpuFrameTime;
  8899. private _captureShaderCompilationTime;
  8900. private _shaderCompilationTime;
  8901. private _onBeginFrameObserver;
  8902. private _onEndFrameObserver;
  8903. private _onBeforeShaderCompilationObserver;
  8904. private _onAfterShaderCompilationObserver;
  8905. /**
  8906. * Gets the perf counter used for GPU frame time
  8907. */
  8908. readonly gpuFrameTimeCounter: PerfCounter;
  8909. /**
  8910. * Gets the GPU frame time capture status
  8911. */
  8912. /**
  8913. * Enable or disable the GPU frame time capture
  8914. */
  8915. captureGPUFrameTime: boolean;
  8916. /**
  8917. * Gets the perf counter used for shader compilation time
  8918. */
  8919. readonly shaderCompilationTimeCounter: PerfCounter;
  8920. /**
  8921. * Gets the shader compilation time capture status
  8922. */
  8923. /**
  8924. * Enable or disable the shader compilation time capture
  8925. */
  8926. captureShaderCompilationTime: boolean;
  8927. constructor(engine: Engine);
  8928. dispose(): void;
  8929. }
  8930. }
  8931. declare module BABYLON {
  8932. /**
  8933. * This class can be used to get instrumentation data from a Babylon engine
  8934. */
  8935. class SceneInstrumentation implements IDisposable {
  8936. scene: Scene;
  8937. private _captureActiveMeshesEvaluationTime;
  8938. private _activeMeshesEvaluationTime;
  8939. private _captureRenderTargetsRenderTime;
  8940. private _renderTargetsRenderTime;
  8941. private _captureFrameTime;
  8942. private _frameTime;
  8943. private _captureRenderTime;
  8944. private _renderTime;
  8945. private _captureInterFrameTime;
  8946. private _interFrameTime;
  8947. private _captureParticlesRenderTime;
  8948. private _particlesRenderTime;
  8949. private _captureSpritesRenderTime;
  8950. private _spritesRenderTime;
  8951. private _capturePhysicsTime;
  8952. private _physicsTime;
  8953. private _captureAnimationsTime;
  8954. private _animationsTime;
  8955. private _onBeforeActiveMeshesEvaluationObserver;
  8956. private _onAfterActiveMeshesEvaluationObserver;
  8957. private _onBeforeRenderTargetsRenderObserver;
  8958. private _onAfterRenderTargetsRenderObserver;
  8959. private _onAfterRenderObserver;
  8960. private _onBeforeDrawPhaseObserver;
  8961. private _onAfterDrawPhaseObserver;
  8962. private _onBeforeAnimationsObserver;
  8963. private _onBeforeParticlesRenderingObserver;
  8964. private _onAfterParticlesRenderingObserver;
  8965. private _onBeforeSpritesRenderingObserver;
  8966. private _onAfterSpritesRenderingObserver;
  8967. private _onBeforePhysicsObserver;
  8968. private _onAfterPhysicsObserver;
  8969. private _onAfterAnimationsObserver;
  8970. /**
  8971. * Gets the perf counter used for active meshes evaluation time
  8972. */
  8973. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  8974. /**
  8975. * Gets the active meshes evaluation time capture status
  8976. */
  8977. /**
  8978. * Enable or disable the active meshes evaluation time capture
  8979. */
  8980. captureActiveMeshesEvaluationTime: boolean;
  8981. /**
  8982. * Gets the perf counter used for render targets render time
  8983. */
  8984. readonly renderTargetsRenderTimeCounter: PerfCounter;
  8985. /**
  8986. * Gets the render targets render time capture status
  8987. */
  8988. /**
  8989. * Enable or disable the render targets render time capture
  8990. */
  8991. captureRenderTargetsRenderTime: boolean;
  8992. /**
  8993. * Gets the perf counter used for particles render time
  8994. */
  8995. readonly particlesRenderTimeCounter: PerfCounter;
  8996. /**
  8997. * Gets the particles render time capture status
  8998. */
  8999. /**
  9000. * Enable or disable the particles render time capture
  9001. */
  9002. captureParticlesRenderTime: boolean;
  9003. /**
  9004. * Gets the perf counter used for sprites render time
  9005. */
  9006. readonly spritesRenderTimeCounter: PerfCounter;
  9007. /**
  9008. * Gets the sprites render time capture status
  9009. */
  9010. /**
  9011. * Enable or disable the sprites render time capture
  9012. */
  9013. captureSpritesRenderTime: boolean;
  9014. /**
  9015. * Gets the perf counter used for physics time
  9016. */
  9017. readonly physicsTimeCounter: PerfCounter;
  9018. /**
  9019. * Gets the physics time capture status
  9020. */
  9021. /**
  9022. * Enable or disable the physics time capture
  9023. */
  9024. capturePhysicsTime: boolean;
  9025. /**
  9026. * Gets the perf counter used for animations time
  9027. */
  9028. readonly animationsTimeCounter: PerfCounter;
  9029. /**
  9030. * Gets the animations time capture status
  9031. */
  9032. /**
  9033. * Enable or disable the animations time capture
  9034. */
  9035. captureAnimationsTime: boolean;
  9036. /**
  9037. * Gets the perf counter used for frame time capture
  9038. */
  9039. readonly frameTimeCounter: PerfCounter;
  9040. /**
  9041. * Gets the frame time capture status
  9042. */
  9043. /**
  9044. * Enable or disable the frame time capture
  9045. */
  9046. captureFrameTime: boolean;
  9047. /**
  9048. * Gets the perf counter used for inter-frames time capture
  9049. */
  9050. readonly interFrameTimeCounter: PerfCounter;
  9051. /**
  9052. * Gets the inter-frames time capture status
  9053. */
  9054. /**
  9055. * Enable or disable the inter-frames time capture
  9056. */
  9057. captureInterFrameTime: boolean;
  9058. /**
  9059. * Gets the perf counter used for render time capture
  9060. */
  9061. readonly renderTimeCounter: PerfCounter;
  9062. /**
  9063. * Gets the render time capture status
  9064. */
  9065. /**
  9066. * Enable or disable the render time capture
  9067. */
  9068. captureRenderTime: boolean;
  9069. /**
  9070. * Gets the perf counter used for draw calls
  9071. */
  9072. readonly drawCallsCounter: PerfCounter;
  9073. /**
  9074. * Gets the perf counter used for texture collisions
  9075. */
  9076. readonly textureCollisionsCounter: PerfCounter;
  9077. constructor(scene: Scene);
  9078. dispose(): void;
  9079. }
  9080. }
  9081. declare module BABYLON {
  9082. /**
  9083. * @hidden
  9084. **/
  9085. class _TimeToken {
  9086. }
  9087. }
  9088. declare module BABYLON {
  9089. /**
  9090. * Represents the different options available during the creation of
  9091. * a Environment helper.
  9092. *
  9093. * This can control the default ground, skybox and image processing setup of your scene.
  9094. */
  9095. interface IEnvironmentHelperOptions {
  9096. /**
  9097. * Specifies wether or not to create a ground.
  9098. * True by default.
  9099. */
  9100. createGround: boolean;
  9101. /**
  9102. * Specifies the ground size.
  9103. * 15 by default.
  9104. */
  9105. groundSize: number;
  9106. /**
  9107. * The texture used on the ground for the main color.
  9108. * Comes from the BabylonJS CDN by default.
  9109. *
  9110. * Remarks: Can be either a texture or a url.
  9111. */
  9112. groundTexture: string | BaseTexture;
  9113. /**
  9114. * The color mixed in the ground texture by default.
  9115. * BabylonJS clearColor by default.
  9116. */
  9117. groundColor: Color3;
  9118. /**
  9119. * Specifies the ground opacity.
  9120. * 1 by default.
  9121. */
  9122. groundOpacity: number;
  9123. /**
  9124. * Enables the ground to receive shadows.
  9125. * True by default.
  9126. */
  9127. enableGroundShadow: boolean;
  9128. /**
  9129. * Helps preventing the shadow to be fully black on the ground.
  9130. * 0.5 by default.
  9131. */
  9132. groundShadowLevel: number;
  9133. /**
  9134. * Creates a mirror texture attach to the ground.
  9135. * false by default.
  9136. */
  9137. enableGroundMirror: boolean;
  9138. /**
  9139. * Specifies the ground mirror size ratio.
  9140. * 0.3 by default as the default kernel is 64.
  9141. */
  9142. groundMirrorSizeRatio: number;
  9143. /**
  9144. * Specifies the ground mirror blur kernel size.
  9145. * 64 by default.
  9146. */
  9147. groundMirrorBlurKernel: number;
  9148. /**
  9149. * Specifies the ground mirror visibility amount.
  9150. * 1 by default
  9151. */
  9152. groundMirrorAmount: number;
  9153. /**
  9154. * Specifies the ground mirror reflectance weight.
  9155. * This uses the standard weight of the background material to setup the fresnel effect
  9156. * of the mirror.
  9157. * 1 by default.
  9158. */
  9159. groundMirrorFresnelWeight: number;
  9160. /**
  9161. * Specifies the ground mirror Falloff distance.
  9162. * This can helps reducing the size of the reflection.
  9163. * 0 by Default.
  9164. */
  9165. groundMirrorFallOffDistance: number;
  9166. /**
  9167. * Specifies the ground mirror texture type.
  9168. * Unsigned Int by Default.
  9169. */
  9170. groundMirrorTextureType: number;
  9171. /**
  9172. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9173. * the shown objects.
  9174. */
  9175. groundYBias: number;
  9176. /**
  9177. * Specifies wether or not to create a skybox.
  9178. * True by default.
  9179. */
  9180. createSkybox: boolean;
  9181. /**
  9182. * Specifies the skybox size.
  9183. * 20 by default.
  9184. */
  9185. skyboxSize: number;
  9186. /**
  9187. * The texture used on the skybox for the main color.
  9188. * Comes from the BabylonJS CDN by default.
  9189. *
  9190. * Remarks: Can be either a texture or a url.
  9191. */
  9192. skyboxTexture: string | BaseTexture;
  9193. /**
  9194. * The color mixed in the skybox texture by default.
  9195. * BabylonJS clearColor by default.
  9196. */
  9197. skyboxColor: Color3;
  9198. /**
  9199. * The background rotation around the Y axis of the scene.
  9200. * This helps aligning the key lights of your scene with the background.
  9201. * 0 by default.
  9202. */
  9203. backgroundYRotation: number;
  9204. /**
  9205. * Compute automatically the size of the elements to best fit with the scene.
  9206. */
  9207. sizeAuto: boolean;
  9208. /**
  9209. * Default position of the rootMesh if autoSize is not true.
  9210. */
  9211. rootPosition: Vector3;
  9212. /**
  9213. * Sets up the image processing in the scene.
  9214. * true by default.
  9215. */
  9216. setupImageProcessing: boolean;
  9217. /**
  9218. * The texture used as your environment texture in the scene.
  9219. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9220. *
  9221. * Remarks: Can be either a texture or a url.
  9222. */
  9223. environmentTexture: string | BaseTexture;
  9224. /**
  9225. * The value of the exposure to apply to the scene.
  9226. * 0.6 by default if setupImageProcessing is true.
  9227. */
  9228. cameraExposure: number;
  9229. /**
  9230. * The value of the contrast to apply to the scene.
  9231. * 1.6 by default if setupImageProcessing is true.
  9232. */
  9233. cameraContrast: number;
  9234. /**
  9235. * Specifies wether or not tonemapping should be enabled in the scene.
  9236. * true by default if setupImageProcessing is true.
  9237. */
  9238. toneMappingEnabled: boolean;
  9239. }
  9240. /**
  9241. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9242. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9243. * It also helps with the default setup of your imageProcessing configuration.
  9244. */
  9245. class EnvironmentHelper {
  9246. /**
  9247. * Default ground texture URL.
  9248. */
  9249. private static _groundTextureCDNUrl;
  9250. /**
  9251. * Default skybox texture URL.
  9252. */
  9253. private static _skyboxTextureCDNUrl;
  9254. /**
  9255. * Default environment texture URL.
  9256. */
  9257. private static _environmentTextureCDNUrl;
  9258. /**
  9259. * Creates the default options for the helper.
  9260. */
  9261. private static _getDefaultOptions();
  9262. private _rootMesh;
  9263. /**
  9264. * Gets the root mesh created by the helper.
  9265. */
  9266. readonly rootMesh: Mesh;
  9267. private _skybox;
  9268. /**
  9269. * Gets the skybox created by the helper.
  9270. */
  9271. readonly skybox: Nullable<Mesh>;
  9272. private _skyboxTexture;
  9273. /**
  9274. * Gets the skybox texture created by the helper.
  9275. */
  9276. readonly skyboxTexture: Nullable<BaseTexture>;
  9277. private _skyboxMaterial;
  9278. /**
  9279. * Gets the skybox material created by the helper.
  9280. */
  9281. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9282. private _ground;
  9283. /**
  9284. * Gets the ground mesh created by the helper.
  9285. */
  9286. readonly ground: Nullable<Mesh>;
  9287. private _groundTexture;
  9288. /**
  9289. * Gets the ground texture created by the helper.
  9290. */
  9291. readonly groundTexture: Nullable<BaseTexture>;
  9292. private _groundMirror;
  9293. /**
  9294. * Gets the ground mirror created by the helper.
  9295. */
  9296. readonly groundMirror: Nullable<MirrorTexture>;
  9297. /**
  9298. * Gets the ground mirror render list to helps pushing the meshes
  9299. * you wish in the ground reflection.
  9300. */
  9301. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9302. private _groundMaterial;
  9303. /**
  9304. * Gets the ground material created by the helper.
  9305. */
  9306. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9307. /**
  9308. * Stores the creation options.
  9309. */
  9310. private readonly _scene;
  9311. private _options;
  9312. /**
  9313. * This observable will be notified with any error during the creation of the environment,
  9314. * mainly texture creation errors.
  9315. */
  9316. onErrorObservable: Observable<{
  9317. message?: string;
  9318. exception?: any;
  9319. }>;
  9320. /**
  9321. * constructor
  9322. * @param options
  9323. * @param scene The scene to add the material to
  9324. */
  9325. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9326. /**
  9327. * Updates the background according to the new options
  9328. * @param options
  9329. */
  9330. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9331. /**
  9332. * Sets the primary color of all the available elements.
  9333. * @param color the main color to affect to the ground and the background
  9334. */
  9335. setMainColor(color: Color3): void;
  9336. /**
  9337. * Setup the image processing according to the specified options.
  9338. */
  9339. private _setupImageProcessing();
  9340. /**
  9341. * Setup the environment texture according to the specified options.
  9342. */
  9343. private _setupEnvironmentTexture();
  9344. /**
  9345. * Setup the background according to the specified options.
  9346. */
  9347. private _setupBackground();
  9348. /**
  9349. * Get the scene sizes according to the setup.
  9350. */
  9351. private _getSceneSize();
  9352. /**
  9353. * Setup the ground according to the specified options.
  9354. */
  9355. private _setupGround(sceneSize);
  9356. /**
  9357. * Setup the ground material according to the specified options.
  9358. */
  9359. private _setupGroundMaterial();
  9360. /**
  9361. * Setup the ground diffuse texture according to the specified options.
  9362. */
  9363. private _setupGroundDiffuseTexture();
  9364. /**
  9365. * Setup the ground mirror texture according to the specified options.
  9366. */
  9367. private _setupGroundMirrorTexture(sceneSize);
  9368. /**
  9369. * Setup the ground to receive the mirror texture.
  9370. */
  9371. private _setupMirrorInGroundMaterial();
  9372. /**
  9373. * Setup the skybox according to the specified options.
  9374. */
  9375. private _setupSkybox(sceneSize);
  9376. /**
  9377. * Setup the skybox material according to the specified options.
  9378. */
  9379. private _setupSkyboxMaterial();
  9380. /**
  9381. * Setup the skybox reflection texture according to the specified options.
  9382. */
  9383. private _setupSkyboxReflectionTexture();
  9384. private _errorHandler;
  9385. /**
  9386. * Dispose all the elements created by the Helper.
  9387. */
  9388. dispose(): void;
  9389. }
  9390. }
  9391. declare module BABYLON {
  9392. /**
  9393. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9394. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9395. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9396. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9397. */
  9398. class VideoDome extends Node {
  9399. /**
  9400. * The video texture being displayed on the sphere
  9401. */
  9402. protected _videoTexture: VideoTexture;
  9403. /**
  9404. * The skybox material
  9405. */
  9406. protected _material: BackgroundMaterial;
  9407. /**
  9408. * The surface used for the skybox
  9409. */
  9410. protected _mesh: Mesh;
  9411. /**
  9412. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9413. * Also see the options.resolution property.
  9414. */
  9415. fovMultiplier: number;
  9416. /**
  9417. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9418. * @param name Element's name, child elements will append suffixes for their own names.
  9419. * @param urlsOrVideo
  9420. * @param options An object containing optional or exposed sub element properties:
  9421. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9422. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9423. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9424. * @param options **loop=true** Automatically loop video on end.
  9425. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9426. */
  9427. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9428. resolution?: number;
  9429. clickToPlay?: boolean;
  9430. autoPlay?: boolean;
  9431. loop?: boolean;
  9432. size?: number;
  9433. }, scene: Scene);
  9434. /**
  9435. * Releases resources associated with this node.
  9436. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9437. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9438. */
  9439. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * Effect layer options. This helps customizing the behaviour
  9445. * of the effect layer.
  9446. */
  9447. interface IEffectLayerOptions {
  9448. /**
  9449. * Multiplication factor apply to the canvas size to compute the render target size
  9450. * used to generated the objects (the smaller the faster).
  9451. */
  9452. mainTextureRatio: number;
  9453. /**
  9454. * Enforces a fixed size texture to ensure effect stability across devices.
  9455. */
  9456. mainTextureFixedSize?: number;
  9457. /**
  9458. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9459. */
  9460. alphaBlendingMode: number;
  9461. /**
  9462. * The camera attached to the layer.
  9463. */
  9464. camera: Nullable<Camera>;
  9465. }
  9466. /**
  9467. * The effect layer Helps adding post process effect blended with the main pass.
  9468. *
  9469. * This can be for instance use to generate glow or higlight effects on the scene.
  9470. *
  9471. * The effect layer class can not be used directly and is intented to inherited from to be
  9472. * customized per effects.
  9473. */
  9474. abstract class EffectLayer {
  9475. private _vertexBuffers;
  9476. private _indexBuffer;
  9477. private _cachedDefines;
  9478. private _effectLayerMapGenerationEffect;
  9479. private _effectLayerOptions;
  9480. private _mergeEffect;
  9481. protected _scene: Scene;
  9482. protected _engine: Engine;
  9483. protected _maxSize: number;
  9484. protected _mainTextureDesiredSize: ISize;
  9485. protected _mainTexture: RenderTargetTexture;
  9486. protected _shouldRender: boolean;
  9487. protected _postProcesses: PostProcess[];
  9488. protected _textures: BaseTexture[];
  9489. protected _emissiveTextureAndColor: {
  9490. texture: Nullable<BaseTexture>;
  9491. color: Color4;
  9492. };
  9493. /**
  9494. * The name of the layer
  9495. */
  9496. name: string;
  9497. /**
  9498. * The clear color of the texture used to generate the glow map.
  9499. */
  9500. neutralColor: Color4;
  9501. /**
  9502. * Specifies wether the highlight layer is enabled or not.
  9503. */
  9504. isEnabled: boolean;
  9505. /**
  9506. * Gets the camera attached to the layer.
  9507. */
  9508. readonly camera: Nullable<Camera>;
  9509. /**
  9510. * An event triggered when the effect layer has been disposed.
  9511. */
  9512. onDisposeObservable: Observable<EffectLayer>;
  9513. /**
  9514. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9515. */
  9516. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9517. /**
  9518. * An event triggered when the generated texture is being merged in the scene.
  9519. */
  9520. onBeforeComposeObservable: Observable<EffectLayer>;
  9521. /**
  9522. * An event triggered when the generated texture has been merged in the scene.
  9523. */
  9524. onAfterComposeObservable: Observable<EffectLayer>;
  9525. /**
  9526. * An event triggered when the efffect layer changes its size.
  9527. */
  9528. onSizeChangedObservable: Observable<EffectLayer>;
  9529. /**
  9530. * Instantiates a new effect Layer and references it in the scene.
  9531. * @param name The name of the layer
  9532. * @param scene The scene to use the layer in
  9533. */
  9534. constructor(
  9535. /** The Friendly of the effect in the scene */
  9536. name: string, scene: Scene);
  9537. /**
  9538. * Get the effect name of the layer.
  9539. * @return The effect name
  9540. */
  9541. abstract getEffectName(): string;
  9542. /**
  9543. * Checks for the readiness of the element composing the layer.
  9544. * @param subMesh the mesh to check for
  9545. * @param useInstances specify wether or not to use instances to render the mesh
  9546. * @return true if ready otherwise, false
  9547. */
  9548. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9549. /**
  9550. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9551. * @returns true if the effect requires stencil during the main canvas render pass.
  9552. */
  9553. abstract needStencil(): boolean;
  9554. /**
  9555. * Create the merge effect. This is the shader use to blit the information back
  9556. * to the main canvas at the end of the scene rendering.
  9557. * @returns The effect containing the shader used to merge the effect on the main canvas
  9558. */
  9559. protected abstract _createMergeEffect(): Effect;
  9560. /**
  9561. * Creates the render target textures and post processes used in the effect layer.
  9562. */
  9563. protected abstract _createTextureAndPostProcesses(): void;
  9564. /**
  9565. * Implementation specific of rendering the generating effect on the main canvas.
  9566. * @param effect The effect used to render through
  9567. */
  9568. protected abstract _internalRender(effect: Effect): void;
  9569. /**
  9570. * Sets the required values for both the emissive texture and and the main color.
  9571. */
  9572. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9573. /**
  9574. * Free any resources and references associated to a mesh.
  9575. * Internal use
  9576. * @param mesh The mesh to free.
  9577. */
  9578. disposeMesh(mesh: Mesh): void;
  9579. /**
  9580. * Serializes this layer (Glow or Highlight for example)
  9581. * @returns a serialized layer object
  9582. */
  9583. abstract serialize?(): any;
  9584. /**
  9585. * Initializes the effect layer with the required options.
  9586. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  9587. */
  9588. protected _init(options: Partial<IEffectLayerOptions>): void;
  9589. /**
  9590. * Generates the index buffer of the full screen quad blending to the main canvas.
  9591. */
  9592. private _generateIndexBuffer();
  9593. /**
  9594. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  9595. */
  9596. private _genrateVertexBuffer();
  9597. /**
  9598. * Sets the main texture desired size which is the closest power of two
  9599. * of the engine canvas size.
  9600. */
  9601. private _setMainTextureSize();
  9602. /**
  9603. * Creates the main texture for the effect layer.
  9604. */
  9605. protected _createMainTexture(): void;
  9606. /**
  9607. * Checks for the readiness of the element composing the layer.
  9608. * @param subMesh the mesh to check for
  9609. * @param useInstances specify wether or not to use instances to render the mesh
  9610. * @param emissiveTexture the associated emissive texture used to generate the glow
  9611. * @return true if ready otherwise, false
  9612. */
  9613. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  9614. /**
  9615. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  9616. */
  9617. render(): void;
  9618. /**
  9619. * Determine if a given mesh will be used in the current effect.
  9620. * @param mesh mesh to test
  9621. * @returns true if the mesh will be used
  9622. */
  9623. hasMesh(mesh: AbstractMesh): boolean;
  9624. /**
  9625. * Returns true if the layer contains information to display, otherwise false.
  9626. * @returns true if the glow layer should be rendered
  9627. */
  9628. shouldRender(): boolean;
  9629. /**
  9630. * Returns true if the mesh should render, otherwise false.
  9631. * @param mesh The mesh to render
  9632. * @returns true if it should render otherwise false
  9633. */
  9634. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9635. /**
  9636. * Returns true if the mesh should render, otherwise false.
  9637. * @param mesh The mesh to render
  9638. * @returns true if it should render otherwise false
  9639. */
  9640. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  9641. /**
  9642. * Renders the submesh passed in parameter to the generation map.
  9643. */
  9644. protected _renderSubMesh(subMesh: SubMesh): void;
  9645. /**
  9646. * Rebuild the required buffers.
  9647. * @hidden Internal use only.
  9648. */
  9649. /**
  9650. * Dispose only the render target textures and post process.
  9651. */
  9652. private _disposeTextureAndPostProcesses();
  9653. /**
  9654. * Dispose the highlight layer and free resources.
  9655. */
  9656. dispose(): void;
  9657. /**
  9658. * Gets the class name of the effect layer
  9659. * @returns the string with the class name of the effect layer
  9660. */
  9661. getClassName(): string;
  9662. /**
  9663. * Creates an effect layer from parsed effect layer data
  9664. * @param parsedEffectLayer defines effect layer data
  9665. * @param scene defines the current scene
  9666. * @param rootUrl defines the root URL containing the effect layer information
  9667. * @returns a parsed effect Layer
  9668. */
  9669. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  9670. }
  9671. }
  9672. declare module BABYLON {
  9673. /**
  9674. * Glow layer options. This helps customizing the behaviour
  9675. * of the glow layer.
  9676. */
  9677. interface IGlowLayerOptions {
  9678. /**
  9679. * Multiplication factor apply to the canvas size to compute the render target size
  9680. * used to generated the glowing objects (the smaller the faster).
  9681. */
  9682. mainTextureRatio: number;
  9683. /**
  9684. * Enforces a fixed size texture to ensure resize independant blur.
  9685. */
  9686. mainTextureFixedSize?: number;
  9687. /**
  9688. * How big is the kernel of the blur texture.
  9689. */
  9690. blurKernelSize: number;
  9691. /**
  9692. * The camera attached to the layer.
  9693. */
  9694. camera: Nullable<Camera>;
  9695. /**
  9696. * Enable MSAA by chosing the number of samples.
  9697. */
  9698. mainTextureSamples?: number;
  9699. }
  9700. /**
  9701. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  9702. *
  9703. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  9704. * glowy meshes to your scene.
  9705. *
  9706. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  9707. */
  9708. class GlowLayer extends EffectLayer {
  9709. /**
  9710. * Effect Name of the layer.
  9711. */
  9712. static readonly EffectName: string;
  9713. /**
  9714. * The default blur kernel size used for the glow.
  9715. */
  9716. static DefaultBlurKernelSize: number;
  9717. /**
  9718. * The default texture size ratio used for the glow.
  9719. */
  9720. static DefaultTextureRatio: number;
  9721. /**
  9722. * Gets the kernel size of the blur.
  9723. */
  9724. /**
  9725. * Sets the kernel size of the blur.
  9726. */
  9727. blurKernelSize: number;
  9728. /**
  9729. * Gets the glow intensity.
  9730. */
  9731. /**
  9732. * Sets the glow intensity.
  9733. */
  9734. intensity: number;
  9735. private _options;
  9736. private _intensity;
  9737. private _horizontalBlurPostprocess1;
  9738. private _verticalBlurPostprocess1;
  9739. private _horizontalBlurPostprocess2;
  9740. private _verticalBlurPostprocess2;
  9741. private _blurTexture1;
  9742. private _blurTexture2;
  9743. private _postProcesses1;
  9744. private _postProcesses2;
  9745. private _includedOnlyMeshes;
  9746. private _excludedMeshes;
  9747. /**
  9748. * Callback used to let the user override the color selection on a per mesh basis
  9749. */
  9750. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  9751. /**
  9752. * Callback used to let the user override the texture selection on a per mesh basis
  9753. */
  9754. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  9755. /**
  9756. * Instantiates a new glow Layer and references it to the scene.
  9757. * @param name The name of the layer
  9758. * @param scene The scene to use the layer in
  9759. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  9760. */
  9761. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  9762. /**
  9763. * Get the effect name of the layer.
  9764. * @return The effect name
  9765. */
  9766. getEffectName(): string;
  9767. /**
  9768. * Create the merge effect. This is the shader use to blit the information back
  9769. * to the main canvas at the end of the scene rendering.
  9770. */
  9771. protected _createMergeEffect(): Effect;
  9772. /**
  9773. * Creates the render target textures and post processes used in the glow layer.
  9774. */
  9775. protected _createTextureAndPostProcesses(): void;
  9776. /**
  9777. * Checks for the readiness of the element composing the layer.
  9778. * @param subMesh the mesh to check for
  9779. * @param useInstances specify wether or not to use instances to render the mesh
  9780. * @param emissiveTexture the associated emissive texture used to generate the glow
  9781. * @return true if ready otherwise, false
  9782. */
  9783. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9784. /**
  9785. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9786. */
  9787. needStencil(): boolean;
  9788. /**
  9789. * Implementation specific of rendering the generating effect on the main canvas.
  9790. * @param effect The effect used to render through
  9791. */
  9792. protected _internalRender(effect: Effect): void;
  9793. /**
  9794. * Sets the required values for both the emissive texture and and the main color.
  9795. */
  9796. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9797. /**
  9798. * Returns true if the mesh should render, otherwise false.
  9799. * @param mesh The mesh to render
  9800. * @returns true if it should render otherwise false
  9801. */
  9802. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9803. /**
  9804. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  9805. * @param mesh The mesh to exclude from the glow layer
  9806. */
  9807. addExcludedMesh(mesh: Mesh): void;
  9808. /**
  9809. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  9810. * @param mesh The mesh to remove
  9811. */
  9812. removeExcludedMesh(mesh: Mesh): void;
  9813. /**
  9814. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  9815. * @param mesh The mesh to include in the glow layer
  9816. */
  9817. addIncludedOnlyMesh(mesh: Mesh): void;
  9818. /**
  9819. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  9820. * @param mesh The mesh to remove
  9821. */
  9822. removeIncludedOnlyMesh(mesh: Mesh): void;
  9823. /**
  9824. * Determine if a given mesh will be used in the glow layer
  9825. * @param mesh The mesh to test
  9826. * @returns true if the mesh will be highlighted by the current glow layer
  9827. */
  9828. hasMesh(mesh: AbstractMesh): boolean;
  9829. /**
  9830. * Free any resources and references associated to a mesh.
  9831. * Internal use
  9832. * @param mesh The mesh to free.
  9833. */
  9834. /**
  9835. * Gets the class name of the effect layer
  9836. * @returns the string with the class name of the effect layer
  9837. */
  9838. getClassName(): string;
  9839. /**
  9840. * Serializes this glow layer
  9841. * @returns a serialized glow layer object
  9842. */
  9843. serialize(): any;
  9844. /**
  9845. * Creates a Glow Layer from parsed glow layer data
  9846. * @param parsedGlowLayer defines glow layer data
  9847. * @param scene defines the current scene
  9848. * @param rootUrl defines the root URL containing the glow layer information
  9849. * @returns a parsed Glow Layer
  9850. */
  9851. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  9852. }
  9853. }
  9854. declare module BABYLON {
  9855. /**
  9856. * Highlight layer options. This helps customizing the behaviour
  9857. * of the highlight layer.
  9858. */
  9859. interface IHighlightLayerOptions {
  9860. /**
  9861. * Multiplication factor apply to the canvas size to compute the render target size
  9862. * used to generated the glowing objects (the smaller the faster).
  9863. */
  9864. mainTextureRatio: number;
  9865. /**
  9866. * Enforces a fixed size texture to ensure resize independant blur.
  9867. */
  9868. mainTextureFixedSize?: number;
  9869. /**
  9870. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  9871. * of the picture to blur (the smaller the faster).
  9872. */
  9873. blurTextureSizeRatio: number;
  9874. /**
  9875. * How big in texel of the blur texture is the vertical blur.
  9876. */
  9877. blurVerticalSize: number;
  9878. /**
  9879. * How big in texel of the blur texture is the horizontal blur.
  9880. */
  9881. blurHorizontalSize: number;
  9882. /**
  9883. * Alpha blending mode used to apply the blur. Default is combine.
  9884. */
  9885. alphaBlendingMode: number;
  9886. /**
  9887. * The camera attached to the layer.
  9888. */
  9889. camera: Nullable<Camera>;
  9890. /**
  9891. * Should we display highlight as a solid stroke?
  9892. */
  9893. isStroke?: boolean;
  9894. }
  9895. /**
  9896. * The highlight layer Helps adding a glow effect around a mesh.
  9897. *
  9898. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  9899. * glowy meshes to your scene.
  9900. *
  9901. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  9902. */
  9903. class HighlightLayer extends EffectLayer {
  9904. name: string;
  9905. /**
  9906. * Effect Name of the highlight layer.
  9907. */
  9908. static readonly EffectName: string;
  9909. /**
  9910. * The neutral color used during the preparation of the glow effect.
  9911. * This is black by default as the blend operation is a blend operation.
  9912. */
  9913. static NeutralColor: Color4;
  9914. /**
  9915. * Stencil value used for glowing meshes.
  9916. */
  9917. static GlowingMeshStencilReference: number;
  9918. /**
  9919. * Stencil value used for the other meshes in the scene.
  9920. */
  9921. static NormalMeshStencilReference: number;
  9922. /**
  9923. * Specifies whether or not the inner glow is ACTIVE in the layer.
  9924. */
  9925. innerGlow: boolean;
  9926. /**
  9927. * Specifies whether or not the outer glow is ACTIVE in the layer.
  9928. */
  9929. outerGlow: boolean;
  9930. /**
  9931. * Gets the horizontal size of the blur.
  9932. */
  9933. /**
  9934. * Specifies the horizontal size of the blur.
  9935. */
  9936. blurHorizontalSize: number;
  9937. /**
  9938. * Gets the vertical size of the blur.
  9939. */
  9940. /**
  9941. * Specifies the vertical size of the blur.
  9942. */
  9943. blurVerticalSize: number;
  9944. /**
  9945. * An event triggered when the highlight layer is being blurred.
  9946. */
  9947. onBeforeBlurObservable: Observable<HighlightLayer>;
  9948. /**
  9949. * An event triggered when the highlight layer has been blurred.
  9950. */
  9951. onAfterBlurObservable: Observable<HighlightLayer>;
  9952. private _instanceGlowingMeshStencilReference;
  9953. private _options;
  9954. private _downSamplePostprocess;
  9955. private _horizontalBlurPostprocess;
  9956. private _verticalBlurPostprocess;
  9957. private _blurTexture;
  9958. private _meshes;
  9959. private _excludedMeshes;
  9960. /**
  9961. * Instantiates a new highlight Layer and references it to the scene..
  9962. * @param name The name of the layer
  9963. * @param scene The scene to use the layer in
  9964. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  9965. */
  9966. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  9967. /**
  9968. * Get the effect name of the layer.
  9969. * @return The effect name
  9970. */
  9971. getEffectName(): string;
  9972. /**
  9973. * Create the merge effect. This is the shader use to blit the information back
  9974. * to the main canvas at the end of the scene rendering.
  9975. */
  9976. protected _createMergeEffect(): Effect;
  9977. /**
  9978. * Creates the render target textures and post processes used in the highlight layer.
  9979. */
  9980. protected _createTextureAndPostProcesses(): void;
  9981. /**
  9982. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9983. */
  9984. needStencil(): boolean;
  9985. /**
  9986. * Checks for the readiness of the element composing the layer.
  9987. * @param subMesh the mesh to check for
  9988. * @param useInstances specify wether or not to use instances to render the mesh
  9989. * @param emissiveTexture the associated emissive texture used to generate the glow
  9990. * @return true if ready otherwise, false
  9991. */
  9992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9993. /**
  9994. * Implementation specific of rendering the generating effect on the main canvas.
  9995. * @param effect The effect used to render through
  9996. */
  9997. protected _internalRender(effect: Effect): void;
  9998. /**
  9999. * Returns true if the layer contains information to display, otherwise false.
  10000. */
  10001. shouldRender(): boolean;
  10002. /**
  10003. * Returns true if the mesh should render, otherwise false.
  10004. * @param mesh The mesh to render
  10005. * @returns true if it should render otherwise false
  10006. */
  10007. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10008. /**
  10009. * Sets the required values for both the emissive texture and and the main color.
  10010. */
  10011. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10012. /**
  10013. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10014. * @param mesh The mesh to exclude from the highlight layer
  10015. */
  10016. addExcludedMesh(mesh: Mesh): void;
  10017. /**
  10018. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10019. * @param mesh The mesh to highlight
  10020. */
  10021. removeExcludedMesh(mesh: Mesh): void;
  10022. /**
  10023. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10024. * @param mesh mesh to test
  10025. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10026. */
  10027. hasMesh(mesh: AbstractMesh): boolean;
  10028. /**
  10029. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10030. * @param mesh The mesh to highlight
  10031. * @param color The color of the highlight
  10032. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10033. */
  10034. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10035. /**
  10036. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10037. * @param mesh The mesh to highlight
  10038. */
  10039. removeMesh(mesh: Mesh): void;
  10040. /**
  10041. * Force the stencil to the normal expected value for none glowing parts
  10042. */
  10043. private _defaultStencilReference(mesh);
  10044. /**
  10045. * Free any resources and references associated to a mesh.
  10046. * Internal use
  10047. * @param mesh The mesh to free.
  10048. */
  10049. /**
  10050. * Dispose the highlight layer and free resources.
  10051. */
  10052. dispose(): void;
  10053. /**
  10054. * Gets the class name of the effect layer
  10055. * @returns the string with the class name of the effect layer
  10056. */
  10057. getClassName(): string;
  10058. /**
  10059. * Serializes this Highlight layer
  10060. * @returns a serialized Highlight layer object
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a Highlight layer from parsed Highlight layer data
  10065. * @param parsedHightlightLayer defines the Highlight layer data
  10066. * @param scene defines the current scene
  10067. * @param rootUrl defines the root URL containing the Highlight layer information
  10068. * @returns a parsed Highlight layer
  10069. */
  10070. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10071. }
  10072. }
  10073. declare module BABYLON {
  10074. class Layer {
  10075. name: string;
  10076. texture: Nullable<Texture>;
  10077. isBackground: boolean;
  10078. color: Color4;
  10079. scale: Vector2;
  10080. offset: Vector2;
  10081. alphaBlendingMode: number;
  10082. alphaTest: boolean;
  10083. layerMask: number;
  10084. private _scene;
  10085. private _vertexBuffers;
  10086. private _indexBuffer;
  10087. private _effect;
  10088. private _alphaTestEffect;
  10089. /**
  10090. * An event triggered when the layer is disposed.
  10091. */
  10092. onDisposeObservable: Observable<Layer>;
  10093. private _onDisposeObserver;
  10094. onDispose: () => void;
  10095. /**
  10096. * An event triggered before rendering the scene
  10097. */
  10098. onBeforeRenderObservable: Observable<Layer>;
  10099. private _onBeforeRenderObserver;
  10100. onBeforeRender: () => void;
  10101. /**
  10102. * An event triggered after rendering the scene
  10103. */
  10104. onAfterRenderObservable: Observable<Layer>;
  10105. private _onAfterRenderObserver;
  10106. onAfterRender: () => void;
  10107. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10108. private _createIndexBuffer();
  10109. render(): void;
  10110. dispose(): void;
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. class LensFlare {
  10115. size: number;
  10116. position: number;
  10117. color: Color3;
  10118. texture: Nullable<Texture>;
  10119. alphaMode: number;
  10120. private _system;
  10121. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10122. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10123. dispose(): void;
  10124. }
  10125. }
  10126. declare module BABYLON {
  10127. class LensFlareSystem {
  10128. name: string;
  10129. lensFlares: LensFlare[];
  10130. borderLimit: number;
  10131. viewportBorder: number;
  10132. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10133. layerMask: number;
  10134. id: string;
  10135. private _scene;
  10136. private _emitter;
  10137. private _vertexBuffers;
  10138. private _indexBuffer;
  10139. private _effect;
  10140. private _positionX;
  10141. private _positionY;
  10142. private _isEnabled;
  10143. constructor(name: string, emitter: any, scene: Scene);
  10144. isEnabled: boolean;
  10145. getScene(): Scene;
  10146. getEmitter(): any;
  10147. setEmitter(newEmitter: any): void;
  10148. getEmitterPosition(): Vector3;
  10149. computeEffectivePosition(globalViewport: Viewport): boolean;
  10150. render(): boolean;
  10151. dispose(): void;
  10152. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10153. serialize(): any;
  10154. }
  10155. }
  10156. declare module BABYLON {
  10157. /**
  10158. * A directional light is defined by a direction (what a surprise!).
  10159. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10160. * 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.
  10161. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10162. */
  10163. class DirectionalLight extends ShadowLight {
  10164. private _shadowFrustumSize;
  10165. /**
  10166. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10167. */
  10168. /**
  10169. * Specifies a fix frustum size for the shadow generation.
  10170. */
  10171. shadowFrustumSize: number;
  10172. private _shadowOrthoScale;
  10173. /**
  10174. * Gets the shadow projection scale against the optimal computed one.
  10175. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10176. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10177. */
  10178. /**
  10179. * Sets the shadow projection scale against the optimal computed one.
  10180. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10181. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10182. */
  10183. shadowOrthoScale: number;
  10184. /**
  10185. * Automatically compute the projection matrix to best fit (including all the casters)
  10186. * on each frame.
  10187. */
  10188. autoUpdateExtends: boolean;
  10189. private _orthoLeft;
  10190. private _orthoRight;
  10191. private _orthoTop;
  10192. private _orthoBottom;
  10193. /**
  10194. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10195. * The directional light is emitted from everywhere in the given direction.
  10196. * It can cast shawdows.
  10197. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10198. * @param name The friendly name of the light
  10199. * @param direction The direction of the light
  10200. * @param scene The scene the light belongs to
  10201. */
  10202. constructor(name: string, direction: Vector3, scene: Scene);
  10203. /**
  10204. * Returns the string "DirectionalLight".
  10205. * @return The class name
  10206. */
  10207. getClassName(): string;
  10208. /**
  10209. * Returns the integer 1.
  10210. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10211. */
  10212. getTypeID(): number;
  10213. /**
  10214. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10215. * Returns the DirectionalLight Shadow projection matrix.
  10216. */
  10217. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10218. /**
  10219. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10220. * Returns the DirectionalLight Shadow projection matrix.
  10221. */
  10222. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10223. /**
  10224. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10225. * Returns the DirectionalLight Shadow projection matrix.
  10226. */
  10227. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10228. protected _buildUniformLayout(): void;
  10229. /**
  10230. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10231. * @param effect The effect to update
  10232. * @param lightIndex The index of the light in the effect to update
  10233. * @returns The directional light
  10234. */
  10235. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10236. /**
  10237. * Gets the minZ used for shadow according to both the scene and the light.
  10238. *
  10239. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10240. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10241. * @param activeCamera The camera we are returning the min for
  10242. * @returns the depth min z
  10243. */
  10244. getDepthMinZ(activeCamera: Camera): number;
  10245. /**
  10246. * Gets the maxZ used for shadow according to both the scene and the light.
  10247. *
  10248. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10249. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10250. * @param activeCamera The camera we are returning the max for
  10251. * @returns the depth max z
  10252. */
  10253. getDepthMaxZ(activeCamera: Camera): number;
  10254. }
  10255. }
  10256. declare module BABYLON {
  10257. /**
  10258. * The HemisphericLight simulates the ambient environment light,
  10259. * so the passed direction is the light reflection direction, not the incoming direction.
  10260. */
  10261. class HemisphericLight extends Light {
  10262. /**
  10263. * The groundColor is the light in the opposite direction to the one specified during creation.
  10264. * 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.
  10265. */
  10266. groundColor: Color3;
  10267. /**
  10268. * The light reflection direction, not the incoming direction.
  10269. */
  10270. direction: Vector3;
  10271. private _worldMatrix;
  10272. /**
  10273. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10274. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10275. * The HemisphericLight can't cast shadows.
  10276. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10277. * @param name The friendly name of the light
  10278. * @param direction The direction of the light reflection
  10279. * @param scene The scene the light belongs to
  10280. */
  10281. constructor(name: string, direction: Vector3, scene: Scene);
  10282. protected _buildUniformLayout(): void;
  10283. /**
  10284. * Returns the string "HemisphericLight".
  10285. * @return The class name
  10286. */
  10287. getClassName(): string;
  10288. /**
  10289. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10290. * Returns the updated direction.
  10291. * @param target The target the direction should point to
  10292. * @return The computed direction
  10293. */
  10294. setDirectionToTarget(target: Vector3): Vector3;
  10295. /**
  10296. * Returns the shadow generator associated to the light.
  10297. * @returns Always null for hemispheric lights because it does not support shadows.
  10298. */
  10299. getShadowGenerator(): Nullable<ShadowGenerator>;
  10300. /**
  10301. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10302. * @param effect The effect to update
  10303. * @param lightIndex The index of the light in the effect to update
  10304. * @returns The hemispheric light
  10305. */
  10306. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10307. /**
  10308. * @hidden internal use only.
  10309. */
  10310. /**
  10311. * Returns the integer 3.
  10312. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10313. */
  10314. getTypeID(): number;
  10315. }
  10316. }
  10317. declare module BABYLON {
  10318. /**
  10319. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10320. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10321. * 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.
  10322. */
  10323. abstract class Light extends Node {
  10324. private static _LIGHTMAP_DEFAULT;
  10325. private static _LIGHTMAP_SPECULAR;
  10326. private static _LIGHTMAP_SHADOWSONLY;
  10327. /**
  10328. * If every light affecting the material is in this lightmapMode,
  10329. * material.lightmapTexture adds or multiplies
  10330. * (depends on material.useLightmapAsShadowmap)
  10331. * after every other light calculations.
  10332. */
  10333. static readonly LIGHTMAP_DEFAULT: number;
  10334. /**
  10335. * material.lightmapTexture as only diffuse lighting from this light
  10336. * adds only specular lighting from this light
  10337. * adds dynamic shadows
  10338. */
  10339. static readonly LIGHTMAP_SPECULAR: number;
  10340. /**
  10341. * material.lightmapTexture as only lighting
  10342. * no light calculation from this light
  10343. * only adds dynamic shadows from this light
  10344. */
  10345. static readonly LIGHTMAP_SHADOWSONLY: number;
  10346. private static _INTENSITYMODE_AUTOMATIC;
  10347. private static _INTENSITYMODE_LUMINOUSPOWER;
  10348. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10349. private static _INTENSITYMODE_ILLUMINANCE;
  10350. private static _INTENSITYMODE_LUMINANCE;
  10351. /**
  10352. * Each light type uses the default quantity according to its type:
  10353. * point/spot lights use luminous intensity
  10354. * directional lights use illuminance
  10355. */
  10356. static readonly INTENSITYMODE_AUTOMATIC: number;
  10357. /**
  10358. * lumen (lm)
  10359. */
  10360. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10361. /**
  10362. * candela (lm/sr)
  10363. */
  10364. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10365. /**
  10366. * lux (lm/m^2)
  10367. */
  10368. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10369. /**
  10370. * nit (cd/m^2)
  10371. */
  10372. static readonly INTENSITYMODE_LUMINANCE: number;
  10373. private static _LIGHTTYPEID_POINTLIGHT;
  10374. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10375. private static _LIGHTTYPEID_SPOTLIGHT;
  10376. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10377. /**
  10378. * Light type const id of the point light.
  10379. */
  10380. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10381. /**
  10382. * Light type const id of the directional light.
  10383. */
  10384. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10385. /**
  10386. * Light type const id of the spot light.
  10387. */
  10388. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10389. /**
  10390. * Light type const id of the hemispheric light.
  10391. */
  10392. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10393. /**
  10394. * Diffuse gives the basic color to an object.
  10395. */
  10396. diffuse: Color3;
  10397. /**
  10398. * Specular produces a highlight color on an object.
  10399. * Note: This is note affecting PBR materials.
  10400. */
  10401. specular: Color3;
  10402. /**
  10403. * Strength of the light.
  10404. * Note: By default it is define in the framework own unit.
  10405. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10406. */
  10407. intensity: number;
  10408. /**
  10409. * Defines how far from the source the light is impacting in scene units.
  10410. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10411. */
  10412. range: number;
  10413. /**
  10414. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10415. * of light.
  10416. */
  10417. private _photometricScale;
  10418. private _intensityMode;
  10419. /**
  10420. * Gets the photometric scale used to interpret the intensity.
  10421. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10422. */
  10423. /**
  10424. * Sets the photometric scale used to interpret the intensity.
  10425. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10426. */
  10427. intensityMode: number;
  10428. private _radius;
  10429. /**
  10430. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10431. */
  10432. /**
  10433. * sets the light radius used by PBR Materials to simulate soft area lights.
  10434. */
  10435. radius: number;
  10436. private _renderPriority;
  10437. /**
  10438. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10439. * exceeding the number allowed of the materials.
  10440. */
  10441. renderPriority: number;
  10442. /**
  10443. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10444. * the current shadow generator.
  10445. */
  10446. shadowEnabled: boolean;
  10447. private _includedOnlyMeshes;
  10448. /**
  10449. * Gets the only meshes impacted by this light.
  10450. */
  10451. /**
  10452. * Sets the only meshes impacted by this light.
  10453. */
  10454. includedOnlyMeshes: AbstractMesh[];
  10455. private _excludedMeshes;
  10456. /**
  10457. * Gets the meshes not impacted by this light.
  10458. */
  10459. /**
  10460. * Sets the meshes not impacted by this light.
  10461. */
  10462. excludedMeshes: AbstractMesh[];
  10463. private _excludeWithLayerMask;
  10464. /**
  10465. * Gets the layer id use to find what meshes are not impacted by the light.
  10466. * Inactive if 0
  10467. */
  10468. /**
  10469. * Sets the layer id use to find what meshes are not impacted by the light.
  10470. * Inactive if 0
  10471. */
  10472. excludeWithLayerMask: number;
  10473. private _includeOnlyWithLayerMask;
  10474. /**
  10475. * Gets the layer id use to find what meshes are impacted by the light.
  10476. * Inactive if 0
  10477. */
  10478. /**
  10479. * Sets the layer id use to find what meshes are impacted by the light.
  10480. * Inactive if 0
  10481. */
  10482. includeOnlyWithLayerMask: number;
  10483. private _lightmapMode;
  10484. /**
  10485. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10486. */
  10487. /**
  10488. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10489. */
  10490. lightmapMode: number;
  10491. private _parentedWorldMatrix;
  10492. /**
  10493. * Shadow generator associted to the light.
  10494. * Internal use only.
  10495. */
  10496. /**
  10497. * @hidden Internal use only.
  10498. */
  10499. /**
  10500. * @hidden Internal use only.
  10501. */
  10502. /**
  10503. * The current light unifom buffer.
  10504. * @hidden Internal use only.
  10505. */
  10506. /**
  10507. * Creates a Light object in the scene.
  10508. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10509. * @param name The firendly name of the light
  10510. * @param scene The scene the light belongs too
  10511. */
  10512. constructor(name: string, scene: Scene);
  10513. protected abstract _buildUniformLayout(): void;
  10514. /**
  10515. * Sets the passed Effect "effect" with the Light information.
  10516. * @param effect The effect to update
  10517. * @param lightIndex The index of the light in the effect to update
  10518. * @returns The light
  10519. */
  10520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10521. /**
  10522. * @hidden internal use only.
  10523. */
  10524. getWorldMatrix(): Matrix;
  10525. /**
  10526. * Returns the string "Light".
  10527. * @returns the class name
  10528. */
  10529. getClassName(): string;
  10530. /**
  10531. * Converts the light information to a readable string for debug purpose.
  10532. * @param fullDetails Supports for multiple levels of logging within scene loading
  10533. * @returns the human readable light info
  10534. */
  10535. toString(fullDetails?: boolean): string;
  10536. /**
  10537. * Set the enabled state of this node.
  10538. * @param value - the new enabled state
  10539. */
  10540. setEnabled(value: boolean): void;
  10541. /**
  10542. * Returns the Light associated shadow generator if any.
  10543. * @return the associated shadow generator.
  10544. */
  10545. getShadowGenerator(): Nullable<IShadowGenerator>;
  10546. /**
  10547. * Returns a Vector3, the absolute light position in the World.
  10548. * @returns the world space position of the light
  10549. */
  10550. getAbsolutePosition(): Vector3;
  10551. /**
  10552. * Specifies if the light will affect the passed mesh.
  10553. * @param mesh The mesh to test against the light
  10554. * @return true the mesh is affected otherwise, false.
  10555. */
  10556. canAffectMesh(mesh: AbstractMesh): boolean;
  10557. /**
  10558. * Computes and Returns the light World matrix.
  10559. * @returns the world matrix
  10560. */
  10561. getWorldMatrix(): Matrix;
  10562. /**
  10563. * Sort function to order lights for rendering.
  10564. * @param a First Light object to compare to second.
  10565. * @param b Second Light object to compare first.
  10566. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10567. */
  10568. static CompareLightsPriority(a: Light, b: Light): number;
  10569. /**
  10570. * Releases resources associated with this node.
  10571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10573. */
  10574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10575. /**
  10576. * Returns the light type ID (integer).
  10577. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10578. */
  10579. getTypeID(): number;
  10580. /**
  10581. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10582. * @returns the scaled intensity in intensity mode unit
  10583. */
  10584. getScaledIntensity(): number;
  10585. /**
  10586. * Returns a new Light object, named "name", from the current one.
  10587. * @param name The name of the cloned light
  10588. * @returns the new created light
  10589. */
  10590. clone(name: string): Nullable<Light>;
  10591. /**
  10592. * Serializes the current light into a Serialization object.
  10593. * @returns the serialized object.
  10594. */
  10595. serialize(): any;
  10596. /**
  10597. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10598. * This new light is named "name" and added to the passed scene.
  10599. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10600. * @param name The friendly name of the light
  10601. * @param scene The scene the new light will belong to
  10602. * @returns the constructor function
  10603. */
  10604. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10605. /**
  10606. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10607. * @param parsedLight The JSON representation of the light
  10608. * @param scene The scene to create the parsed light in
  10609. * @returns the created light after parsing
  10610. */
  10611. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10612. private _hookArrayForExcluded(array);
  10613. private _hookArrayForIncludedOnly(array);
  10614. private _resyncMeshes();
  10615. /**
  10616. * Forces the meshes to update their light related information in their rendering used effects
  10617. * @hidden Internal Use Only
  10618. */
  10619. /**
  10620. * Recomputes the cached photometric scale if needed.
  10621. */
  10622. private _computePhotometricScale();
  10623. /**
  10624. * Returns the Photometric Scale according to the light type and intensity mode.
  10625. */
  10626. private _getPhotometricScale();
  10627. /**
  10628. * Reorder the light in the scene according to their defined priority.
  10629. * @hidden Internal Use Only
  10630. */
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * A point light is a light defined by an unique point in world space.
  10636. * The light is emitted in every direction from this point.
  10637. * A good example of a point light is a standard light bulb.
  10638. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10639. */
  10640. class PointLight extends ShadowLight {
  10641. private _shadowAngle;
  10642. /**
  10643. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10644. * This specifies what angle the shadow will use to be created.
  10645. *
  10646. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10647. */
  10648. /**
  10649. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10650. * This specifies what angle the shadow will use to be created.
  10651. *
  10652. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10653. */
  10654. shadowAngle: number;
  10655. /**
  10656. * Gets the direction if it has been set.
  10657. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10658. */
  10659. /**
  10660. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10661. */
  10662. direction: Vector3;
  10663. /**
  10664. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  10665. * A PointLight emits the light in every direction.
  10666. * It can cast shadows.
  10667. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  10668. * ```javascript
  10669. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  10670. * ```
  10671. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10672. * @param name The light friendly name
  10673. * @param position The position of the point light in the scene
  10674. * @param scene The scene the lights belongs to
  10675. */
  10676. constructor(name: string, position: Vector3, scene: Scene);
  10677. /**
  10678. * Returns the string "PointLight"
  10679. * @returns the class name
  10680. */
  10681. getClassName(): string;
  10682. /**
  10683. * Returns the integer 0.
  10684. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10685. */
  10686. getTypeID(): number;
  10687. /**
  10688. * Specifies wether or not the shadowmap should be a cube texture.
  10689. * @returns true if the shadowmap needs to be a cube texture.
  10690. */
  10691. needCube(): boolean;
  10692. /**
  10693. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  10694. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10695. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10696. */
  10697. getShadowDirection(faceIndex?: number): Vector3;
  10698. /**
  10699. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  10700. * - fov = PI / 2
  10701. * - aspect ratio : 1.0
  10702. * - z-near and far equal to the active camera minZ and maxZ.
  10703. * Returns the PointLight.
  10704. */
  10705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10706. protected _buildUniformLayout(): void;
  10707. /**
  10708. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  10709. * @param effect The effect to update
  10710. * @param lightIndex The index of the light in the effect to update
  10711. * @returns The point light
  10712. */
  10713. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  10714. }
  10715. }
  10716. declare module BABYLON {
  10717. /**
  10718. * Interface describing all the common properties and methods a shadow light needs to implement.
  10719. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10720. * as well as binding the different shadow properties to the effects.
  10721. */
  10722. interface IShadowLight extends Light {
  10723. /**
  10724. * The light id in the scene (used in scene.findLighById for instance)
  10725. */
  10726. id: string;
  10727. /**
  10728. * The position the shdow will be casted from.
  10729. */
  10730. position: Vector3;
  10731. /**
  10732. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10733. */
  10734. direction: Vector3;
  10735. /**
  10736. * The transformed position. Position of the light in world space taking parenting in account.
  10737. */
  10738. transformedPosition: Vector3;
  10739. /**
  10740. * The transformed direction. Direction of the light in world space taking parenting in account.
  10741. */
  10742. transformedDirection: Vector3;
  10743. /**
  10744. * The friendly name of the light in the scene.
  10745. */
  10746. name: string;
  10747. /**
  10748. * Defines the shadow projection clipping minimum z value.
  10749. */
  10750. shadowMinZ: number;
  10751. /**
  10752. * Defines the shadow projection clipping maximum z value.
  10753. */
  10754. shadowMaxZ: number;
  10755. /**
  10756. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10757. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10758. */
  10759. computeTransformedInformation(): boolean;
  10760. /**
  10761. * Gets the scene the light belongs to.
  10762. * @returns The scene
  10763. */
  10764. getScene(): Scene;
  10765. /**
  10766. * Callback defining a custom Projection Matrix Builder.
  10767. * This can be used to override the default projection matrix computation.
  10768. */
  10769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10770. /**
  10771. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10772. * @param matrix The materix to updated with the projection information
  10773. * @param viewMatrix The transform matrix of the light
  10774. * @param renderList The list of mesh to render in the map
  10775. * @returns The current light
  10776. */
  10777. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10778. /**
  10779. * Gets the current depth scale used in ESM.
  10780. * @returns The scale
  10781. */
  10782. getDepthScale(): number;
  10783. /**
  10784. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10785. * @returns true if a cube texture needs to be use
  10786. */
  10787. needCube(): boolean;
  10788. /**
  10789. * Detects if the projection matrix requires to be recomputed this frame.
  10790. * @returns true if it requires to be recomputed otherwise, false.
  10791. */
  10792. needProjectionMatrixCompute(): boolean;
  10793. /**
  10794. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10795. */
  10796. forceProjectionMatrixCompute(): void;
  10797. /**
  10798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10801. */
  10802. getShadowDirection(faceIndex?: number): Vector3;
  10803. /**
  10804. * Gets the minZ used for shadow according to both the scene and the light.
  10805. * @param activeCamera The camera we are returning the min for
  10806. * @returns the depth min z
  10807. */
  10808. getDepthMinZ(activeCamera: Camera): number;
  10809. /**
  10810. * Gets the maxZ used for shadow according to both the scene and the light.
  10811. * @param activeCamera The camera we are returning the max for
  10812. * @returns the depth max z
  10813. */
  10814. getDepthMaxZ(activeCamera: Camera): number;
  10815. }
  10816. /**
  10817. * Base implementation IShadowLight
  10818. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10819. */
  10820. abstract class ShadowLight extends Light implements IShadowLight {
  10821. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10822. protected _position: Vector3;
  10823. protected _setPosition(value: Vector3): void;
  10824. /**
  10825. * Sets the position the shadow will be casted from. Also use as the light position for both
  10826. * point and spot lights.
  10827. */
  10828. /**
  10829. * Sets the position the shadow will be casted from. Also use as the light position for both
  10830. * point and spot lights.
  10831. */
  10832. position: Vector3;
  10833. protected _direction: Vector3;
  10834. protected _setDirection(value: Vector3): void;
  10835. /**
  10836. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10837. * Also use as the light direction on spot and directional lights.
  10838. */
  10839. /**
  10840. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10841. * Also use as the light direction on spot and directional lights.
  10842. */
  10843. direction: Vector3;
  10844. private _shadowMinZ;
  10845. /**
  10846. * Gets the shadow projection clipping minimum z value.
  10847. */
  10848. /**
  10849. * Sets the shadow projection clipping minimum z value.
  10850. */
  10851. shadowMinZ: number;
  10852. private _shadowMaxZ;
  10853. /**
  10854. * Sets the shadow projection clipping maximum z value.
  10855. */
  10856. /**
  10857. * Gets the shadow projection clipping maximum z value.
  10858. */
  10859. shadowMaxZ: number;
  10860. /**
  10861. * Callback defining a custom Projection Matrix Builder.
  10862. * This can be used to override the default projection matrix computation.
  10863. */
  10864. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10865. /**
  10866. * The transformed position. Position of the light in world space taking parenting in account.
  10867. */
  10868. transformedPosition: Vector3;
  10869. /**
  10870. * The transformed direction. Direction of the light in world space taking parenting in account.
  10871. */
  10872. transformedDirection: Vector3;
  10873. private _worldMatrix;
  10874. private _needProjectionMatrixCompute;
  10875. /**
  10876. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10877. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10878. */
  10879. computeTransformedInformation(): boolean;
  10880. /**
  10881. * Return the depth scale used for the shadow map.
  10882. * @returns the depth scale.
  10883. */
  10884. getDepthScale(): number;
  10885. /**
  10886. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10887. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10888. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10889. */
  10890. getShadowDirection(faceIndex?: number): Vector3;
  10891. /**
  10892. * Returns the ShadowLight absolute position in the World.
  10893. * @returns the position vector in world space
  10894. */
  10895. getAbsolutePosition(): Vector3;
  10896. /**
  10897. * Sets the ShadowLight direction toward the passed target.
  10898. * @param target The point tot target in local space
  10899. * @returns the updated ShadowLight direction
  10900. */
  10901. setDirectionToTarget(target: Vector3): Vector3;
  10902. /**
  10903. * Returns the light rotation in euler definition.
  10904. * @returns the x y z rotation in local space.
  10905. */
  10906. getRotation(): Vector3;
  10907. /**
  10908. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10909. * @returns true if a cube texture needs to be use
  10910. */
  10911. needCube(): boolean;
  10912. /**
  10913. * Detects if the projection matrix requires to be recomputed this frame.
  10914. * @returns true if it requires to be recomputed otherwise, false.
  10915. */
  10916. needProjectionMatrixCompute(): boolean;
  10917. /**
  10918. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10919. */
  10920. forceProjectionMatrixCompute(): void;
  10921. /**
  10922. * Get the world matrix of the sahdow lights.
  10923. * @hidden Internal Use Only
  10924. */
  10925. /**
  10926. * Gets the minZ used for shadow according to both the scene and the light.
  10927. * @param activeCamera The camera we are returning the min for
  10928. * @returns the depth min z
  10929. */
  10930. getDepthMinZ(activeCamera: Camera): number;
  10931. /**
  10932. * Gets the maxZ used for shadow according to both the scene and the light.
  10933. * @param activeCamera The camera we are returning the max for
  10934. * @returns the depth max z
  10935. */
  10936. getDepthMaxZ(activeCamera: Camera): number;
  10937. /**
  10938. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10939. * @param matrix The materix to updated with the projection information
  10940. * @param viewMatrix The transform matrix of the light
  10941. * @param renderList The list of mesh to render in the map
  10942. * @returns The current light
  10943. */
  10944. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10945. }
  10946. }
  10947. declare module BABYLON {
  10948. /**
  10949. * A spot light is defined by a position, a direction, an angle, and an exponent.
  10950. * These values define a cone of light starting from the position, emitting toward the direction.
  10951. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  10952. * and the exponent defines the speed of the decay of the light with distance (reach).
  10953. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10954. */
  10955. class SpotLight extends ShadowLight {
  10956. private _angle;
  10957. /**
  10958. * Gets the cone angle of the spot light in Radians.
  10959. */
  10960. /**
  10961. * Sets the cone angle of the spot light in Radians.
  10962. */
  10963. angle: number;
  10964. private _shadowAngleScale;
  10965. /**
  10966. * Allows scaling the angle of the light for shadow generation only.
  10967. */
  10968. /**
  10969. * Allows scaling the angle of the light for shadow generation only.
  10970. */
  10971. shadowAngleScale: number;
  10972. /**
  10973. * The light decay speed with the distance from the emission spot.
  10974. */
  10975. exponent: number;
  10976. private _projectionTextureMatrix;
  10977. /**
  10978. * Allows reading the projecton texture
  10979. */
  10980. readonly projectionTextureMatrix: Matrix;
  10981. protected _projectionTextureLightNear: number;
  10982. /**
  10983. * Gets the near clip of the Spotlight for texture projection.
  10984. */
  10985. /**
  10986. * Sets the near clip of the Spotlight for texture projection.
  10987. */
  10988. projectionTextureLightNear: number;
  10989. protected _projectionTextureLightFar: number;
  10990. /**
  10991. * Gets the far clip of the Spotlight for texture projection.
  10992. */
  10993. /**
  10994. * Sets the far clip of the Spotlight for texture projection.
  10995. */
  10996. projectionTextureLightFar: number;
  10997. protected _projectionTextureUpDirection: Vector3;
  10998. /**
  10999. * Gets the Up vector of the Spotlight for texture projection.
  11000. */
  11001. /**
  11002. * Sets the Up vector of the Spotlight for texture projection.
  11003. */
  11004. projectionTextureUpDirection: Vector3;
  11005. private _projectionTexture;
  11006. /**
  11007. * Gets the projection texture of the light.
  11008. */
  11009. /**
  11010. * Sets the projection texture of the light.
  11011. */
  11012. projectionTexture: Nullable<BaseTexture>;
  11013. private _projectionTextureViewLightDirty;
  11014. private _projectionTextureProjectionLightDirty;
  11015. private _projectionTextureDirty;
  11016. private _projectionTextureViewTargetVector;
  11017. private _projectionTextureViewLightMatrix;
  11018. private _projectionTextureProjectionLightMatrix;
  11019. private _projectionTextureScalingMatrix;
  11020. /**
  11021. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11022. * It can cast shadows.
  11023. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11024. * @param name The light friendly name
  11025. * @param position The position of the spot light in the scene
  11026. * @param direction The direction of the light in the scene
  11027. * @param angle The cone angle of the light in Radians
  11028. * @param exponent The light decay speed with the distance from the emission spot
  11029. * @param scene The scene the lights belongs to
  11030. */
  11031. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11032. /**
  11033. * Returns the string "SpotLight".
  11034. * @returns the class name
  11035. */
  11036. getClassName(): string;
  11037. /**
  11038. * Returns the integer 2.
  11039. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11040. */
  11041. getTypeID(): number;
  11042. /**
  11043. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11044. */
  11045. protected _setDirection(value: Vector3): void;
  11046. /**
  11047. * Overrides the position setter to recompute the projection texture view light Matrix.
  11048. */
  11049. protected _setPosition(value: Vector3): void;
  11050. /**
  11051. * 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.
  11052. * Returns the SpotLight.
  11053. */
  11054. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11055. protected _computeProjectionTextureViewLightMatrix(): void;
  11056. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11057. /**
  11058. * Main function for light texture projection matrix computing.
  11059. */
  11060. protected _computeProjectionTextureMatrix(): void;
  11061. protected _buildUniformLayout(): void;
  11062. /**
  11063. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11064. * @param effect The effect to update
  11065. * @param lightIndex The index of the light in the effect to update
  11066. * @returns The spot light
  11067. */
  11068. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11069. /**
  11070. * Disposes the light and the associated resources.
  11071. */
  11072. dispose(): void;
  11073. }
  11074. }
  11075. declare module BABYLON {
  11076. class StickValues {
  11077. x: number;
  11078. y: number;
  11079. constructor(x: number, y: number);
  11080. }
  11081. interface GamepadButtonChanges {
  11082. changed: boolean;
  11083. pressChanged: boolean;
  11084. touchChanged: boolean;
  11085. valueChanged: boolean;
  11086. }
  11087. class Gamepad {
  11088. id: string;
  11089. index: number;
  11090. browserGamepad: any;
  11091. type: number;
  11092. private _leftStick;
  11093. private _rightStick;
  11094. private _leftStickAxisX;
  11095. private _leftStickAxisY;
  11096. private _rightStickAxisX;
  11097. private _rightStickAxisY;
  11098. private _onleftstickchanged;
  11099. private _onrightstickchanged;
  11100. static GAMEPAD: number;
  11101. static GENERIC: number;
  11102. static XBOX: number;
  11103. static POSE_ENABLED: number;
  11104. protected _invertLeftStickY: boolean;
  11105. readonly isConnected: boolean;
  11106. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11107. onleftstickchanged(callback: (values: StickValues) => void): void;
  11108. onrightstickchanged(callback: (values: StickValues) => void): void;
  11109. leftStick: StickValues;
  11110. rightStick: StickValues;
  11111. update(): void;
  11112. dispose(): void;
  11113. }
  11114. class GenericPad extends Gamepad {
  11115. private _buttons;
  11116. private _onbuttondown;
  11117. private _onbuttonup;
  11118. onButtonDownObservable: Observable<number>;
  11119. onButtonUpObservable: Observable<number>;
  11120. onbuttondown(callback: (buttonPressed: number) => void): void;
  11121. onbuttonup(callback: (buttonReleased: number) => void): void;
  11122. constructor(id: string, index: number, browserGamepad: any);
  11123. private _setButtonValue(newValue, currentValue, buttonIndex);
  11124. update(): void;
  11125. dispose(): void;
  11126. }
  11127. }
  11128. declare module BABYLON {
  11129. class GamepadManager {
  11130. private _scene;
  11131. private _babylonGamepads;
  11132. private _oneGamepadConnected;
  11133. private _gamepadEventSupported;
  11134. private _gamepadSupport;
  11135. onGamepadConnectedObservable: Observable<Gamepad>;
  11136. onGamepadDisconnectedObservable: Observable<Gamepad>;
  11137. private _onGamepadConnectedEvent;
  11138. private _onGamepadDisconnectedEvent;
  11139. constructor(_scene?: Scene | undefined);
  11140. readonly gamepads: Gamepad[];
  11141. getGamepadByType(type?: number): Nullable<Gamepad>;
  11142. dispose(): void;
  11143. private _addNewGamepad(gamepad);
  11144. private _startMonitoringGamepads();
  11145. private _stopMonitoringGamepads();
  11146. private _updateGamepadObjects();
  11147. }
  11148. }
  11149. declare module BABYLON {
  11150. /**
  11151. * Defines supported buttons for XBox360 compatible gamepads
  11152. */
  11153. enum Xbox360Button {
  11154. /** A */
  11155. A = 0,
  11156. /** B */
  11157. B = 1,
  11158. /** X */
  11159. X = 2,
  11160. /** Y */
  11161. Y = 3,
  11162. /** Start */
  11163. Start = 4,
  11164. /** Back */
  11165. Back = 5,
  11166. /** Left button */
  11167. LB = 6,
  11168. /** Right button */
  11169. RB = 7,
  11170. /** Left stick */
  11171. LeftStick = 8,
  11172. /** Right stick */
  11173. RightStick = 9,
  11174. }
  11175. /** Defines values for XBox360 DPad */
  11176. enum Xbox360Dpad {
  11177. /** Up */
  11178. Up = 0,
  11179. /** Down */
  11180. Down = 1,
  11181. /** Left */
  11182. Left = 2,
  11183. /** Right */
  11184. Right = 3,
  11185. }
  11186. /**
  11187. * Defines a XBox360 gamepad
  11188. */
  11189. class Xbox360Pad extends Gamepad {
  11190. private _leftTrigger;
  11191. private _rightTrigger;
  11192. private _onlefttriggerchanged;
  11193. private _onrighttriggerchanged;
  11194. private _onbuttondown;
  11195. private _onbuttonup;
  11196. private _ondpaddown;
  11197. private _ondpadup;
  11198. /** Observable raised when a button is pressed */
  11199. onButtonDownObservable: Observable<Xbox360Button>;
  11200. /** Observable raised when a button is released */
  11201. onButtonUpObservable: Observable<Xbox360Button>;
  11202. /** Observable raised when a pad is pressed */
  11203. onPadDownObservable: Observable<Xbox360Dpad>;
  11204. /** Observable raised when a pad is released */
  11205. onPadUpObservable: Observable<Xbox360Dpad>;
  11206. private _buttonA;
  11207. private _buttonB;
  11208. private _buttonX;
  11209. private _buttonY;
  11210. private _buttonBack;
  11211. private _buttonStart;
  11212. private _buttonLB;
  11213. private _buttonRB;
  11214. private _buttonLeftStick;
  11215. private _buttonRightStick;
  11216. private _dPadUp;
  11217. private _dPadDown;
  11218. private _dPadLeft;
  11219. private _dPadRight;
  11220. private _isXboxOnePad;
  11221. /**
  11222. * Creates a new XBox360 gamepad object
  11223. * @param id defines the id of this gamepad
  11224. * @param index defines its index
  11225. * @param gamepad defines the internal HTML gamepad object
  11226. * @param xboxOne defines if it is a XBox One gamepad
  11227. */
  11228. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  11229. /**
  11230. * Defines the callback to call when left trigger is pressed
  11231. * @param callback defines the callback to use
  11232. */
  11233. onlefttriggerchanged(callback: (value: number) => void): void;
  11234. /**
  11235. * Defines the callback to call when right trigger is pressed
  11236. * @param callback defines the callback to use
  11237. */
  11238. onrighttriggerchanged(callback: (value: number) => void): void;
  11239. /**
  11240. * Gets or sets left trigger value
  11241. */
  11242. leftTrigger: number;
  11243. /**
  11244. * Gets or sets right trigger value
  11245. */
  11246. rightTrigger: number;
  11247. /**
  11248. * Defines the callback to call when a button is pressed
  11249. * @param callback defines the callback to use
  11250. */
  11251. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  11252. /**
  11253. * Defines the callback to call when a button is released
  11254. * @param callback defines the callback to use
  11255. */
  11256. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  11257. /**
  11258. * Defines the callback to call when a pad is pressed
  11259. * @param callback defines the callback to use
  11260. */
  11261. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  11262. /**
  11263. * Defines the callback to call when a pad is released
  11264. * @param callback defines the callback to use
  11265. */
  11266. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  11267. private _setButtonValue(newValue, currentValue, buttonType);
  11268. private _setDPadValue(newValue, currentValue, buttonType);
  11269. /** Gets or sets value of A button */
  11270. buttonA: number;
  11271. /** Gets or sets value of B button */
  11272. buttonB: number;
  11273. /** Gets or sets value of X button */
  11274. buttonX: number;
  11275. /** Gets or sets value of Y button */
  11276. buttonY: number;
  11277. /** Gets or sets value of Start button */
  11278. buttonStart: number;
  11279. /** Gets or sets value of Back button */
  11280. buttonBack: number;
  11281. /** Gets or sets value of Left button */
  11282. buttonLB: number;
  11283. /** Gets or sets value of Right button */
  11284. buttonRB: number;
  11285. /** Gets or sets value of left stick */
  11286. buttonLeftStick: number;
  11287. /** Gets or sets value of right stick */
  11288. buttonRightStick: number;
  11289. /** Gets or sets value of DPad up */
  11290. dPadUp: number;
  11291. /** Gets or sets value of DPad down */
  11292. dPadDown: number;
  11293. /** Gets or sets value of DPad left */
  11294. dPadLeft: number;
  11295. /** Gets or sets value of DPad right */
  11296. dPadRight: number;
  11297. /**
  11298. * Force the gamepad to synchronize with device values
  11299. */
  11300. update(): void;
  11301. dispose(): void;
  11302. }
  11303. }
  11304. declare module BABYLON {
  11305. interface ILoadingScreen {
  11306. displayLoadingUI: () => void;
  11307. hideLoadingUI: () => void;
  11308. loadingUIBackgroundColor: string;
  11309. loadingUIText: string;
  11310. }
  11311. class DefaultLoadingScreen implements ILoadingScreen {
  11312. private _renderingCanvas;
  11313. private _loadingText;
  11314. private _loadingDivBackgroundColor;
  11315. private _loadingDiv;
  11316. private _loadingTextDiv;
  11317. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11318. displayLoadingUI(): void;
  11319. hideLoadingUI(): void;
  11320. loadingUIText: string;
  11321. loadingUIBackgroundColor: string;
  11322. private _resizeLoadingUI;
  11323. }
  11324. }
  11325. declare module BABYLON {
  11326. class SceneLoaderProgressEvent {
  11327. readonly lengthComputable: boolean;
  11328. readonly loaded: number;
  11329. readonly total: number;
  11330. constructor(lengthComputable: boolean, loaded: number, total: number);
  11331. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11332. }
  11333. interface ISceneLoaderPluginExtensions {
  11334. [extension: string]: {
  11335. isBinary: boolean;
  11336. };
  11337. }
  11338. interface ISceneLoaderPluginFactory {
  11339. name: string;
  11340. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11341. canDirectLoad?: (data: string) => boolean;
  11342. }
  11343. interface ISceneLoaderPlugin {
  11344. /**
  11345. * The friendly name of this plugin.
  11346. */
  11347. name: string;
  11348. /**
  11349. * The file extensions supported by this plugin.
  11350. */
  11351. extensions: string | ISceneLoaderPluginExtensions;
  11352. /**
  11353. * Import meshes into a scene.
  11354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11355. * @param scene The scene to import into
  11356. * @param data The data to import
  11357. * @param rootUrl The root url for scene and resources
  11358. * @param meshes The meshes array to import into
  11359. * @param particleSystems The particle systems array to import into
  11360. * @param skeletons The skeletons array to import into
  11361. * @param onError The callback when import fails
  11362. * @returns True if successful or false otherwise
  11363. */
  11364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11365. /**
  11366. * Load into a scene.
  11367. * @param scene The scene to load into
  11368. * @param data The data to import
  11369. * @param rootUrl The root url for scene and resources
  11370. * @param onError The callback when import fails
  11371. * @returns true if successful or false otherwise
  11372. */
  11373. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11374. /**
  11375. * The callback that returns true if the data can be directly loaded.
  11376. */
  11377. canDirectLoad?: (data: string) => boolean;
  11378. /**
  11379. * The callback that allows custom handling of the root url based on the response url.
  11380. */
  11381. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11382. /**
  11383. * Load into an asset container.
  11384. * @param scene The scene to load into
  11385. * @param data The data to import
  11386. * @param rootUrl The root url for scene and resources
  11387. * @param onError The callback when import fails
  11388. * @returns The loaded asset container
  11389. */
  11390. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11391. }
  11392. interface ISceneLoaderPluginAsync {
  11393. /**
  11394. * The friendly name of this plugin.
  11395. */
  11396. name: string;
  11397. /**
  11398. * The file extensions supported by this plugin.
  11399. */
  11400. extensions: string | ISceneLoaderPluginExtensions;
  11401. /**
  11402. * Import meshes into a scene.
  11403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11404. * @param scene The scene to import into
  11405. * @param data The data to import
  11406. * @param rootUrl The root url for scene and resources
  11407. * @param onProgress The callback when the load progresses
  11408. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11409. */
  11410. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11411. meshes: AbstractMesh[];
  11412. particleSystems: ParticleSystem[];
  11413. skeletons: Skeleton[];
  11414. animationGroups: AnimationGroup[];
  11415. }>;
  11416. /**
  11417. * Load into a scene.
  11418. * @param scene The scene to load into
  11419. * @param data The data to import
  11420. * @param rootUrl The root url for scene and resources
  11421. * @param onProgress The callback when the load progresses
  11422. * @returns Nothing
  11423. */
  11424. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11425. /**
  11426. * The callback that returns true if the data can be directly loaded.
  11427. */
  11428. canDirectLoad?: (data: string) => boolean;
  11429. /**
  11430. * The callback that allows custom handling of the root url based on the response url.
  11431. */
  11432. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11433. /**
  11434. * Load into an asset container.
  11435. * @param scene The scene to load into
  11436. * @param data The data to import
  11437. * @param rootUrl The root url for scene and resources
  11438. * @param onProgress The callback when the load progresses
  11439. * @returns The loaded asset container
  11440. */
  11441. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11442. }
  11443. class SceneLoader {
  11444. private static _ForceFullSceneLoadingForIncremental;
  11445. private static _ShowLoadingScreen;
  11446. private static _CleanBoneMatrixWeights;
  11447. static readonly NO_LOGGING: number;
  11448. static readonly MINIMAL_LOGGING: number;
  11449. static readonly SUMMARY_LOGGING: number;
  11450. static readonly DETAILED_LOGGING: number;
  11451. private static _loggingLevel;
  11452. static ForceFullSceneLoadingForIncremental: boolean;
  11453. static ShowLoadingScreen: boolean;
  11454. static loggingLevel: number;
  11455. static CleanBoneMatrixWeights: boolean;
  11456. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11457. private static _registeredPlugins;
  11458. private static _getDefaultPlugin();
  11459. private static _getPluginForExtension(extension);
  11460. private static _getPluginForDirectLoad(data);
  11461. private static _getPluginForFilename(sceneFilename);
  11462. private static _getDirectLoad(sceneFilename);
  11463. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11464. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11465. static IsPluginForExtensionAvailable(extension: string): boolean;
  11466. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11467. /**
  11468. * Import meshes into a scene
  11469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11470. * @param rootUrl a string that defines the root url for scene and resources
  11471. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11472. * @param scene the instance of BABYLON.Scene to append to
  11473. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11474. * @param onProgress a callback with a progress event for each file being loaded
  11475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11476. * @param pluginExtension the extension used to determine the plugin
  11477. * @returns The loaded plugin
  11478. */
  11479. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: 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>;
  11480. /**
  11481. * Import meshes into a scene
  11482. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11483. * @param rootUrl a string that defines the root url for scene and resources
  11484. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11485. * @param scene the instance of BABYLON.Scene to append to
  11486. * @param onProgress a callback with a progress event for each file being loaded
  11487. * @param pluginExtension the extension used to determine the plugin
  11488. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11489. */
  11490. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11491. meshes: AbstractMesh[];
  11492. particleSystems: ParticleSystem[];
  11493. skeletons: Skeleton[];
  11494. animationGroups: AnimationGroup[];
  11495. }>;
  11496. /**
  11497. * Load a scene
  11498. * @param rootUrl a string that defines the root url for scene and resources
  11499. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11500. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11501. * @param onSuccess a callback with the scene when import succeeds
  11502. * @param onProgress a callback with a progress event for each file being loaded
  11503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11504. * @param pluginExtension the extension used to determine the plugin
  11505. * @returns The loaded plugin
  11506. */
  11507. 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>;
  11508. /**
  11509. * Load a scene
  11510. * @param rootUrl a string that defines the root url for scene and resources
  11511. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11513. * @param onProgress a callback with a progress event for each file being loaded
  11514. * @param pluginExtension the extension used to determine the plugin
  11515. * @returns The loaded scene
  11516. */
  11517. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11518. /**
  11519. * Append a scene
  11520. * @param rootUrl a string that defines the root url for scene and resources
  11521. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11522. * @param scene is the instance of BABYLON.Scene to append to
  11523. * @param onSuccess a callback with the scene when import succeeds
  11524. * @param onProgress a callback with a progress event for each file being loaded
  11525. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11526. * @param pluginExtension the extension used to determine the plugin
  11527. * @returns The loaded plugin
  11528. */
  11529. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  11530. /**
  11531. * Append a scene
  11532. * @param rootUrl a string that defines the root url for scene and resources
  11533. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11534. * @param scene is the instance of BABYLON.Scene to append to
  11535. * @param onProgress a callback with a progress event for each file being loaded
  11536. * @param pluginExtension the extension used to determine the plugin
  11537. * @returns The given scene
  11538. */
  11539. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11540. /**
  11541. * Load a scene into an asset container
  11542. * @param rootUrl a string that defines the root url for scene and resources
  11543. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11544. * @param scene is the instance of BABYLON.Scene to append to
  11545. * @param onSuccess a callback with the scene when import succeeds
  11546. * @param onProgress a callback with a progress event for each file being loaded
  11547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11548. * @param pluginExtension the extension used to determine the plugin
  11549. * @returns The loaded plugin
  11550. */
  11551. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  11552. /**
  11553. * Load a scene into an asset container
  11554. * @param rootUrl a string that defines the root url for scene and resources
  11555. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11556. * @param scene is the instance of BABYLON.Scene to append to
  11557. * @param onProgress a callback with a progress event for each file being loaded
  11558. * @param pluginExtension the extension used to determine the plugin
  11559. * @returns The loaded asset container
  11560. */
  11561. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11562. }
  11563. }
  11564. declare module BABYLON {
  11565. class Scalar {
  11566. /**
  11567. * Two pi constants convenient for computation.
  11568. */
  11569. static TwoPi: number;
  11570. /**
  11571. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  11572. */
  11573. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  11574. /**
  11575. * Returns a string : the upper case translation of the number i to hexadecimal.
  11576. */
  11577. static ToHex(i: number): string;
  11578. /**
  11579. * Returns -1 if value is negative and +1 is value is positive.
  11580. * Returns the value itself if it's equal to zero.
  11581. */
  11582. static Sign(value: number): number;
  11583. /**
  11584. * Returns the value itself if it's between min and max.
  11585. * Returns min if the value is lower than min.
  11586. * Returns max if the value is greater than max.
  11587. */
  11588. static Clamp(value: number, min?: number, max?: number): number;
  11589. /**
  11590. * Returns the log2 of value.
  11591. */
  11592. static Log2(value: number): number;
  11593. /**
  11594. * Loops the value, so that it is never larger than length and never smaller than 0.
  11595. *
  11596. * This is similar to the modulo operator but it works with floating point numbers.
  11597. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  11598. * With t = 5 and length = 2.5, the result would be 0.0.
  11599. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  11600. */
  11601. static Repeat(value: number, length: number): number;
  11602. /**
  11603. * Normalize the value between 0.0 and 1.0 using min and max values
  11604. */
  11605. static Normalize(value: number, min: number, max: number): number;
  11606. /**
  11607. * Denormalize the value from 0.0 and 1.0 using min and max values
  11608. */
  11609. static Denormalize(normalized: number, min: number, max: number): number;
  11610. /**
  11611. * Calculates the shortest difference between two given angles given in degrees.
  11612. */
  11613. static DeltaAngle(current: number, target: number): number;
  11614. /**
  11615. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  11616. *
  11617. * The returned value will move back and forth between 0 and length
  11618. */
  11619. static PingPong(tx: number, length: number): number;
  11620. /**
  11621. * Interpolates between min and max with smoothing at the limits.
  11622. *
  11623. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  11624. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  11625. */
  11626. static SmoothStep(from: number, to: number, tx: number): number;
  11627. /**
  11628. * Moves a value current towards target.
  11629. *
  11630. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  11631. * Negative values of maxDelta pushes the value away from target.
  11632. */
  11633. static MoveTowards(current: number, target: number, maxDelta: number): number;
  11634. /**
  11635. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11636. *
  11637. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  11638. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  11639. */
  11640. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  11641. /**
  11642. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  11643. */
  11644. static Lerp(start: number, end: number, amount: number): number;
  11645. /**
  11646. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11647. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  11648. */
  11649. static LerpAngle(start: number, end: number, amount: number): number;
  11650. /**
  11651. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  11652. */
  11653. static InverseLerp(a: number, b: number, value: number): number;
  11654. /**
  11655. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  11656. */
  11657. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  11658. /**
  11659. * Returns a random float number between and min and max values
  11660. */
  11661. static RandomRange(min: number, max: number): number;
  11662. /**
  11663. * This function returns percentage of a number in a given range.
  11664. *
  11665. * RangeToPercent(40,20,60) will return 0.5 (50%)
  11666. * RangeToPercent(34,0,100) will return 0.34 (34%)
  11667. */
  11668. static RangeToPercent(number: number, min: number, max: number): number;
  11669. /**
  11670. * This function returns number that corresponds to the percentage in a given range.
  11671. *
  11672. * PercentToRange(0.34,0,100) will return 34.
  11673. */
  11674. static PercentToRange(percent: number, min: number, max: number): number;
  11675. /**
  11676. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  11677. * @param angle The angle to normalize in radian.
  11678. * @return The converted angle.
  11679. */
  11680. static NormalizeRadians(angle: number): number;
  11681. }
  11682. }
  11683. declare module BABYLON {
  11684. const ToGammaSpace: number;
  11685. const ToLinearSpace = 2.2;
  11686. const Epsilon = 0.001;
  11687. /**
  11688. * Class used to hold a RBG color
  11689. */
  11690. class Color3 {
  11691. /**
  11692. * Defines the red component (between 0 and 1, default is 0)
  11693. */
  11694. r: number;
  11695. /**
  11696. * Defines the green component (between 0 and 1, default is 0)
  11697. */
  11698. g: number;
  11699. /**
  11700. * Defines the blue component (between 0 and 1, default is 0)
  11701. */
  11702. b: number;
  11703. /**
  11704. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  11705. * @param r defines the red component (between 0 and 1, default is 0)
  11706. * @param g defines the green component (between 0 and 1, default is 0)
  11707. * @param b defines the blue component (between 0 and 1, default is 0)
  11708. */
  11709. constructor(
  11710. /**
  11711. * Defines the red component (between 0 and 1, default is 0)
  11712. */
  11713. r?: number,
  11714. /**
  11715. * Defines the green component (between 0 and 1, default is 0)
  11716. */
  11717. g?: number,
  11718. /**
  11719. * Defines the blue component (between 0 and 1, default is 0)
  11720. */
  11721. b?: number);
  11722. /**
  11723. * Creates a string with the Color3 current values
  11724. * @returns the string representation of the Color3 object
  11725. */
  11726. toString(): string;
  11727. /**
  11728. * Returns the string "Color3"
  11729. * @returns "Color3"
  11730. */
  11731. getClassName(): string;
  11732. /**
  11733. * Compute the Color3 hash code
  11734. * @returns an unique number that can be used to hash Color3 objects
  11735. */
  11736. getHashCode(): number;
  11737. /**
  11738. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  11739. * @param array defines the array where to store the r,g,b components
  11740. * @param index defines an optional index in the target array to define where to start storing values
  11741. * @returns the current Color3 object
  11742. */
  11743. toArray(array: FloatArray, index?: number): Color3;
  11744. /**
  11745. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  11746. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  11747. * @returns a new {BABYLON.Color4} object
  11748. */
  11749. toColor4(alpha?: number): Color4;
  11750. /**
  11751. * Returns a new array populated with 3 numeric elements : red, green and blue values
  11752. * @returns the new array
  11753. */
  11754. asArray(): number[];
  11755. /**
  11756. * Returns the luminance value
  11757. * @returns a float value
  11758. */
  11759. toLuminance(): number;
  11760. /**
  11761. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  11762. * @param otherColor defines the second operand
  11763. * @returns the new Color3 object
  11764. */
  11765. multiply(otherColor: Color3): Color3;
  11766. /**
  11767. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  11768. * @param otherColor defines the second operand
  11769. * @param result defines the Color3 object where to store the result
  11770. * @returns the current Color3
  11771. */
  11772. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  11773. /**
  11774. * Determines equality between Color3 objects
  11775. * @param otherColor defines the second operand
  11776. * @returns true if the rgb values are equal to the given ones
  11777. */
  11778. equals(otherColor: Color3): boolean;
  11779. /**
  11780. * Determines equality between the current Color3 object and a set of r,b,g values
  11781. * @param r defines the red component to check
  11782. * @param g defines the green component to check
  11783. * @param b defines the blue component to check
  11784. * @returns true if the rgb values are equal to the given ones
  11785. */
  11786. equalsFloats(r: number, g: number, b: number): boolean;
  11787. /**
  11788. * Multiplies in place each rgb value by scale
  11789. * @param scale defines the scaling factor
  11790. * @returns the updated Color3
  11791. */
  11792. scale(scale: number): Color3;
  11793. /**
  11794. * Multiplies the rgb values by scale and stores the result into "result"
  11795. * @param scale defines the scaling factor
  11796. * @param result defines the Color3 object where to store the result
  11797. * @returns the unmodified current Color3
  11798. */
  11799. scaleToRef(scale: number, result: Color3): Color3;
  11800. /**
  11801. * Scale the current Color3 values by a factor and add the result to a given Color3
  11802. * @param scale defines the scale factor
  11803. * @param result defines color to store the result into
  11804. * @returns the unmodified current Color3
  11805. */
  11806. scaleAndAddToRef(scale: number, result: Color3): Color3;
  11807. /**
  11808. * Clamps the rgb values by the min and max values and stores the result into "result"
  11809. * @param min defines minimum clamping value (default is 0)
  11810. * @param max defines maximum clamping value (default is 1)
  11811. * @param result defines color to store the result into
  11812. * @returns the original Color3
  11813. */
  11814. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  11815. /**
  11816. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  11817. * @param otherColor defines the second operand
  11818. * @returns the new Color3
  11819. */
  11820. add(otherColor: Color3): Color3;
  11821. /**
  11822. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  11823. * @param otherColor defines the second operand
  11824. * @param result defines Color3 object to store the result into
  11825. * @returns the unmodified current Color3
  11826. */
  11827. addToRef(otherColor: Color3, result: Color3): Color3;
  11828. /**
  11829. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  11830. * @param otherColor defines the second operand
  11831. * @returns the new Color3
  11832. */
  11833. subtract(otherColor: Color3): Color3;
  11834. /**
  11835. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  11836. * @param otherColor defines the second operand
  11837. * @param result defines Color3 object to store the result into
  11838. * @returns the unmodified current Color3
  11839. */
  11840. subtractToRef(otherColor: Color3, result: Color3): Color3;
  11841. /**
  11842. * Copy the current object
  11843. * @returns a new Color3 copied the current one
  11844. */
  11845. clone(): Color3;
  11846. /**
  11847. * Copies the rgb values from the source in the current Color3
  11848. * @param source defines the source Color3 object
  11849. * @returns the updated Color3 object
  11850. */
  11851. copyFrom(source: Color3): Color3;
  11852. /**
  11853. * Updates the Color3 rgb values from the given floats
  11854. * @param r defines the red component to read from
  11855. * @param g defines the green component to read from
  11856. * @param b defines the blue component to read from
  11857. * @returns the current Color3 object
  11858. */
  11859. copyFromFloats(r: number, g: number, b: number): Color3;
  11860. /**
  11861. * Updates the Color3 rgb values from the given floats
  11862. * @param r defines the red component to read from
  11863. * @param g defines the green component to read from
  11864. * @param b defines the blue component to read from
  11865. * @returns the current Color3 object
  11866. */
  11867. set(r: number, g: number, b: number): Color3;
  11868. /**
  11869. * Compute the Color3 hexadecimal code as a string
  11870. * @returns a string containing the hexadecimal representation of the Color3 object
  11871. */
  11872. toHexString(): string;
  11873. /**
  11874. * Computes a new Color3 converted from the current one to linear space
  11875. * @returns a new Color3 object
  11876. */
  11877. toLinearSpace(): Color3;
  11878. /**
  11879. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  11880. * @param convertedColor defines the Color3 object where to store the linear space version
  11881. * @returns the unmodified Color3
  11882. */
  11883. toLinearSpaceToRef(convertedColor: Color3): Color3;
  11884. /**
  11885. * Computes a new Color3 converted from the current one to gamma space
  11886. * @returns a new Color3 object
  11887. */
  11888. toGammaSpace(): Color3;
  11889. /**
  11890. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  11891. * @param convertedColor defines the Color3 object where to store the gamma space version
  11892. * @returns the unmodified Color3
  11893. */
  11894. toGammaSpaceToRef(convertedColor: Color3): Color3;
  11895. /**
  11896. * Creates a new Color3 from the string containing valid hexadecimal values
  11897. * @param hex defines a string containing valid hexadecimal values
  11898. * @returns a new Color3 object
  11899. */
  11900. static FromHexString(hex: string): Color3;
  11901. /**
  11902. * Creates a new Vector3 from the starting index of the given array
  11903. * @param array defines the source array
  11904. * @param offset defines an offset in the source array
  11905. * @returns a new Color3 object
  11906. */
  11907. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  11908. /**
  11909. * Creates a new Color3 from integer values (< 256)
  11910. * @param r defines the red component to read from (value between 0 and 255)
  11911. * @param g defines the green component to read from (value between 0 and 255)
  11912. * @param b defines the blue component to read from (value between 0 and 255)
  11913. * @returns a new Color3 object
  11914. */
  11915. static FromInts(r: number, g: number, b: number): Color3;
  11916. /**
  11917. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  11918. * @param start defines the start Color3 value
  11919. * @param end defines the end Color3 value
  11920. * @param amount defines the gradient value between start and end
  11921. * @returns a new Color3 object
  11922. */
  11923. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  11924. /**
  11925. * Returns a Color3 value containing a red color
  11926. * @returns a new Color3 object
  11927. */
  11928. static Red(): Color3;
  11929. /**
  11930. * Returns a Color3 value containing a green color
  11931. * @returns a new Color3 object
  11932. */
  11933. static Green(): Color3;
  11934. /**
  11935. * Returns a Color3 value containing a blue color
  11936. * @returns a new Color3 object
  11937. */
  11938. static Blue(): Color3;
  11939. /**
  11940. * Returns a Color3 value containing a black color
  11941. * @returns a new Color3 object
  11942. */
  11943. static Black(): Color3;
  11944. /**
  11945. * Returns a Color3 value containing a white color
  11946. * @returns a new Color3 object
  11947. */
  11948. static White(): Color3;
  11949. /**
  11950. * Returns a Color3 value containing a purple color
  11951. * @returns a new Color3 object
  11952. */
  11953. static Purple(): Color3;
  11954. /**
  11955. * Returns a Color3 value containing a magenta color
  11956. * @returns a new Color3 object
  11957. */
  11958. static Magenta(): Color3;
  11959. /**
  11960. * Returns a Color3 value containing a yellow color
  11961. * @returns a new Color3 object
  11962. */
  11963. static Yellow(): Color3;
  11964. /**
  11965. * Returns a Color3 value containing a gray color
  11966. * @returns a new Color3 object
  11967. */
  11968. static Gray(): Color3;
  11969. /**
  11970. * Returns a Color3 value containing a teal color
  11971. * @returns a new Color3 object
  11972. */
  11973. static Teal(): Color3;
  11974. /**
  11975. * Returns a Color3 value containing a random color
  11976. * @returns a new Color3 object
  11977. */
  11978. static Random(): Color3;
  11979. }
  11980. /**
  11981. * Class used to hold a RBGA color
  11982. */
  11983. class Color4 {
  11984. /**
  11985. * Defines the red component (between 0 and 1, default is 0)
  11986. */
  11987. r: number;
  11988. /**
  11989. * Defines the green component (between 0 and 1, default is 0)
  11990. */
  11991. g: number;
  11992. /**
  11993. * Defines the blue component (between 0 and 1, default is 0)
  11994. */
  11995. b: number;
  11996. /**
  11997. * Defines the alpha component (between 0 and 1, default is 1)
  11998. */
  11999. a: number;
  12000. /**
  12001. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12002. * @param r defines the red component (between 0 and 1, default is 0)
  12003. * @param g defines the green component (between 0 and 1, default is 0)
  12004. * @param b defines the blue component (between 0 and 1, default is 0)
  12005. * @param a defines the alpha component (between 0 and 1, default is 1)
  12006. */
  12007. constructor(
  12008. /**
  12009. * Defines the red component (between 0 and 1, default is 0)
  12010. */
  12011. r?: number,
  12012. /**
  12013. * Defines the green component (between 0 and 1, default is 0)
  12014. */
  12015. g?: number,
  12016. /**
  12017. * Defines the blue component (between 0 and 1, default is 0)
  12018. */
  12019. b?: number,
  12020. /**
  12021. * Defines the alpha component (between 0 and 1, default is 1)
  12022. */
  12023. a?: number);
  12024. /**
  12025. * Adds in place the given Color4 values to the current Color4 object
  12026. * @param right defines the second operand
  12027. * @returns the current updated Color4 object
  12028. */
  12029. addInPlace(right: Color4): Color4;
  12030. /**
  12031. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12032. * @returns the new array
  12033. */
  12034. asArray(): number[];
  12035. /**
  12036. * Stores from the starting index in the given array the Color4 successive values
  12037. * @param array defines the array where to store the r,g,b components
  12038. * @param index defines an optional index in the target array to define where to start storing values
  12039. * @returns the current Color4 object
  12040. */
  12041. toArray(array: number[], index?: number): Color4;
  12042. /**
  12043. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12044. * @param right defines the second operand
  12045. * @returns a new Color4 object
  12046. */
  12047. add(right: Color4): Color4;
  12048. /**
  12049. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12050. * @param right defines the second operand
  12051. * @returns a new Color4 object
  12052. */
  12053. subtract(right: Color4): Color4;
  12054. /**
  12055. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12056. * @param right defines the second operand
  12057. * @param result defines the Color4 object where to store the result
  12058. * @returns the current Color4 object
  12059. */
  12060. subtractToRef(right: Color4, result: Color4): Color4;
  12061. /**
  12062. * Creates a new Color4 with the current Color4 values multiplied by scale
  12063. * @param scale defines the scaling factor to apply
  12064. * @returns a new Color4 object
  12065. */
  12066. scale(scale: number): Color4;
  12067. /**
  12068. * Multiplies the current Color4 values by scale and stores the result in "result"
  12069. * @param scale defines the scaling factor to apply
  12070. * @param result defines the Color4 object where to store the result
  12071. * @returns the current unmodified Color4
  12072. */
  12073. scaleToRef(scale: number, result: Color4): Color4;
  12074. /**
  12075. * Scale the current Color4 values by a factor and add the result to a given Color4
  12076. * @param scale defines the scale factor
  12077. * @param result defines the Color4 object where to store the result
  12078. * @returns the unmodified current Color4
  12079. */
  12080. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12081. /**
  12082. * Clamps the rgb values by the min and max values and stores the result into "result"
  12083. * @param min defines minimum clamping value (default is 0)
  12084. * @param max defines maximum clamping value (default is 1)
  12085. * @param result defines color to store the result into.
  12086. * @returns the cuurent Color4
  12087. */
  12088. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12089. /**
  12090. * Multipy an Color4 value by another and return a new Color4 object
  12091. * @param color defines the Color4 value to multiply by
  12092. * @returns a new Color4 object
  12093. */
  12094. multiply(color: Color4): Color4;
  12095. /**
  12096. * Multipy a Color4 value by another and push the result in a reference value
  12097. * @param color defines the Color4 value to multiply by
  12098. * @param result defines the Color4 to fill the result in
  12099. * @returns the result Color4
  12100. */
  12101. multiplyToRef(color: Color4, result: Color4): Color4;
  12102. /**
  12103. * Creates a string with the Color4 current values
  12104. * @returns the string representation of the Color4 object
  12105. */
  12106. toString(): string;
  12107. /**
  12108. * Returns the string "Color4"
  12109. * @returns "Color4"
  12110. */
  12111. getClassName(): string;
  12112. /**
  12113. * Compute the Color4 hash code
  12114. * @returns an unique number that can be used to hash Color4 objects
  12115. */
  12116. getHashCode(): number;
  12117. /**
  12118. * Creates a new Color4 copied from the current one
  12119. * @returns a new Color4 object
  12120. */
  12121. clone(): Color4;
  12122. /**
  12123. * Copies the given Color4 values into the current one
  12124. * @param source defines the source Color4 object
  12125. * @returns the current updated Color4 object
  12126. */
  12127. copyFrom(source: Color4): Color4;
  12128. /**
  12129. * Copies the given float values into the current one
  12130. * @param r defines the red component to read from
  12131. * @param g defines the green component to read from
  12132. * @param b defines the blue component to read from
  12133. * @param a defines the alpha component to read from
  12134. * @returns the current updated Color4 object
  12135. */
  12136. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12137. /**
  12138. * Copies the given float values into the current one
  12139. * @param r defines the red component to read from
  12140. * @param g defines the green component to read from
  12141. * @param b defines the blue component to read from
  12142. * @param a defines the alpha component to read from
  12143. * @returns the current updated Color4 object
  12144. */
  12145. set(r: number, g: number, b: number, a: number): Color4;
  12146. /**
  12147. * Compute the Color4 hexadecimal code as a string
  12148. * @returns a string containing the hexadecimal representation of the Color4 object
  12149. */
  12150. toHexString(): string;
  12151. /**
  12152. * Computes a new Color4 converted from the current one to linear space
  12153. * @returns a new Color4 object
  12154. */
  12155. toLinearSpace(): Color4;
  12156. /**
  12157. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12158. * @param convertedColor defines the Color4 object where to store the linear space version
  12159. * @returns the unmodified Color4
  12160. */
  12161. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12162. /**
  12163. * Computes a new Color4 converted from the current one to gamma space
  12164. * @returns a new Color4 object
  12165. */
  12166. toGammaSpace(): Color4;
  12167. /**
  12168. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12169. * @param convertedColor defines the Color4 object where to store the gamma space version
  12170. * @returns the unmodified Color4
  12171. */
  12172. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12173. /**
  12174. * Creates a new Color4 from the string containing valid hexadecimal values
  12175. * @param hex defines a string containing valid hexadecimal values
  12176. * @returns a new Color4 object
  12177. */
  12178. static FromHexString(hex: string): Color4;
  12179. /**
  12180. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12181. * @param left defines the start value
  12182. * @param right defines the end value
  12183. * @param amount defines the gradient factor
  12184. * @returns a new Color4 object
  12185. */
  12186. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12187. /**
  12188. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12189. * @param left defines the start value
  12190. * @param right defines the end value
  12191. * @param amount defines the gradient factor
  12192. * @param result defines the Color4 object where to store data
  12193. */
  12194. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12195. /**
  12196. * Creates a new Color4 from the starting index element of the given array
  12197. * @param array defines the source array to read from
  12198. * @param offset defines the offset in the source array
  12199. * @returns a new Color4 object
  12200. */
  12201. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12202. /**
  12203. * Creates a new Color3 from integer values (< 256)
  12204. * @param r defines the red component to read from (value between 0 and 255)
  12205. * @param g defines the green component to read from (value between 0 and 255)
  12206. * @param b defines the blue component to read from (value between 0 and 255)
  12207. * @param a defines the alpha component to read from (value between 0 and 255)
  12208. * @returns a new Color3 object
  12209. */
  12210. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12211. /**
  12212. * Check the content of a given array and convert it to an array containing RGBA data
  12213. * If the original array was already containing count * 4 values then it is returned directly
  12214. * @param colors defines the array to check
  12215. * @param count defines the number of RGBA data to expect
  12216. * @returns an array containing count * 4 values (RGBA)
  12217. */
  12218. static CheckColors4(colors: number[], count: number): number[];
  12219. }
  12220. /**
  12221. * Class representing a vector containing 2 coordinates
  12222. */
  12223. class Vector2 {
  12224. /** defines the first coordinate */
  12225. x: number;
  12226. /** defines the second coordinate */
  12227. y: number;
  12228. /**
  12229. * Creates a new Vector2 from the given x and y coordinates
  12230. * @param x defines the first coordinate
  12231. * @param y defines the second coordinate
  12232. */
  12233. constructor(
  12234. /** defines the first coordinate */
  12235. x: number,
  12236. /** defines the second coordinate */
  12237. y: number);
  12238. /**
  12239. * Gets a string with the Vector2 coordinates
  12240. * @returns a string with the Vector2 coordinates
  12241. */
  12242. toString(): string;
  12243. /**
  12244. * Gets class name
  12245. * @returns the string "Vector2"
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Gets current vector hash code
  12250. * @returns the Vector2 hash code as a number
  12251. */
  12252. getHashCode(): number;
  12253. /**
  12254. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  12255. * @param array defines the source array
  12256. * @param index defines the offset in source array
  12257. * @returns the current Vector2
  12258. */
  12259. toArray(array: FloatArray, index?: number): Vector2;
  12260. /**
  12261. * Copy the current vector to an array
  12262. * @returns a new array with 2 elements: the Vector2 coordinates.
  12263. */
  12264. asArray(): number[];
  12265. /**
  12266. * Sets the Vector2 coordinates with the given Vector2 coordinates
  12267. * @param source defines the source Vector2
  12268. * @returns the current updated Vector2
  12269. */
  12270. copyFrom(source: Vector2): Vector2;
  12271. /**
  12272. * Sets the Vector2 coordinates with the given floats
  12273. * @param x defines the first coordinate
  12274. * @param y defines the second coordinate
  12275. * @returns the current updated Vector2
  12276. */
  12277. copyFromFloats(x: number, y: number): Vector2;
  12278. /**
  12279. * Sets the Vector2 coordinates with the given floats
  12280. * @param x defines the first coordinate
  12281. * @param y defines the second coordinate
  12282. * @returns the current updated Vector2
  12283. */
  12284. set(x: number, y: number): Vector2;
  12285. /**
  12286. * Add another vector with the current one
  12287. * @param otherVector defines the other vector
  12288. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  12289. */
  12290. add(otherVector: Vector2): Vector2;
  12291. /**
  12292. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  12293. * @param otherVector defines the other vector
  12294. * @param result defines the target vector
  12295. * @returns the unmodified current Vector2
  12296. */
  12297. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  12298. /**
  12299. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  12300. * @param otherVector defines the other vector
  12301. * @returns the current updated Vector2
  12302. */
  12303. addInPlace(otherVector: Vector2): Vector2;
  12304. /**
  12305. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  12306. * @param otherVector defines the other vector
  12307. * @returns a new Vector2
  12308. */
  12309. addVector3(otherVector: Vector3): Vector2;
  12310. /**
  12311. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  12312. * @param otherVector defines the other vector
  12313. * @returns a new Vector2
  12314. */
  12315. subtract(otherVector: Vector2): Vector2;
  12316. /**
  12317. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  12318. * @param otherVector defines the other vector
  12319. * @param result defines the target vector
  12320. * @returns the unmodified current Vector2
  12321. */
  12322. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  12323. /**
  12324. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  12325. * @param otherVector defines the other vector
  12326. * @returns the current updated Vector2
  12327. */
  12328. subtractInPlace(otherVector: Vector2): Vector2;
  12329. /**
  12330. * Multiplies in place the current Vector2 coordinates by the given ones
  12331. * @param otherVector defines the other vector
  12332. * @returns the current updated Vector2
  12333. */
  12334. multiplyInPlace(otherVector: Vector2): Vector2;
  12335. /**
  12336. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  12337. * @param otherVector defines the other vector
  12338. * @returns a new Vector2
  12339. */
  12340. multiply(otherVector: Vector2): Vector2;
  12341. /**
  12342. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  12343. * @param otherVector defines the other vector
  12344. * @param result defines the target vector
  12345. * @returns the unmodified current Vector2
  12346. */
  12347. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  12348. /**
  12349. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  12350. * @param x defines the first coordinate
  12351. * @param y defines the second coordinate
  12352. * @returns a new Vector2
  12353. */
  12354. multiplyByFloats(x: number, y: number): Vector2;
  12355. /**
  12356. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  12357. * @param otherVector defines the other vector
  12358. * @returns a new Vector2
  12359. */
  12360. divide(otherVector: Vector2): Vector2;
  12361. /**
  12362. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  12363. * @param otherVector defines the other vector
  12364. * @param result defines the target vector
  12365. * @returns the unmodified current Vector2
  12366. */
  12367. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  12368. /**
  12369. * Divides the current Vector3 coordinates by the given ones
  12370. * @param otherVector defines the other vector
  12371. * @returns the current updated Vector2
  12372. */
  12373. divideInPlace(otherVector: Vector2): Vector2;
  12374. /**
  12375. * Gets a new Vector2 with current Vector2 negated coordinates
  12376. * @returns a new Vector2
  12377. */
  12378. negate(): Vector2;
  12379. /**
  12380. * Multiply the Vector2 coordinates by scale
  12381. * @param scale defines the scaling factor
  12382. * @returns the current updated Vector2
  12383. */
  12384. scaleInPlace(scale: number): Vector2;
  12385. /**
  12386. * Returns a new Vector2 scaled by "scale" from the current Vector2
  12387. * @param scale defines the scaling factor
  12388. * @returns a new Vector2
  12389. */
  12390. scale(scale: number): Vector2;
  12391. /**
  12392. * Scale the current Vector2 values by a factor to a given Vector2
  12393. * @param scale defines the scale factor
  12394. * @param result defines the Vector2 object where to store the result
  12395. * @returns the unmodified current Vector2
  12396. */
  12397. scaleToRef(scale: number, result: Vector2): Vector2;
  12398. /**
  12399. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  12400. * @param scale defines the scale factor
  12401. * @param result defines the Vector2 object where to store the result
  12402. * @returns the unmodified current Vector2
  12403. */
  12404. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  12405. /**
  12406. * Gets a boolean if two vectors are equals
  12407. * @param otherVector defines the other vector
  12408. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  12409. */
  12410. equals(otherVector: Vector2): boolean;
  12411. /**
  12412. * Gets a boolean if two vectors are equals (using an epsilon value)
  12413. * @param otherVector defines the other vector
  12414. * @param epsilon defines the minimal distance to consider equality
  12415. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  12416. */
  12417. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  12418. /**
  12419. * Gets the length of the vector
  12420. * @returns the vector length (float)
  12421. */
  12422. length(): number;
  12423. /**
  12424. * Gets the vector squared length
  12425. * @returns the vector squared length (float)
  12426. */
  12427. lengthSquared(): number;
  12428. /**
  12429. * Normalize the vector
  12430. * @returns the current updated Vector2
  12431. */
  12432. normalize(): Vector2;
  12433. /**
  12434. * Gets a new Vector2 copied from the Vector2
  12435. * @returns a new Vector2
  12436. */
  12437. clone(): Vector2;
  12438. /**
  12439. * Gets a new Vector2(0, 0)
  12440. * @returns a new Vector2
  12441. */
  12442. static Zero(): Vector2;
  12443. /**
  12444. * Gets a new Vector2(1, 1)
  12445. * @returns a new Vector2
  12446. */
  12447. static One(): Vector2;
  12448. /**
  12449. * Gets a new Vector2 set from the given index element of the given array
  12450. * @param array defines the data source
  12451. * @param offset defines the offset in the data source
  12452. * @returns a new Vector2
  12453. */
  12454. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  12455. /**
  12456. * Sets "result" from the given index element of the given array
  12457. * @param array defines the data source
  12458. * @param offset defines the offset in the data source
  12459. * @param result defines the target vector
  12460. */
  12461. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  12462. /**
  12463. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  12464. * @param value1 defines 1st point of control
  12465. * @param value2 defines 2nd point of control
  12466. * @param value3 defines 3rd point of control
  12467. * @param value4 defines 4th point of control
  12468. * @param amount defines the interpolation factor
  12469. * @returns a new Vector2
  12470. */
  12471. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  12472. /**
  12473. * 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".
  12474. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  12475. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  12476. * @param value defines the value to clamp
  12477. * @param min defines the lower limit
  12478. * @param max defines the upper limit
  12479. * @returns a new Vector2
  12480. */
  12481. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  12482. /**
  12483. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  12484. * @param value1 defines the 1st control point
  12485. * @param tangent1 defines the outgoing tangent
  12486. * @param value2 defines the 2nd control point
  12487. * @param tangent2 defines the incoming tangent
  12488. * @param amount defines the interpolation factor
  12489. * @returns a new Vector2
  12490. */
  12491. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  12492. /**
  12493. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  12494. * @param start defines the start vector
  12495. * @param end defines the end vector
  12496. * @param amount defines the interpolation factor
  12497. * @returns a new Vector2
  12498. */
  12499. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  12500. /**
  12501. * Gets the dot product of the vector "left" and the vector "right"
  12502. * @param left defines first vector
  12503. * @param right defines second vector
  12504. * @returns the dot product (float)
  12505. */
  12506. static Dot(left: Vector2, right: Vector2): number;
  12507. /**
  12508. * Returns a new Vector2 equal to the normalized given vector
  12509. * @param vector defines the vector to normalize
  12510. * @returns a new Vector2
  12511. */
  12512. static Normalize(vector: Vector2): Vector2;
  12513. /**
  12514. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  12515. * @param left defines 1st vector
  12516. * @param right defines 2nd vector
  12517. * @returns a new Vector2
  12518. */
  12519. static Minimize(left: Vector2, right: Vector2): Vector2;
  12520. /**
  12521. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  12522. * @param left defines 1st vector
  12523. * @param right defines 2nd vector
  12524. * @returns a new Vector2
  12525. */
  12526. static Maximize(left: Vector2, right: Vector2): Vector2;
  12527. /**
  12528. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  12529. * @param vector defines the vector to transform
  12530. * @param transformation defines the matrix to apply
  12531. * @returns a new Vector2
  12532. */
  12533. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  12534. /**
  12535. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  12536. * @param vector defines the vector to transform
  12537. * @param transformation defines the matrix to apply
  12538. * @param result defines the target vector
  12539. */
  12540. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  12541. /**
  12542. * Determines if a given vector is included in a triangle
  12543. * @param p defines the vector to test
  12544. * @param p0 defines 1st triangle point
  12545. * @param p1 defines 2nd triangle point
  12546. * @param p2 defines 3rd triangle point
  12547. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  12548. */
  12549. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  12550. /**
  12551. * Gets the distance between the vectors "value1" and "value2"
  12552. * @param value1 defines first vector
  12553. * @param value2 defines second vector
  12554. * @returns the distance between vectors
  12555. */
  12556. static Distance(value1: Vector2, value2: Vector2): number;
  12557. /**
  12558. * Returns the squared distance between the vectors "value1" and "value2"
  12559. * @param value1 defines first vector
  12560. * @param value2 defines second vector
  12561. * @returns the squared distance between vectors
  12562. */
  12563. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  12564. /**
  12565. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  12566. * @param value1 defines first vector
  12567. * @param value2 defines second vector
  12568. * @returns a new Vector2
  12569. */
  12570. static Center(value1: Vector2, value2: Vector2): Vector2;
  12571. /**
  12572. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  12573. * @param p defines the middle point
  12574. * @param segA defines one point of the segment
  12575. * @param segB defines the other point of the segment
  12576. * @returns the shortest distance
  12577. */
  12578. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  12579. }
  12580. /**
  12581. * Classed used to store (x,y,z) vector representation
  12582. * A Vector3 is the main object used in 3D geometry
  12583. * It can represent etiher the coordinates of a point the space, either a direction
  12584. * Reminder: Babylon.js uses a left handed forward facing system
  12585. */
  12586. class Vector3 {
  12587. /**
  12588. * Defines the first coordinates (on X axis)
  12589. */
  12590. x: number;
  12591. /**
  12592. * Defines the second coordinates (on Y axis)
  12593. */
  12594. y: number;
  12595. /**
  12596. * Defines the third coordinates (on Z axis)
  12597. */
  12598. z: number;
  12599. /**
  12600. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  12601. * @param x defines the first coordinates (on X axis)
  12602. * @param y defines the second coordinates (on Y axis)
  12603. * @param z defines the third coordinates (on Z axis)
  12604. */
  12605. constructor(
  12606. /**
  12607. * Defines the first coordinates (on X axis)
  12608. */
  12609. x: number,
  12610. /**
  12611. * Defines the second coordinates (on Y axis)
  12612. */
  12613. y: number,
  12614. /**
  12615. * Defines the third coordinates (on Z axis)
  12616. */
  12617. z: number);
  12618. /**
  12619. * Creates a string representation of the Vector3
  12620. * @returns a string with the Vector3 coordinates.
  12621. */
  12622. toString(): string;
  12623. /**
  12624. * Gets the class name
  12625. * @returns the string "Vector3"
  12626. */
  12627. getClassName(): string;
  12628. /**
  12629. * Creates the Vector3 hash code
  12630. * @returns a number which tends to be unique between Vector3 instances
  12631. */
  12632. getHashCode(): number;
  12633. /**
  12634. * Creates an array containing three elements : the coordinates of the Vector3
  12635. * @returns a new array of numbers
  12636. */
  12637. asArray(): number[];
  12638. /**
  12639. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  12640. * @param array defines the destination array
  12641. * @param index defines the offset in the destination array
  12642. * @returns the current Vector3
  12643. */
  12644. toArray(array: FloatArray, index?: number): Vector3;
  12645. /**
  12646. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  12647. * @returns a new Quaternion object, computed from the Vector3 coordinates
  12648. */
  12649. toQuaternion(): Quaternion;
  12650. /**
  12651. * Adds the given vector to the current Vector3
  12652. * @param otherVector defines the second operand
  12653. * @returns the current updated Vector3
  12654. */
  12655. addInPlace(otherVector: Vector3): Vector3;
  12656. /**
  12657. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  12658. * @param otherVector defines the second operand
  12659. * @returns the resulting Vector3
  12660. */
  12661. add(otherVector: Vector3): Vector3;
  12662. /**
  12663. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  12664. * @param otherVector defines the second operand
  12665. * @param result defines the Vector3 object where to store the result
  12666. * @returns the current Vector3
  12667. */
  12668. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  12669. /**
  12670. * Subtract the given vector from the current Vector3
  12671. * @param otherVector defines the second operand
  12672. * @returns the current updated Vector3
  12673. */
  12674. subtractInPlace(otherVector: Vector3): Vector3;
  12675. /**
  12676. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  12677. * @param otherVector defines the second operand
  12678. * @returns the resulting Vector3
  12679. */
  12680. subtract(otherVector: Vector3): Vector3;
  12681. /**
  12682. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  12683. * @param otherVector defines the second operand
  12684. * @param result defines the Vector3 object where to store the result
  12685. * @returns the current Vector3
  12686. */
  12687. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  12688. /**
  12689. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  12690. * @param x defines the x coordinate of the operand
  12691. * @param y defines the y coordinate of the operand
  12692. * @param z defines the z coordinate of the operand
  12693. * @returns the resulting Vector3
  12694. */
  12695. subtractFromFloats(x: number, y: number, z: number): Vector3;
  12696. /**
  12697. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  12698. * @param x defines the x coordinate of the operand
  12699. * @param y defines the y coordinate of the operand
  12700. * @param z defines the z coordinate of the operand
  12701. * @param result defines the Vector3 object where to store the result
  12702. * @returns the current Vector3
  12703. */
  12704. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  12705. /**
  12706. * Gets a new Vector3 set with the current Vector3 negated coordinates
  12707. * @returns a new Vector3
  12708. */
  12709. negate(): Vector3;
  12710. /**
  12711. * Multiplies the Vector3 coordinates by the float "scale"
  12712. * @param scale defines the multiplier factor
  12713. * @returns the current updated Vector3
  12714. */
  12715. scaleInPlace(scale: number): Vector3;
  12716. /**
  12717. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  12718. * @param scale defines the multiplier factor
  12719. * @returns a new Vector3
  12720. */
  12721. scale(scale: number): Vector3;
  12722. /**
  12723. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  12724. * @param scale defines the multiplier factor
  12725. * @param result defines the Vector3 object where to store the result
  12726. * @returns the current Vector3
  12727. */
  12728. scaleToRef(scale: number, result: Vector3): Vector3;
  12729. /**
  12730. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  12731. * @param scale defines the scale factor
  12732. * @param result defines the Vector3 object where to store the result
  12733. * @returns the unmodified current Vector3
  12734. */
  12735. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  12736. /**
  12737. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  12738. * @param otherVector defines the second operand
  12739. * @returns true if both vectors are equals
  12740. */
  12741. equals(otherVector: Vector3): boolean;
  12742. /**
  12743. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  12744. * @param otherVector defines the second operand
  12745. * @param epsilon defines the minimal distance to define values as equals
  12746. * @returns true if both vectors are distant less than epsilon
  12747. */
  12748. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  12749. /**
  12750. * Returns true if the current Vector3 coordinates equals the given floats
  12751. * @param x defines the x coordinate of the operand
  12752. * @param y defines the y coordinate of the operand
  12753. * @param z defines the z coordinate of the operand
  12754. * @returns true if both vectors are equals
  12755. */
  12756. equalsToFloats(x: number, y: number, z: number): boolean;
  12757. /**
  12758. * Multiplies the current Vector3 coordinates by the given ones
  12759. * @param otherVector defines the second operand
  12760. * @returns the current updated Vector3
  12761. */
  12762. multiplyInPlace(otherVector: Vector3): Vector3;
  12763. /**
  12764. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  12765. * @param otherVector defines the second operand
  12766. * @returns the new Vector3
  12767. */
  12768. multiply(otherVector: Vector3): Vector3;
  12769. /**
  12770. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  12771. * @param otherVector defines the second operand
  12772. * @param result defines the Vector3 object where to store the result
  12773. * @returns the current Vector3
  12774. */
  12775. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  12776. /**
  12777. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  12778. * @param x defines the x coordinate of the operand
  12779. * @param y defines the y coordinate of the operand
  12780. * @param z defines the z coordinate of the operand
  12781. * @returns the new Vector3
  12782. */
  12783. multiplyByFloats(x: number, y: number, z: number): Vector3;
  12784. /**
  12785. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  12786. * @param otherVector defines the second operand
  12787. * @returns the new Vector3
  12788. */
  12789. divide(otherVector: Vector3): Vector3;
  12790. /**
  12791. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  12792. * @param otherVector defines the second operand
  12793. * @param result defines the Vector3 object where to store the result
  12794. * @returns the current Vector3
  12795. */
  12796. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  12797. /**
  12798. * Divides the current Vector3 coordinates by the given ones.
  12799. * @param otherVector defines the second operand
  12800. * @returns the current updated Vector3
  12801. */
  12802. divideInPlace(otherVector: Vector3): Vector3;
  12803. /**
  12804. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  12805. * @param other defines the second operand
  12806. * @returns the current updated Vector3
  12807. */
  12808. minimizeInPlace(other: Vector3): Vector3;
  12809. /**
  12810. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  12811. * @param other defines the second operand
  12812. * @returns the current updated Vector3
  12813. */
  12814. maximizeInPlace(other: Vector3): Vector3;
  12815. /**
  12816. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  12817. */
  12818. readonly isNonUniform: boolean;
  12819. /**
  12820. * Gets the length of the Vector3
  12821. * @returns the length of the Vecto3
  12822. */
  12823. length(): number;
  12824. /**
  12825. * Gets the squared length of the Vector3
  12826. * @returns squared length of the Vector3
  12827. */
  12828. lengthSquared(): number;
  12829. /**
  12830. * Normalize the current Vector3.
  12831. * Please note that this is an in place operation.
  12832. * @returns the current updated Vector3
  12833. */
  12834. normalize(): Vector3;
  12835. /**
  12836. * Normalize the current Vector3 to a new vector
  12837. * @returns the new Vector3
  12838. */
  12839. normalizeToNew(): Vector3;
  12840. /**
  12841. * Normalize the current Vector3 to the reference
  12842. * @param reference define the Vector3 to update
  12843. * @returns the updated Vector3
  12844. */
  12845. normalizeToRef(reference: Vector3): Vector3;
  12846. /**
  12847. * Creates a new Vector3 copied from the current Vector3
  12848. * @returns the new Vector3
  12849. */
  12850. clone(): Vector3;
  12851. /**
  12852. * Copies the given vector coordinates to the current Vector3 ones
  12853. * @param source defines the source Vector3
  12854. * @returns the current updated Vector3
  12855. */
  12856. copyFrom(source: Vector3): Vector3;
  12857. /**
  12858. * Copies the given floats to the current Vector3 coordinates
  12859. * @param x defines the x coordinate of the operand
  12860. * @param y defines the y coordinate of the operand
  12861. * @param z defines the z coordinate of the operand
  12862. * @returns the current updated Vector3
  12863. */
  12864. copyFromFloats(x: number, y: number, z: number): Vector3;
  12865. /**
  12866. * Copies the given floats to the current Vector3 coordinates
  12867. * @param x defines the x coordinate of the operand
  12868. * @param y defines the y coordinate of the operand
  12869. * @param z defines the z coordinate of the operand
  12870. * @returns the current updated Vector3
  12871. */
  12872. set(x: number, y: number, z: number): Vector3;
  12873. /**
  12874. * Get the clip factor between two vectors
  12875. * @param vector0 defines the first operand
  12876. * @param vector1 defines the second operand
  12877. * @param axis defines the axis to use
  12878. * @param size defines the size along the axis
  12879. * @returns the clip factor
  12880. */
  12881. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  12882. /**
  12883. * Get angle between two vectors
  12884. * @param vector0 angle between vector0 and vector1
  12885. * @param vector1 angle between vector0 and vector1
  12886. * @param normal direction of the normal
  12887. * @return the angle between vector0 and vector1
  12888. */
  12889. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  12890. /**
  12891. * Returns a new Vector3 set from the index "offset" of the given array
  12892. * @param array defines the source array
  12893. * @param offset defines the offset in the source array
  12894. * @returns the new Vector3
  12895. */
  12896. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  12897. /**
  12898. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  12899. * This function is deprecated. Use FromArray instead
  12900. * @param array defines the source array
  12901. * @param offset defines the offset in the source array
  12902. * @returns the new Vector3
  12903. */
  12904. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  12905. /**
  12906. * Sets the given vector "result" with the element values from the index "offset" of the given array
  12907. * @param array defines the source array
  12908. * @param offset defines the offset in the source array
  12909. * @param result defines the Vector3 where to store the result
  12910. */
  12911. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  12912. /**
  12913. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  12914. * This function is deprecated. Use FromArrayToRef instead.
  12915. * @param array defines the source array
  12916. * @param offset defines the offset in the source array
  12917. * @param result defines the Vector3 where to store the result
  12918. */
  12919. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  12920. /**
  12921. * Sets the given vector "result" with the given floats.
  12922. * @param x defines the x coordinate of the source
  12923. * @param y defines the y coordinate of the source
  12924. * @param z defines the z coordinate of the source
  12925. * @param result defines the Vector3 where to store the result
  12926. */
  12927. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  12928. /**
  12929. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  12930. * @returns a new empty Vector3
  12931. */
  12932. static Zero(): Vector3;
  12933. /**
  12934. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  12935. * @returns a new unit Vector3
  12936. */
  12937. static One(): Vector3;
  12938. /**
  12939. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  12940. * @returns a new up Vector3
  12941. */
  12942. static Up(): Vector3;
  12943. /**
  12944. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  12945. * @returns a new forward Vector3
  12946. */
  12947. static Forward(): Vector3;
  12948. /**
  12949. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  12950. * @returns a new right Vector3
  12951. */
  12952. static Right(): Vector3;
  12953. /**
  12954. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  12955. * @returns a new left Vector3
  12956. */
  12957. static Left(): Vector3;
  12958. /**
  12959. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  12960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  12961. * @param vector defines the Vector3 to transform
  12962. * @param transformation defines the transformation matrix
  12963. * @returns the transformed Vector3
  12964. */
  12965. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  12966. /**
  12967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  12968. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  12969. * @param vector defines the Vector3 to transform
  12970. * @param transformation defines the transformation matrix
  12971. * @param result defines the Vector3 where to store the result
  12972. */
  12973. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  12974. /**
  12975. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  12976. * This method computes tranformed coordinates only, not transformed direction vectors
  12977. * @param x define the x coordinate of the source vector
  12978. * @param y define the y coordinate of the source vector
  12979. * @param z define the z coordinate of the source vector
  12980. * @param transformation defines the transformation matrix
  12981. * @param result defines the Vector3 where to store the result
  12982. */
  12983. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  12984. /**
  12985. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  12986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  12987. * @param vector defines the Vector3 to transform
  12988. * @param transformation defines the transformation matrix
  12989. * @returns the new Vector3
  12990. */
  12991. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  12992. /**
  12993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  12994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  12995. * @param vector defines the Vector3 to transform
  12996. * @param transformation defines the transformation matrix
  12997. * @param result defines the Vector3 where to store the result
  12998. */
  12999. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13000. /**
  13001. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13002. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13003. * @param x define the x coordinate of the source vector
  13004. * @param y define the y coordinate of the source vector
  13005. * @param z define the z coordinate of the source vector
  13006. * @param transformation defines the transformation matrix
  13007. * @param result defines the Vector3 where to store the result
  13008. */
  13009. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13010. /**
  13011. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13012. * @param value1 defines the first control point
  13013. * @param value2 defines the second control point
  13014. * @param value3 defines the third control point
  13015. * @param value4 defines the fourth control point
  13016. * @param amount defines the amount on the spline to use
  13017. * @returns the new Vector3
  13018. */
  13019. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13020. /**
  13021. * 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"
  13022. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13023. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13024. * @param value defines the current value
  13025. * @param min defines the lower range value
  13026. * @param max defines the upper range value
  13027. * @returns the new Vector3
  13028. */
  13029. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13030. /**
  13031. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13032. * @param value1 defines the first control point
  13033. * @param tangent1 defines the first tangent vector
  13034. * @param value2 defines the second control point
  13035. * @param tangent2 defines the second tangent vector
  13036. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13037. * @returns the new Vector3
  13038. */
  13039. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13040. /**
  13041. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13042. * @param start defines the start value
  13043. * @param end defines the end value
  13044. * @param amount max defines amount between both (between 0 and 1)
  13045. * @returns the new Vector3
  13046. */
  13047. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13048. /**
  13049. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13050. * @param start defines the start value
  13051. * @param end defines the end value
  13052. * @param amount max defines amount between both (between 0 and 1)
  13053. * @param result defines the Vector3 where to store the result
  13054. */
  13055. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13056. /**
  13057. * Returns the dot product (float) between the vectors "left" and "right"
  13058. * @param left defines the left operand
  13059. * @param right defines the right operand
  13060. * @returns the dot product
  13061. */
  13062. static Dot(left: Vector3, right: Vector3): number;
  13063. /**
  13064. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13065. * The cross product is then orthogonal to both "left" and "right"
  13066. * @param left defines the left operand
  13067. * @param right defines the right operand
  13068. * @returns the cross product
  13069. */
  13070. static Cross(left: Vector3, right: Vector3): Vector3;
  13071. /**
  13072. * Sets the given vector "result" with the cross product of "left" and "right"
  13073. * The cross product is then orthogonal to both "left" and "right"
  13074. * @param left defines the left operand
  13075. * @param right defines the right operand
  13076. * @param result defines the Vector3 where to store the result
  13077. */
  13078. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13079. /**
  13080. * Returns a new Vector3 as the normalization of the given vector
  13081. * @param vector defines the Vector3 to normalize
  13082. * @returns the new Vector3
  13083. */
  13084. static Normalize(vector: Vector3): Vector3;
  13085. /**
  13086. * Sets the given vector "result" with the normalization of the given first vector
  13087. * @param vector defines the Vector3 to normalize
  13088. * @param result defines the Vector3 where to store the result
  13089. */
  13090. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13091. private static _viewportMatrixCache;
  13092. /**
  13093. * Project a Vector3 onto screen space
  13094. * @param vector defines the Vector3 to project
  13095. * @param world defines the world matrix to use
  13096. * @param transform defines the transform (view x projection) matrix to use
  13097. * @param viewport defines the screen viewport to use
  13098. * @returns the new Vector3
  13099. */
  13100. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13101. /**
  13102. * Unproject from screen space to object space
  13103. * @param source defines the screen space Vector3 to use
  13104. * @param viewportWidth defines the current width of the viewport
  13105. * @param viewportHeight defines the current height of the viewport
  13106. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13107. * @param transform defines the transform (view x projection) matrix to use
  13108. * @returns the new Vector3
  13109. */
  13110. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13111. /**
  13112. * Unproject from screen space to object space
  13113. * @param source defines the screen space Vector3 to use
  13114. * @param viewportWidth defines the current width of the viewport
  13115. * @param viewportHeight defines the current height of the viewport
  13116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13117. * @param view defines the view matrix to use
  13118. * @param projection defines the projection matrix to use
  13119. * @returns the new Vector3
  13120. */
  13121. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13122. /**
  13123. * Unproject from screen space to object space
  13124. * @param source defines the screen space Vector3 to use
  13125. * @param viewportWidth defines the current width of the viewport
  13126. * @param viewportHeight defines the current height of the viewport
  13127. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13128. * @param view defines the view matrix to use
  13129. * @param projection defines the projection matrix to use
  13130. * @param result defines the Vector3 where to store the result
  13131. */
  13132. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13133. /**
  13134. * Unproject from screen space to object space
  13135. * @param sourceX defines the screen space x coordinate to use
  13136. * @param sourceY defines the screen space y coordinate to use
  13137. * @param sourceZ defines the screen space z coordinate to use
  13138. * @param viewportWidth defines the current width of the viewport
  13139. * @param viewportHeight defines the current height of the viewport
  13140. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13141. * @param view defines the view matrix to use
  13142. * @param projection defines the projection matrix to use
  13143. * @param result defines the Vector3 where to store the result
  13144. */
  13145. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13146. /**
  13147. * Gets the minimal coordinate values between two Vector3
  13148. * @param left defines the first operand
  13149. * @param right defines the second operand
  13150. * @returns the new Vector3
  13151. */
  13152. static Minimize(left: Vector3, right: Vector3): Vector3;
  13153. /**
  13154. * Gets the maximal coordinate values between two Vector3
  13155. * @param left defines the first operand
  13156. * @param right defines the second operand
  13157. * @returns the new Vector3
  13158. */
  13159. static Maximize(left: Vector3, right: Vector3): Vector3;
  13160. /**
  13161. * Returns the distance between the vectors "value1" and "value2"
  13162. * @param value1 defines the first operand
  13163. * @param value2 defines the second operand
  13164. * @returns the distance
  13165. */
  13166. static Distance(value1: Vector3, value2: Vector3): number;
  13167. /**
  13168. * Returns the squared distance between the vectors "value1" and "value2"
  13169. * @param value1 defines the first operand
  13170. * @param value2 defines the second operand
  13171. * @returns the squared distance
  13172. */
  13173. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13174. /**
  13175. * Returns a new Vector3 located at the center between "value1" and "value2"
  13176. * @param value1 defines the first operand
  13177. * @param value2 defines the second operand
  13178. * @returns the new Vector3
  13179. */
  13180. static Center(value1: Vector3, value2: Vector3): Vector3;
  13181. /**
  13182. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13183. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13184. * to something in order to rotate it from its local system to the given target system
  13185. * Note: axis1, axis2 and axis3 are normalized during this operation
  13186. * @param axis1 defines the first axis
  13187. * @param axis2 defines the second axis
  13188. * @param axis3 defines the third axis
  13189. * @returns a new Vector3
  13190. */
  13191. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13192. /**
  13193. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  13194. * @param axis1 defines the first axis
  13195. * @param axis2 defines the second axis
  13196. * @param axis3 defines the third axis
  13197. * @param ref defines the Vector3 where to store the result
  13198. */
  13199. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13200. }
  13201. class Vector4 {
  13202. x: number;
  13203. y: number;
  13204. z: number;
  13205. w: number;
  13206. /**
  13207. * Creates a Vector4 object from the given floats.
  13208. */
  13209. constructor(x: number, y: number, z: number, w: number);
  13210. /**
  13211. * Returns the string with the Vector4 coordinates.
  13212. */
  13213. toString(): string;
  13214. /**
  13215. * Returns the string "Vector4".
  13216. */
  13217. getClassName(): string;
  13218. /**
  13219. * Returns the Vector4 hash code.
  13220. */
  13221. getHashCode(): number;
  13222. /**
  13223. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13224. */
  13225. asArray(): number[];
  13226. /**
  13227. * Populates the given array from the given index with the Vector4 coordinates.
  13228. * Returns the Vector4.
  13229. */
  13230. toArray(array: FloatArray, index?: number): Vector4;
  13231. /**
  13232. * Adds the given vector to the current Vector4.
  13233. * Returns the updated Vector4.
  13234. */
  13235. addInPlace(otherVector: Vector4): Vector4;
  13236. /**
  13237. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  13238. */
  13239. add(otherVector: Vector4): Vector4;
  13240. /**
  13241. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  13242. * Returns the current Vector4.
  13243. */
  13244. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  13245. /**
  13246. * Subtract in place the given vector from the current Vector4.
  13247. * Returns the updated Vector4.
  13248. */
  13249. subtractInPlace(otherVector: Vector4): Vector4;
  13250. /**
  13251. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  13252. */
  13253. subtract(otherVector: Vector4): Vector4;
  13254. /**
  13255. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  13256. * Returns the current Vector4.
  13257. */
  13258. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  13259. /**
  13260. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13261. */
  13262. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13263. /**
  13264. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13265. * Returns the current Vector4.
  13266. */
  13267. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  13268. /**
  13269. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  13270. */
  13271. negate(): Vector4;
  13272. /**
  13273. * Multiplies the current Vector4 coordinates by scale (float).
  13274. * Returns the updated Vector4.
  13275. */
  13276. scaleInPlace(scale: number): Vector4;
  13277. /**
  13278. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  13279. */
  13280. scale(scale: number): Vector4;
  13281. /**
  13282. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  13283. * Returns the current Vector4.
  13284. */
  13285. scaleToRef(scale: number, result: Vector4): Vector4;
  13286. /**
  13287. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  13288. * @param scale defines the scale factor
  13289. * @param result defines the Vector4 object where to store the result
  13290. * @returns the unmodified current Vector4
  13291. */
  13292. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  13293. /**
  13294. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  13295. */
  13296. equals(otherVector: Vector4): boolean;
  13297. /**
  13298. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  13299. */
  13300. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  13301. /**
  13302. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  13303. */
  13304. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  13305. /**
  13306. * Multiplies in place the current Vector4 by the given one.
  13307. * Returns the updated Vector4.
  13308. */
  13309. multiplyInPlace(otherVector: Vector4): Vector4;
  13310. /**
  13311. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  13312. */
  13313. multiply(otherVector: Vector4): Vector4;
  13314. /**
  13315. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  13316. * Returns the current Vector4.
  13317. */
  13318. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  13319. /**
  13320. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  13321. */
  13322. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  13323. /**
  13324. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  13325. */
  13326. divide(otherVector: Vector4): Vector4;
  13327. /**
  13328. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  13329. * Returns the current Vector4.
  13330. */
  13331. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  13332. /**
  13333. * Divides the current Vector3 coordinates by the given ones.
  13334. * @returns the updated Vector3.
  13335. */
  13336. divideInPlace(otherVector: Vector4): Vector4;
  13337. /**
  13338. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  13339. * @param other defines the second operand
  13340. * @returns the current updated Vector4
  13341. */
  13342. minimizeInPlace(other: Vector4): Vector4;
  13343. /**
  13344. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  13345. * @param other defines the second operand
  13346. * @returns the current updated Vector4
  13347. */
  13348. maximizeInPlace(other: Vector4): Vector4;
  13349. /**
  13350. * Returns the Vector4 length (float).
  13351. */
  13352. length(): number;
  13353. /**
  13354. * Returns the Vector4 squared length (float).
  13355. */
  13356. lengthSquared(): number;
  13357. /**
  13358. * Normalizes in place the Vector4.
  13359. * Returns the updated Vector4.
  13360. */
  13361. normalize(): Vector4;
  13362. /**
  13363. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  13364. */
  13365. toVector3(): Vector3;
  13366. /**
  13367. * Returns a new Vector4 copied from the current one.
  13368. */
  13369. clone(): Vector4;
  13370. /**
  13371. * Updates the current Vector4 with the given one coordinates.
  13372. * Returns the updated Vector4.
  13373. */
  13374. copyFrom(source: Vector4): Vector4;
  13375. /**
  13376. * Updates the current Vector4 coordinates with the given floats.
  13377. * Returns the updated Vector4.
  13378. */
  13379. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13380. /**
  13381. * Updates the current Vector4 coordinates with the given floats.
  13382. * Returns the updated Vector4.
  13383. */
  13384. set(x: number, y: number, z: number, w: number): Vector4;
  13385. /**
  13386. * Returns a new Vector4 set from the starting index of the given array.
  13387. */
  13388. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  13389. /**
  13390. * Updates the given vector "result" from the starting index of the given array.
  13391. */
  13392. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  13393. /**
  13394. * Updates the given vector "result" from the starting index of the given Float32Array.
  13395. */
  13396. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  13397. /**
  13398. * Updates the given vector "result" coordinates from the given floats.
  13399. */
  13400. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  13401. /**
  13402. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  13403. */
  13404. static Zero(): Vector4;
  13405. /**
  13406. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  13407. */
  13408. static One(): Vector4;
  13409. /**
  13410. * Returns a new normalized Vector4 from the given one.
  13411. */
  13412. static Normalize(vector: Vector4): Vector4;
  13413. /**
  13414. * Updates the given vector "result" from the normalization of the given one.
  13415. */
  13416. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  13417. static Minimize(left: Vector4, right: Vector4): Vector4;
  13418. static Maximize(left: Vector4, right: Vector4): Vector4;
  13419. /**
  13420. * Returns the distance (float) between the vectors "value1" and "value2".
  13421. */
  13422. static Distance(value1: Vector4, value2: Vector4): number;
  13423. /**
  13424. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13425. */
  13426. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  13427. /**
  13428. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  13429. */
  13430. static Center(value1: Vector4, value2: Vector4): Vector4;
  13431. /**
  13432. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  13433. * This methods computes transformed normalized direction vectors only.
  13434. */
  13435. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  13436. /**
  13437. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  13438. * This methods computes transformed normalized direction vectors only.
  13439. */
  13440. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  13441. /**
  13442. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  13443. * This methods computes transformed normalized direction vectors only.
  13444. */
  13445. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  13446. }
  13447. interface ISize {
  13448. width: number;
  13449. height: number;
  13450. }
  13451. class Size implements ISize {
  13452. width: number;
  13453. height: number;
  13454. /**
  13455. * Creates a Size object from the given width and height (floats).
  13456. */
  13457. constructor(width: number, height: number);
  13458. toString(): string;
  13459. /**
  13460. * Returns the string "Size"
  13461. */
  13462. getClassName(): string;
  13463. /**
  13464. * Returns the Size hash code.
  13465. */
  13466. getHashCode(): number;
  13467. /**
  13468. * Updates the current size from the given one.
  13469. * Returns the updated Size.
  13470. */
  13471. copyFrom(src: Size): void;
  13472. /**
  13473. * Updates in place the current Size from the given floats.
  13474. * Returns the updated Size.
  13475. */
  13476. copyFromFloats(width: number, height: number): Size;
  13477. /**
  13478. * Updates in place the current Size from the given floats.
  13479. * Returns the updated Size.
  13480. */
  13481. set(width: number, height: number): Size;
  13482. /**
  13483. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  13484. */
  13485. multiplyByFloats(w: number, h: number): Size;
  13486. /**
  13487. * Returns a new Size copied from the given one.
  13488. */
  13489. clone(): Size;
  13490. /**
  13491. * Boolean : True if the current Size and the given one width and height are strictly equal.
  13492. */
  13493. equals(other: Size): boolean;
  13494. /**
  13495. * Returns the surface of the Size : width * height (float).
  13496. */
  13497. readonly surface: number;
  13498. /**
  13499. * Returns a new Size set to (0.0, 0.0)
  13500. */
  13501. static Zero(): Size;
  13502. /**
  13503. * Returns a new Size set as the addition result of the current Size and the given one.
  13504. */
  13505. add(otherSize: Size): Size;
  13506. /**
  13507. * Returns a new Size set as the subtraction result of the given one from the current Size.
  13508. */
  13509. subtract(otherSize: Size): Size;
  13510. /**
  13511. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  13512. */
  13513. static Lerp(start: Size, end: Size, amount: number): Size;
  13514. }
  13515. /**
  13516. * Class used to store quaternion data
  13517. * @see https://en.wikipedia.org/wiki/Quaternion
  13518. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  13519. */
  13520. class Quaternion {
  13521. /** defines the first component (0 by default) */
  13522. x: number;
  13523. /** defines the second component (0 by default) */
  13524. y: number;
  13525. /** defines the third component (0 by default) */
  13526. z: number;
  13527. /** defines the fourth component (1.0 by default) */
  13528. w: number;
  13529. /**
  13530. * Creates a new Quaternion from the given floats
  13531. * @param x defines the first component (0 by default)
  13532. * @param y defines the second component (0 by default)
  13533. * @param z defines the third component (0 by default)
  13534. * @param w defines the fourth component (1.0 by default)
  13535. */
  13536. constructor(
  13537. /** defines the first component (0 by default) */
  13538. x?: number,
  13539. /** defines the second component (0 by default) */
  13540. y?: number,
  13541. /** defines the third component (0 by default) */
  13542. z?: number,
  13543. /** defines the fourth component (1.0 by default) */
  13544. w?: number);
  13545. /**
  13546. * Gets a string representation for the current quaternion
  13547. * @returns a string with the Quaternion coordinates
  13548. */
  13549. toString(): string;
  13550. /**
  13551. * Gets the class name of the quaternion
  13552. * @returns the string "Quaternion"
  13553. */
  13554. getClassName(): string;
  13555. /**
  13556. * Gets a hash code for this quaternion
  13557. * @returns the quaternion hash code
  13558. */
  13559. getHashCode(): number;
  13560. /**
  13561. * Copy the quaternion to an array
  13562. * @returns a new array populated with 4 elements from the quaternion coordinates
  13563. */
  13564. asArray(): number[];
  13565. /**
  13566. * Check if two quaternions are equals
  13567. * @param otherQuaternion defines the second operand
  13568. * @return true if the current quaternion and the given one coordinates are strictly equals
  13569. */
  13570. equals(otherQuaternion: Quaternion): boolean;
  13571. /**
  13572. * Clone the current quaternion
  13573. * @returns a new quaternion copied from the current one
  13574. */
  13575. clone(): Quaternion;
  13576. /**
  13577. * Copy a quaternion to the current one
  13578. * @param other defines the other quaternion
  13579. * @returns the updated current quaternion
  13580. */
  13581. copyFrom(other: Quaternion): Quaternion;
  13582. /**
  13583. * Updates the current quaternion with the given float coordinates
  13584. * @param x defines the x coordinate
  13585. * @param y defines the y coordinate
  13586. * @param z defines the z coordinate
  13587. * @param w defines the w coordinate
  13588. * @returns the updated current quaternion
  13589. */
  13590. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  13591. /**
  13592. * Updates the current quaternion from the given float coordinates
  13593. * @param x defines the x coordinate
  13594. * @param y defines the y coordinate
  13595. * @param z defines the z coordinate
  13596. * @param w defines the w coordinate
  13597. * @returns the updated current quaternion
  13598. */
  13599. set(x: number, y: number, z: number, w: number): Quaternion;
  13600. /**
  13601. * Adds two quaternions
  13602. * @param other defines the second operand
  13603. * @returns a new quaternion as the addition result of the given one and the current quaternion
  13604. */
  13605. add(other: Quaternion): Quaternion;
  13606. /**
  13607. * Add a quaternion to the current one
  13608. * @param other defines the quaternion to add
  13609. * @returns the current quaternion
  13610. */
  13611. addInPlace(other: Quaternion): Quaternion;
  13612. /**
  13613. * Subtract two quaternions
  13614. * @param other defines the second operand
  13615. * @returns a new quaternion as the subtraction result of the given one from the current one
  13616. */
  13617. subtract(other: Quaternion): Quaternion;
  13618. /**
  13619. * Multiplies the current quaternion by a scale factor
  13620. * @param value defines the scale factor
  13621. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  13622. */
  13623. scale(value: number): Quaternion;
  13624. /**
  13625. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  13626. * @param scale defines the scale factor
  13627. * @param result defines the Quaternion object where to store the result
  13628. * @returns the unmodified current quaternion
  13629. */
  13630. scaleToRef(scale: number, result: Quaternion): Quaternion;
  13631. /**
  13632. * Multiplies in place the current quaternion by a scale factor
  13633. * @param value defines the scale factor
  13634. * @returns the current modified quaternion
  13635. */
  13636. scaleInPlace(value: number): Quaternion;
  13637. /**
  13638. * Scale the current quaternion values by a factor and add the result to a given quaternion
  13639. * @param scale defines the scale factor
  13640. * @param result defines the Quaternion object where to store the result
  13641. * @returns the unmodified current quaternion
  13642. */
  13643. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  13644. /**
  13645. * Multiplies two quaternions
  13646. * @param q1 defines the second operand
  13647. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  13648. */
  13649. multiply(q1: Quaternion): Quaternion;
  13650. /**
  13651. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  13652. * @param q1 defines the second operand
  13653. * @param result defines the target quaternion
  13654. * @returns the current quaternion
  13655. */
  13656. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  13657. /**
  13658. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  13659. * @param q1 defines the second operand
  13660. * @returns the currentupdated quaternion
  13661. */
  13662. multiplyInPlace(q1: Quaternion): Quaternion;
  13663. /**
  13664. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  13665. * @param ref defines the target quaternion
  13666. * @returns the current quaternion
  13667. */
  13668. conjugateToRef(ref: Quaternion): Quaternion;
  13669. /**
  13670. * Conjugates in place (1-q) the current quaternion
  13671. * @returns the current updated quaternion
  13672. */
  13673. conjugateInPlace(): Quaternion;
  13674. /**
  13675. * Conjugates in place (1-q) the current quaternion
  13676. * @returns a new quaternion
  13677. */
  13678. conjugate(): Quaternion;
  13679. /**
  13680. * Gets length of current quaternion
  13681. * @returns the quaternion length (float)
  13682. */
  13683. length(): number;
  13684. /**
  13685. * Normalize in place the current quaternion
  13686. * @returns the current updated quaternion
  13687. */
  13688. normalize(): Quaternion;
  13689. /**
  13690. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  13691. * @param order is a reserved parameter and is ignore for now
  13692. * @returns a new Vector3 containing the Euler angles
  13693. */
  13694. toEulerAngles(order?: string): Vector3;
  13695. /**
  13696. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  13697. * @param result defines the vector which will be filled with the Euler angles
  13698. * @param order is a reserved parameter and is ignore for now
  13699. * @returns the current unchanged quaternion
  13700. */
  13701. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  13702. /**
  13703. * Updates the given rotation matrix with the current quaternion values
  13704. * @param result defines the target matrix
  13705. * @returns the current unchanged quaternion
  13706. */
  13707. toRotationMatrix(result: Matrix): Quaternion;
  13708. /**
  13709. * Updates the current quaternion from the given rotation matrix values
  13710. * @param matrix defines the source matrix
  13711. * @returns the current updated quaternion
  13712. */
  13713. fromRotationMatrix(matrix: Matrix): Quaternion;
  13714. /**
  13715. * Creates a new quaternion from a rotation matrix
  13716. * @param matrix defines the source matrix
  13717. * @returns a new quaternion created from the given rotation matrix values
  13718. */
  13719. static FromRotationMatrix(matrix: Matrix): Quaternion;
  13720. /**
  13721. * Updates the given quaternion with the given rotation matrix values
  13722. * @param matrix defines the source matrix
  13723. * @param result defines the target quaternion
  13724. */
  13725. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  13726. /**
  13727. * Creates an empty quaternion
  13728. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  13729. */
  13730. static Zero(): Quaternion;
  13731. /**
  13732. * Inverse a given quaternion
  13733. * @param q defines the source quaternion
  13734. * @returns a new quaternion as the inverted current quaternion
  13735. */
  13736. static Inverse(q: Quaternion): Quaternion;
  13737. /**
  13738. * Creates an identity quaternion
  13739. * @returns the identity quaternion
  13740. */
  13741. static Identity(): Quaternion;
  13742. /**
  13743. * Gets a boolean indicating if the given quaternion is identity
  13744. * @param quaternion defines the quaternion to check
  13745. * @returns true if the quaternion is identity
  13746. */
  13747. static IsIdentity(quaternion: Quaternion): boolean;
  13748. /**
  13749. * Creates a quaternion from a rotation around an axis
  13750. * @param axis defines the axis to use
  13751. * @param angle defines the angle to use
  13752. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  13753. */
  13754. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  13755. /**
  13756. * Creates a rotation around an axis and stores it into the given quaternion
  13757. * @param axis defines the axis to use
  13758. * @param angle defines the angle to use
  13759. * @param result defines the target quaternion
  13760. * @returns the target quaternion
  13761. */
  13762. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  13763. /**
  13764. * Creates a new quaternion from data stored into an array
  13765. * @param array defines the data source
  13766. * @param offset defines the offset in the source array where the data starts
  13767. * @returns a new quaternion
  13768. */
  13769. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  13770. /**
  13771. * Creates a new quaternion from the given Euler float angles (y, x, z)
  13772. * @param yaw defines the rotation around Y axis
  13773. * @param pitch defines the rotation around X axis
  13774. * @param roll defines the rotation around Z axis
  13775. * @returns the new quaternion
  13776. */
  13777. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  13778. /**
  13779. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  13780. * @param yaw defines the rotation around Y axis
  13781. * @param pitch defines the rotation around X axis
  13782. * @param roll defines the rotation around Z axis
  13783. * @param result defines the target quaternion
  13784. */
  13785. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  13786. /**
  13787. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  13788. * @param alpha defines the rotation around first axis
  13789. * @param beta defines the rotation around second axis
  13790. * @param gamma defines the rotation around third axis
  13791. * @returns the new quaternion
  13792. */
  13793. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  13794. /**
  13795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  13796. * @param alpha defines the rotation around first axis
  13797. * @param beta defines the rotation around second axis
  13798. * @param gamma defines the rotation around third axis
  13799. * @param result defines the target quaternion
  13800. */
  13801. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  13802. /**
  13803. * 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)
  13804. * @param axis1 defines the first axis
  13805. * @param axis2 defines the second axis
  13806. * @param axis3 defines the third axis
  13807. * @returns the new quaternion
  13808. */
  13809. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  13810. /**
  13811. * 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
  13812. * @param axis1 defines the first axis
  13813. * @param axis2 defines the second axis
  13814. * @param axis3 defines the third axis
  13815. * @param ref defines the target quaternion
  13816. */
  13817. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  13818. /**
  13819. * Interpolates between two quaternions
  13820. * @param left defines first quaternion
  13821. * @param right defines second quaternion
  13822. * @param amount defines the gradient to use
  13823. * @returns the new interpolated quaternion
  13824. */
  13825. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  13826. /**
  13827. * Interpolates between two quaternions and stores it into a target quaternion
  13828. * @param left defines first quaternion
  13829. * @param right defines second quaternion
  13830. * @param amount defines the gradient to use
  13831. * @param result defines the target quaternion
  13832. */
  13833. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  13834. /**
  13835. * Interpolate between two quaternions using Hermite interpolation
  13836. * @param value1 defines first quaternion
  13837. * @param tangent1 defines the incoming tangent
  13838. * @param value2 defines second quaternion
  13839. * @param tangent2 defines the outgoing tangent
  13840. * @param amount defines the target quaternion
  13841. * @returns the new interpolated quaternion
  13842. */
  13843. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  13844. }
  13845. /**
  13846. * Class used to store matrix data (4x4)
  13847. */
  13848. class Matrix {
  13849. private static _tempQuaternion;
  13850. private static _xAxis;
  13851. private static _yAxis;
  13852. private static _zAxis;
  13853. private static _updateFlagSeed;
  13854. private static _identityReadOnly;
  13855. private _isIdentity;
  13856. private _isIdentityDirty;
  13857. /**
  13858. * Gets the update flag of the matrix which is an unique number for the matrix.
  13859. * It will be incremented every time the matrix data change.
  13860. * You can use it to speed the comparison between two versions of the same matrix.
  13861. */
  13862. updateFlag: number;
  13863. /**
  13864. * Gets or sets the internal data of the matrix
  13865. */
  13866. m: Float32Array;
  13867. /** @hidden */
  13868. /**
  13869. * Creates an empty matrix (filled with zeros)
  13870. */
  13871. constructor();
  13872. /**
  13873. * Check if the current matrix is indentity
  13874. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  13875. * @returns true is the matrix is the identity matrix
  13876. */
  13877. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  13878. /**
  13879. * Gets the determinant of the matrix
  13880. * @returns the matrix determinant
  13881. */
  13882. determinant(): number;
  13883. /**
  13884. * Returns the matrix as a Float32Array
  13885. * @returns the matrix underlying array
  13886. */
  13887. toArray(): Float32Array;
  13888. /**
  13889. * Returns the matrix as a Float32Array
  13890. * @returns the matrix underlying array.
  13891. */
  13892. asArray(): Float32Array;
  13893. /**
  13894. * Inverts the current matrix in place
  13895. * @returns the current inverted matrix
  13896. */
  13897. invert(): Matrix;
  13898. /**
  13899. * Sets all the matrix elements to zero
  13900. * @returns the current matrix
  13901. */
  13902. reset(): Matrix;
  13903. /**
  13904. * Adds the current matrix with a second one
  13905. * @param other defines the matrix to add
  13906. * @returns a new matrix as the addition of the current matrix and the given one
  13907. */
  13908. add(other: Matrix): Matrix;
  13909. /**
  13910. * Sets the given matrix "result" to the addition of the current matrix and the given one
  13911. * @param other defines the matrix to add
  13912. * @param result defines the target matrix
  13913. * @returns the current matrix
  13914. */
  13915. addToRef(other: Matrix, result: Matrix): Matrix;
  13916. /**
  13917. * Adds in place the given matrix to the current matrix
  13918. * @param other defines the second operand
  13919. * @returns the current updated matrix
  13920. */
  13921. addToSelf(other: Matrix): Matrix;
  13922. /**
  13923. * Sets the given matrix to the current inverted Matrix
  13924. * @param other defines the target matrix
  13925. * @returns the unmodified current matrix
  13926. */
  13927. invertToRef(other: Matrix): Matrix;
  13928. /**
  13929. * Inserts the translation vector (using 3 floats) in the current matrix
  13930. * @param x defines the 1st component of the translation
  13931. * @param y defines the 2nd component of the translation
  13932. * @param z defines the 3rd component of the translation
  13933. * @returns the current updated matrix
  13934. */
  13935. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  13936. /**
  13937. * Inserts the translation vector in the current matrix
  13938. * @param vector3 defines the translation to insert
  13939. * @returns the current updated matrix
  13940. */
  13941. setTranslation(vector3: Vector3): Matrix;
  13942. /**
  13943. * Gets the translation value of the current matrix
  13944. * @returns a new Vector3 as the extracted translation from the matrix
  13945. */
  13946. getTranslation(): Vector3;
  13947. /**
  13948. * Fill a Vector3 with the extracted translation from the matrix
  13949. * @param result defines the Vector3 where to store the translation
  13950. * @returns the current matrix
  13951. */
  13952. getTranslationToRef(result: Vector3): Matrix;
  13953. /**
  13954. * Remove rotation and scaling part from the matrix
  13955. * @returns the updated matrix
  13956. */
  13957. removeRotationAndScaling(): Matrix;
  13958. /**
  13959. * Multiply two matrices
  13960. * @param other defines the second operand
  13961. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  13962. */
  13963. multiply(other: Matrix): Matrix;
  13964. /**
  13965. * Copy the current matrix from the given one
  13966. * @param other defines the source matrix
  13967. * @returns the current updated matrix
  13968. */
  13969. copyFrom(other: Matrix): Matrix;
  13970. /**
  13971. * Populates the given array from the starting index with the current matrix values
  13972. * @param array defines the target array
  13973. * @param offset defines the offset in the target array where to start storing values
  13974. * @returns the current matrix
  13975. */
  13976. copyToArray(array: Float32Array, offset?: number): Matrix;
  13977. /**
  13978. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  13979. * @param other defines the second operand
  13980. * @param result defines the matrix where to store the multiplication
  13981. * @returns the current matrix
  13982. */
  13983. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  13984. /**
  13985. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  13986. * @param other defines the second operand
  13987. * @param result defines the array where to store the multiplication
  13988. * @param offset defines the offset in the target array where to start storing values
  13989. * @returns the current matrix
  13990. */
  13991. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  13992. /**
  13993. * Check equality between this matrix and a second one
  13994. * @param value defines the second matrix to compare
  13995. * @returns true is the current matrix and the given one values are strictly equal
  13996. */
  13997. equals(value: Matrix): boolean;
  13998. /**
  13999. * Clone the current matrix
  14000. * @returns a new matrix from the current matrix
  14001. */
  14002. clone(): Matrix;
  14003. /**
  14004. * Returns the name of the current matrix class
  14005. * @returns the string "Matrix"
  14006. */
  14007. getClassName(): string;
  14008. /**
  14009. * Gets the hash code of the current matrix
  14010. * @returns the hash code
  14011. */
  14012. getHashCode(): number;
  14013. /**
  14014. * Decomposes the current Matrix into a translation, rotation and scaling components
  14015. * @param scale defines the scale vector3 given as a reference to update
  14016. * @param rotation defines the rotation quaternion given as a reference to update
  14017. * @param translation defines the translation vector3 given as a reference to update
  14018. * @returns true if operation was successful
  14019. */
  14020. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14021. /**
  14022. * Gets specific row of the matrix
  14023. * @param index defines the number of the row to get
  14024. * @returns the index-th row of the current matrix as a new Vector4
  14025. */
  14026. getRow(index: number): Nullable<Vector4>;
  14027. /**
  14028. * Sets the index-th row of the current matrix to the vector4 values
  14029. * @param index defines the number of the row to set
  14030. * @param row defines the target vector4
  14031. * @returns the updated current matrix
  14032. */
  14033. setRow(index: number, row: Vector4): Matrix;
  14034. /**
  14035. * Compute the transpose of the matrix
  14036. * @returns the new transposed matrix
  14037. */
  14038. transpose(): Matrix;
  14039. /**
  14040. * Compute the transpose of the matrix and store it in a given matrix
  14041. * @param result defines the target matrix
  14042. * @returns the current matrix
  14043. */
  14044. transposeToRef(result: Matrix): Matrix;
  14045. /**
  14046. * Sets the index-th row of the current matrix with the given 4 x float values
  14047. * @param index defines the row index
  14048. * @param x defines the x component to set
  14049. * @param y defines the y component to set
  14050. * @param z defines the z component to set
  14051. * @param w defines the w component to set
  14052. * @returns the updated current matrix
  14053. */
  14054. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14055. /**
  14056. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14057. * @param scale defines the scale factor
  14058. * @returns a new matrix
  14059. */
  14060. scale(scale: number): Matrix;
  14061. /**
  14062. * Scale the current matrix values by a factor to a given result matrix
  14063. * @param scale defines the scale factor
  14064. * @param result defines the matrix to store the result
  14065. * @returns the current matrix
  14066. */
  14067. scaleToRef(scale: number, result: Matrix): Matrix;
  14068. /**
  14069. * Scale the current matrix values by a factor and add the result to a given matrix
  14070. * @param scale defines the scale factor
  14071. * @param result defines the Matrix to store the result
  14072. * @returns the current matrix
  14073. */
  14074. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14075. /**
  14076. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14077. * @param ref matrix to store the result
  14078. */
  14079. toNormalMatrix(ref: Matrix): void;
  14080. /**
  14081. * Gets only rotation part of the current matrix
  14082. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14083. */
  14084. getRotationMatrix(): Matrix;
  14085. /**
  14086. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14087. * @param result defines the target matrix to store data to
  14088. * @returns the current matrix
  14089. */
  14090. getRotationMatrixToRef(result: Matrix): Matrix;
  14091. /**
  14092. * Creates a matrix from an array
  14093. * @param array defines the source array
  14094. * @param offset defines an offset in the source array
  14095. * @returns a new Matrix set from the starting index of the given array
  14096. */
  14097. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14098. /**
  14099. * Copy the content of an array into a given matrix
  14100. * @param array defines the source array
  14101. * @param offset defines an offset in the source array
  14102. * @param result defines the target matrix
  14103. */
  14104. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14105. /**
  14106. * Stores an array into a matrix after having multiplied each component by a given factor
  14107. * @param array defines the source array
  14108. * @param offset defines the offset in the source array
  14109. * @param scale defines the scaling factor
  14110. * @param result defines the target matrix
  14111. */
  14112. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14113. /**
  14114. * Stores a list of values (16) inside a given matrix
  14115. * @param initialM11 defines 1st value of 1st row
  14116. * @param initialM12 defines 2nd value of 1st row
  14117. * @param initialM13 defines 3rd value of 1st row
  14118. * @param initialM14 defines 4th value of 1st row
  14119. * @param initialM21 defines 1st value of 2nd row
  14120. * @param initialM22 defines 2nd value of 2nd row
  14121. * @param initialM23 defines 3rd value of 2nd row
  14122. * @param initialM24 defines 4th value of 2nd row
  14123. * @param initialM31 defines 1st value of 3rd row
  14124. * @param initialM32 defines 2nd value of 3rd row
  14125. * @param initialM33 defines 3rd value of 3rd row
  14126. * @param initialM34 defines 4th value of 3rd row
  14127. * @param initialM41 defines 1st value of 4th row
  14128. * @param initialM42 defines 2nd value of 4th row
  14129. * @param initialM43 defines 3rd value of 4th row
  14130. * @param initialM44 defines 4th value of 4th row
  14131. * @param result defines the target matrix
  14132. */
  14133. 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;
  14134. /**
  14135. * Gets an identity matrix that must not be updated
  14136. */
  14137. static readonly IdentityReadOnly: Matrix;
  14138. /**
  14139. * Creates new matrix from a list of values (16)
  14140. * @param initialM11 defines 1st value of 1st row
  14141. * @param initialM12 defines 2nd value of 1st row
  14142. * @param initialM13 defines 3rd value of 1st row
  14143. * @param initialM14 defines 4th value of 1st row
  14144. * @param initialM21 defines 1st value of 2nd row
  14145. * @param initialM22 defines 2nd value of 2nd row
  14146. * @param initialM23 defines 3rd value of 2nd row
  14147. * @param initialM24 defines 4th value of 2nd row
  14148. * @param initialM31 defines 1st value of 3rd row
  14149. * @param initialM32 defines 2nd value of 3rd row
  14150. * @param initialM33 defines 3rd value of 3rd row
  14151. * @param initialM34 defines 4th value of 3rd row
  14152. * @param initialM41 defines 1st value of 4th row
  14153. * @param initialM42 defines 2nd value of 4th row
  14154. * @param initialM43 defines 3rd value of 4th row
  14155. * @param initialM44 defines 4th value of 4th row
  14156. * @returns the new matrix
  14157. */
  14158. 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;
  14159. /**
  14160. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14161. * @param scale defines the scale vector3
  14162. * @param rotation defines the rotation quaternion
  14163. * @param translation defines the translation vector3
  14164. * @returns a new matrix
  14165. */
  14166. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14167. /**
  14168. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14169. * @param scale defines the scale vector3
  14170. * @param rotation defines the rotation quaternion
  14171. * @param translation defines the translation vector3
  14172. * @param result defines the target matrix
  14173. */
  14174. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14175. /**
  14176. * Creates a new identity matrix
  14177. * @returns a new identity matrix
  14178. */
  14179. static Identity(): Matrix;
  14180. /**
  14181. * Creates a new identity matrix and stores the result in a given matrix
  14182. * @param result defines the target matrix
  14183. */
  14184. static IdentityToRef(result: Matrix): void;
  14185. /**
  14186. * Creates a new zero matrix
  14187. * @returns a new zero matrix
  14188. */
  14189. static Zero(): Matrix;
  14190. /**
  14191. * Creates a new rotation matrix for "angle" radians around the X axis
  14192. * @param angle defines the angle (in radians) to use
  14193. * @return the new matrix
  14194. */
  14195. static RotationX(angle: number): Matrix;
  14196. /**
  14197. * Creates a new matrix as the invert of a given matrix
  14198. * @param source defines the source matrix
  14199. * @returns the new matrix
  14200. */
  14201. static Invert(source: Matrix): Matrix;
  14202. /**
  14203. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  14204. * @param angle defines the angle (in radians) to use
  14205. * @param result defines the target matrix
  14206. */
  14207. static RotationXToRef(angle: number, result: Matrix): void;
  14208. /**
  14209. * Creates a new rotation matrix for "angle" radians around the Y axis
  14210. * @param angle defines the angle (in radians) to use
  14211. * @return the new matrix
  14212. */
  14213. static RotationY(angle: number): Matrix;
  14214. /**
  14215. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  14216. * @param angle defines the angle (in radians) to use
  14217. * @param result defines the target matrix
  14218. */
  14219. static RotationYToRef(angle: number, result: Matrix): void;
  14220. /**
  14221. * Creates a new rotation matrix for "angle" radians around the Z axis
  14222. * @param angle defines the angle (in radians) to use
  14223. * @return the new matrix
  14224. */
  14225. static RotationZ(angle: number): Matrix;
  14226. /**
  14227. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  14228. * @param angle defines the angle (in radians) to use
  14229. * @param result defines the target matrix
  14230. */
  14231. static RotationZToRef(angle: number, result: Matrix): void;
  14232. /**
  14233. * Creates a new rotation matrix for "angle" radians around the given axis
  14234. * @param axis defines the axis to use
  14235. * @param angle defines the angle (in radians) to use
  14236. * @return the new matrix
  14237. */
  14238. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14239. /**
  14240. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  14241. * @param axis defines the axis to use
  14242. * @param angle defines the angle (in radians) to use
  14243. * @param result defines the target matrix
  14244. */
  14245. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14246. /**
  14247. * Creates a rotation matrix
  14248. * @param yaw defines the yaw angle in radians (Y axis)
  14249. * @param pitch defines the pitch angle in radians (X axis)
  14250. * @param roll defines the roll angle in radians (X axis)
  14251. * @returns the new rotation matrix
  14252. */
  14253. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14254. /**
  14255. * Creates a rotation matrix and stores it in a given matrix
  14256. * @param yaw defines the yaw angle in radians (Y axis)
  14257. * @param pitch defines the pitch angle in radians (X axis)
  14258. * @param roll defines the roll angle in radians (X axis)
  14259. * @param result defines the target matrix
  14260. */
  14261. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14262. /**
  14263. * Creates a scaling matrix
  14264. * @param x defines the scale factor on X axis
  14265. * @param y defines the scale factor on Y axis
  14266. * @param z defines the scale factor on Z axis
  14267. * @returns the new matrix
  14268. */
  14269. static Scaling(x: number, y: number, z: number): Matrix;
  14270. /**
  14271. * Creates a scaling matrix and stores it in a given matrix
  14272. * @param x defines the scale factor on X axis
  14273. * @param y defines the scale factor on Y axis
  14274. * @param z defines the scale factor on Z axis
  14275. * @param result defines the target matrix
  14276. */
  14277. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14278. /**
  14279. * Creates a translation matrix
  14280. * @param x defines the translation on X axis
  14281. * @param y defines the translation on Y axis
  14282. * @param z defines the translationon Z axis
  14283. * @returns the new matrix
  14284. */
  14285. static Translation(x: number, y: number, z: number): Matrix;
  14286. /**
  14287. * Creates a translation matrix and stores it in a given matrix
  14288. * @param x defines the translation on X axis
  14289. * @param y defines the translation on Y axis
  14290. * @param z defines the translationon Z axis
  14291. * @param result defines the target matrix
  14292. */
  14293. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14294. /**
  14295. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14296. * @param startValue defines the start value
  14297. * @param endValue defines the end value
  14298. * @param gradient defines the gradient factor
  14299. * @returns the new matrix
  14300. */
  14301. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14302. /**
  14303. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14304. * @param startValue defines the start value
  14305. * @param endValue defines the end value
  14306. * @param gradient defines the gradient factor
  14307. * @param result defines the Matrix object where to store data
  14308. */
  14309. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14310. /**
  14311. * Builds a new matrix whose values are computed by:
  14312. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14313. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14314. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14315. * @param startValue defines the first matrix
  14316. * @param endValue defines the second matrix
  14317. * @param gradient defines the gradient between the two matrices
  14318. * @returns the new matrix
  14319. */
  14320. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14321. /**
  14322. * Update a matrix to values which are computed by:
  14323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14326. * @param startValue defines the first matrix
  14327. * @param endValue defines the second matrix
  14328. * @param gradient defines the gradient between the two matrices
  14329. * @param result defines the target matrix
  14330. */
  14331. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14332. /**
  14333. * 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"
  14334. * This function works in left handed mode
  14335. * @param eye defines the final position of the entity
  14336. * @param target defines where the entity should look at
  14337. * @param up defines the up vector for the entity
  14338. * @returns the new matrix
  14339. */
  14340. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14341. /**
  14342. * 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".
  14343. * This function works in left handed mode
  14344. * @param eye defines the final position of the entity
  14345. * @param target defines where the entity should look at
  14346. * @param up defines the up vector for the entity
  14347. * @param result defines the target matrix
  14348. */
  14349. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14350. /**
  14351. * 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"
  14352. * This function works in right handed mode
  14353. * @param eye defines the final position of the entity
  14354. * @param target defines where the entity should look at
  14355. * @param up defines the up vector for the entity
  14356. * @returns the new matrix
  14357. */
  14358. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14359. /**
  14360. * 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".
  14361. * This function works in right handed mode
  14362. * @param eye defines the final position of the entity
  14363. * @param target defines where the entity should look at
  14364. * @param up defines the up vector for the entity
  14365. * @param result defines the target matrix
  14366. */
  14367. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14368. /**
  14369. * Create a left-handed orthographic projection matrix
  14370. * @param width defines the viewport width
  14371. * @param height defines the viewport height
  14372. * @param znear defines the near clip plane
  14373. * @param zfar defines the far clip plane
  14374. * @returns a new matrix as a left-handed orthographic projection matrix
  14375. */
  14376. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14377. /**
  14378. * Store a left-handed orthographic projection to a given matrix
  14379. * @param width defines the viewport width
  14380. * @param height defines the viewport height
  14381. * @param znear defines the near clip plane
  14382. * @param zfar defines the far clip plane
  14383. * @param result defines the target matrix
  14384. */
  14385. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14386. /**
  14387. * Create a left-handed orthographic projection matrix
  14388. * @param left defines the viewport left coordinate
  14389. * @param right defines the viewport right coordinate
  14390. * @param bottom defines the viewport bottom coordinate
  14391. * @param top defines the viewport top coordinate
  14392. * @param znear defines the near clip plane
  14393. * @param zfar defines the far clip plane
  14394. * @returns a new matrix as a left-handed orthographic projection matrix
  14395. */
  14396. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14397. /**
  14398. * Stores a left-handed orthographic projection into a given matrix
  14399. * @param left defines the viewport left coordinate
  14400. * @param right defines the viewport right coordinate
  14401. * @param bottom defines the viewport bottom coordinate
  14402. * @param top defines the viewport top coordinate
  14403. * @param znear defines the near clip plane
  14404. * @param zfar defines the far clip plane
  14405. * @param result defines the target matrix
  14406. */
  14407. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14408. /**
  14409. * Creates a right-handed orthographic projection matrix
  14410. * @param left defines the viewport left coordinate
  14411. * @param right defines the viewport right coordinate
  14412. * @param bottom defines the viewport bottom coordinate
  14413. * @param top defines the viewport top coordinate
  14414. * @param znear defines the near clip plane
  14415. * @param zfar defines the far clip plane
  14416. * @returns a new matrix as a right-handed orthographic projection matrix
  14417. */
  14418. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14419. /**
  14420. * Stores a right-handed orthographic projection into a given matrix
  14421. * @param left defines the viewport left coordinate
  14422. * @param right defines the viewport right coordinate
  14423. * @param bottom defines the viewport bottom coordinate
  14424. * @param top defines the viewport top coordinate
  14425. * @param znear defines the near clip plane
  14426. * @param zfar defines the far clip plane
  14427. * @param result defines the target matrix
  14428. */
  14429. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14430. /**
  14431. * Creates a left-handed perspective projection matrix
  14432. * @param width defines the viewport width
  14433. * @param height defines the viewport height
  14434. * @param znear defines the near clip plane
  14435. * @param zfar defines the far clip plane
  14436. * @returns a new matrix as a left-handed perspective projection matrix
  14437. */
  14438. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14439. /**
  14440. * Creates a left-handed perspective projection matrix
  14441. * @param fov defines the horizontal field of view
  14442. * @param aspect defines the aspect ratio
  14443. * @param znear defines the near clip plane
  14444. * @param zfar defines the far clip plane
  14445. * @returns a new matrix as a left-handed perspective projection matrix
  14446. */
  14447. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14448. /**
  14449. * Stores a left-handed perspective projection into a given matrix
  14450. * @param fov defines the horizontal field of view
  14451. * @param aspect defines the aspect ratio
  14452. * @param znear defines the near clip plane
  14453. * @param zfar defines the far clip plane
  14454. * @param result defines the target matrix
  14455. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14456. */
  14457. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14458. /**
  14459. * Creates a right-handed perspective projection matrix
  14460. * @param fov defines the horizontal field of view
  14461. * @param aspect defines the aspect ratio
  14462. * @param znear defines the near clip plane
  14463. * @param zfar defines the far clip plane
  14464. * @returns a new matrix as a right-handed perspective projection matrix
  14465. */
  14466. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14467. /**
  14468. * Stores a right-handed perspective projection into a given matrix
  14469. * @param fov defines the horizontal field of view
  14470. * @param aspect defines the aspect ratio
  14471. * @param znear defines the near clip plane
  14472. * @param zfar defines the far clip plane
  14473. * @param result defines the target matrix
  14474. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14475. */
  14476. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14477. /**
  14478. * Stores a perspective projection for WebVR info a given matrix
  14479. * @param fov defines the field of view
  14480. * @param znear defines the near clip plane
  14481. * @param zfar defines the far clip plane
  14482. * @param result defines the target matrix
  14483. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  14484. */
  14485. static PerspectiveFovWebVRToRef(fov: {
  14486. upDegrees: number;
  14487. downDegrees: number;
  14488. leftDegrees: number;
  14489. rightDegrees: number;
  14490. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  14491. /**
  14492. * Computes a complete transformation matrix
  14493. * @param viewport defines the viewport to use
  14494. * @param world defines the world matrix
  14495. * @param view defines the view matrix
  14496. * @param projection defines the projection matrix
  14497. * @param zmin defines the near clip plane
  14498. * @param zmax defines the far clip plane
  14499. * @returns the transformation matrix
  14500. */
  14501. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  14502. /**
  14503. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  14504. * @param matrix defines the matrix to use
  14505. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  14506. */
  14507. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  14508. /**
  14509. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  14510. * @param matrix defines the matrix to use
  14511. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  14512. */
  14513. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  14514. /**
  14515. * Compute the transpose of a given matrix
  14516. * @param matrix defines the matrix to transpose
  14517. * @returns the new matrix
  14518. */
  14519. static Transpose(matrix: Matrix): Matrix;
  14520. /**
  14521. * Compute the transpose of a matrix and store it in a target matrix
  14522. * @param matrix defines the matrix to transpose
  14523. * @param result defines the target matrix
  14524. */
  14525. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  14526. /**
  14527. * Computes a reflection matrix from a plane
  14528. * @param plane defines the reflection plane
  14529. * @returns a new matrix
  14530. */
  14531. static Reflection(plane: Plane): Matrix;
  14532. /**
  14533. * Computes a reflection matrix from a plane
  14534. * @param plane defines the reflection plane
  14535. * @param result defines the target matrix
  14536. */
  14537. static ReflectionToRef(plane: Plane, result: Matrix): void;
  14538. /**
  14539. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  14540. * @param xaxis defines the value of the 1st axis
  14541. * @param yaxis defines the value of the 2nd axis
  14542. * @param zaxis defines the value of the 3rd axis
  14543. * @param result defines the target matrix
  14544. */
  14545. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  14546. /**
  14547. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  14548. * @param quat defines the quaternion to use
  14549. * @param result defines the target matrix
  14550. */
  14551. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  14552. }
  14553. class Plane {
  14554. normal: Vector3;
  14555. d: number;
  14556. /**
  14557. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  14558. */
  14559. constructor(a: number, b: number, c: number, d: number);
  14560. /**
  14561. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  14562. */
  14563. asArray(): number[];
  14564. /**
  14565. * Returns a new plane copied from the current Plane.
  14566. */
  14567. clone(): Plane;
  14568. /**
  14569. * Returns the string "Plane".
  14570. */
  14571. getClassName(): string;
  14572. /**
  14573. * Returns the Plane hash code.
  14574. */
  14575. getHashCode(): number;
  14576. /**
  14577. * Normalize the current Plane in place.
  14578. * Returns the updated Plane.
  14579. */
  14580. normalize(): Plane;
  14581. /**
  14582. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  14583. */
  14584. transform(transformation: Matrix): Plane;
  14585. /**
  14586. * Returns the dot product (float) of the point coordinates and the plane normal.
  14587. */
  14588. dotCoordinate(point: Vector3): number;
  14589. /**
  14590. * Updates the current Plane from the plane defined by the three given points.
  14591. * Returns the updated Plane.
  14592. */
  14593. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14594. /**
  14595. * Boolean : True is the vector "direction" is the same side than the plane normal.
  14596. */
  14597. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  14598. /**
  14599. * Returns the signed distance (float) from the given point to the Plane.
  14600. */
  14601. signedDistanceTo(point: Vector3): number;
  14602. /**
  14603. * Returns a new Plane from the given array.
  14604. */
  14605. static FromArray(array: ArrayLike<number>): Plane;
  14606. /**
  14607. * Returns a new Plane defined by the three given points.
  14608. */
  14609. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14610. /**
  14611. * Returns a new Plane the normal vector to this plane at the given origin point.
  14612. * Note : the vector "normal" is updated because normalized.
  14613. */
  14614. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  14615. /**
  14616. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  14617. */
  14618. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  14619. }
  14620. class Viewport {
  14621. x: number;
  14622. y: number;
  14623. width: number;
  14624. height: number;
  14625. /**
  14626. * Creates a Viewport object located at (x, y) and sized (width, height).
  14627. */
  14628. constructor(x: number, y: number, width: number, height: number);
  14629. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  14630. /**
  14631. * Returns a new Viewport copied from the current one.
  14632. */
  14633. clone(): Viewport;
  14634. }
  14635. class Frustum {
  14636. /**
  14637. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14638. */
  14639. static GetPlanes(transform: Matrix): Plane[];
  14640. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14641. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14642. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14643. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14644. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14645. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14646. /**
  14647. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14648. */
  14649. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  14650. }
  14651. /** Defines supported spaces */
  14652. enum Space {
  14653. /** Local (object) space */
  14654. LOCAL = 0,
  14655. /** World space */
  14656. WORLD = 1,
  14657. /** Bone space */
  14658. BONE = 2,
  14659. }
  14660. /** Defines the 3 main axes */
  14661. class Axis {
  14662. /** X axis */
  14663. static X: Vector3;
  14664. /** Y axis */
  14665. static Y: Vector3;
  14666. /** Z axis */
  14667. static Z: Vector3;
  14668. }
  14669. class BezierCurve {
  14670. /**
  14671. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  14672. */
  14673. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  14674. }
  14675. /**
  14676. * Defines potential orientation for back face culling
  14677. */
  14678. enum Orientation {
  14679. /**
  14680. * Clockwise
  14681. */
  14682. CW = 0,
  14683. /** Counter clockwise */
  14684. CCW = 1,
  14685. }
  14686. /**
  14687. * Defines angle representation
  14688. */
  14689. class Angle {
  14690. private _radians;
  14691. /**
  14692. * Creates an Angle object of "radians" radians (float).
  14693. */
  14694. constructor(radians: number);
  14695. /**
  14696. * Get value in degrees
  14697. * @returns the Angle value in degrees (float)
  14698. */
  14699. degrees(): number;
  14700. /**
  14701. * Get value in radians
  14702. * @returns the Angle value in radians (float)
  14703. */
  14704. radians(): number;
  14705. /**
  14706. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  14707. * @param a defines first vector
  14708. * @param b defines second vector
  14709. * @returns a new Angle
  14710. */
  14711. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  14712. /**
  14713. * Gets a new Angle object from the given float in radians
  14714. * @param radians defines the angle value in radians
  14715. * @returns a new Angle
  14716. */
  14717. static FromRadians(radians: number): Angle;
  14718. /**
  14719. * Gets a new Angle object from the given float in degrees
  14720. * @param degrees defines the angle value in degrees
  14721. * @returns a new Angle
  14722. */
  14723. static FromDegrees(degrees: number): Angle;
  14724. }
  14725. class Arc2 {
  14726. startPoint: Vector2;
  14727. midPoint: Vector2;
  14728. endPoint: Vector2;
  14729. centerPoint: Vector2;
  14730. radius: number;
  14731. angle: Angle;
  14732. startAngle: Angle;
  14733. orientation: Orientation;
  14734. /**
  14735. * Creates an Arc object from the three given points : start, middle and end.
  14736. */
  14737. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  14738. }
  14739. class Path2 {
  14740. private _points;
  14741. private _length;
  14742. closed: boolean;
  14743. /**
  14744. * Creates a Path2 object from the starting 2D coordinates x and y.
  14745. */
  14746. constructor(x: number, y: number);
  14747. /**
  14748. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  14749. * Returns the updated Path2.
  14750. */
  14751. addLineTo(x: number, y: number): Path2;
  14752. /**
  14753. * 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.
  14754. * Returns the updated Path2.
  14755. */
  14756. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  14757. /**
  14758. * Closes the Path2.
  14759. * Returns the Path2.
  14760. */
  14761. close(): Path2;
  14762. /**
  14763. * Returns the Path2 total length (float).
  14764. */
  14765. length(): number;
  14766. /**
  14767. * Returns the Path2 internal array of points.
  14768. */
  14769. getPoints(): Vector2[];
  14770. /**
  14771. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  14772. */
  14773. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  14774. /**
  14775. * Returns a new Path2 starting at the coordinates (x, y).
  14776. */
  14777. static StartingAt(x: number, y: number): Path2;
  14778. }
  14779. class Path3D {
  14780. path: Vector3[];
  14781. private _curve;
  14782. private _distances;
  14783. private _tangents;
  14784. private _normals;
  14785. private _binormals;
  14786. private _raw;
  14787. /**
  14788. * new Path3D(path, normal, raw)
  14789. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  14790. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  14791. * path : an array of Vector3, the curve axis of the Path3D
  14792. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  14793. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  14794. */
  14795. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  14796. /**
  14797. * Returns the Path3D array of successive Vector3 designing its curve.
  14798. */
  14799. getCurve(): Vector3[];
  14800. /**
  14801. * Returns an array populated with tangent vectors on each Path3D curve point.
  14802. */
  14803. getTangents(): Vector3[];
  14804. /**
  14805. * Returns an array populated with normal vectors on each Path3D curve point.
  14806. */
  14807. getNormals(): Vector3[];
  14808. /**
  14809. * Returns an array populated with binormal vectors on each Path3D curve point.
  14810. */
  14811. getBinormals(): Vector3[];
  14812. /**
  14813. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  14814. */
  14815. getDistances(): number[];
  14816. /**
  14817. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  14818. * Returns the same object updated.
  14819. */
  14820. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  14821. private _compute(firstNormal);
  14822. private _getFirstNonNullVector(index);
  14823. private _getLastNonNullVector(index);
  14824. private _normalVector(v0, vt, va);
  14825. }
  14826. class Curve3 {
  14827. private _points;
  14828. private _length;
  14829. /**
  14830. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  14831. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  14832. * @param v1 (Vector3) the control point
  14833. * @param v2 (Vector3) the end point of the Quadratic Bezier
  14834. * @param nbPoints (integer) the wanted number of points in the curve
  14835. */
  14836. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  14837. /**
  14838. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  14839. * @param v0 (Vector3) the origin point of the Cubic Bezier
  14840. * @param v1 (Vector3) the first control point
  14841. * @param v2 (Vector3) the second control point
  14842. * @param v3 (Vector3) the end point of the Cubic Bezier
  14843. * @param nbPoints (integer) the wanted number of points in the curve
  14844. */
  14845. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  14846. /**
  14847. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  14848. * @param p1 (Vector3) the origin point of the Hermite Spline
  14849. * @param t1 (Vector3) the tangent vector at the origin point
  14850. * @param p2 (Vector3) the end point of the Hermite Spline
  14851. * @param t2 (Vector3) the tangent vector at the end point
  14852. * @param nbPoints (integer) the wanted number of points in the curve
  14853. */
  14854. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  14855. /**
  14856. * Returns a Curve3 object along a CatmullRom Spline curve :
  14857. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  14858. * @param nbPoints (integer) the wanted number of points between each curve control points.
  14859. */
  14860. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  14861. /**
  14862. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  14863. * A Curve3 is designed from a series of successive Vector3.
  14864. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  14865. */
  14866. constructor(points: Vector3[]);
  14867. /**
  14868. * Returns the Curve3 stored array of successive Vector3
  14869. */
  14870. getPoints(): Vector3[];
  14871. /**
  14872. * Returns the computed length (float) of the curve.
  14873. */
  14874. length(): number;
  14875. /**
  14876. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  14877. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  14878. * curveA and curveB keep unchanged.
  14879. */
  14880. continue(curve: Curve3): Curve3;
  14881. private _computeLength(path);
  14882. }
  14883. class PositionNormalVertex {
  14884. position: Vector3;
  14885. normal: Vector3;
  14886. constructor(position?: Vector3, normal?: Vector3);
  14887. clone(): PositionNormalVertex;
  14888. }
  14889. class PositionNormalTextureVertex {
  14890. position: Vector3;
  14891. normal: Vector3;
  14892. uv: Vector2;
  14893. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  14894. clone(): PositionNormalTextureVertex;
  14895. }
  14896. class Tmp {
  14897. static Color3: Color3[];
  14898. static Vector2: Vector2[];
  14899. static Vector3: Vector3[];
  14900. static Vector4: Vector4[];
  14901. static Quaternion: Quaternion[];
  14902. static Matrix: Matrix[];
  14903. }
  14904. }
  14905. declare module BABYLON {
  14906. class SphericalPolynomial {
  14907. x: Vector3;
  14908. y: Vector3;
  14909. z: Vector3;
  14910. xx: Vector3;
  14911. yy: Vector3;
  14912. zz: Vector3;
  14913. xy: Vector3;
  14914. yz: Vector3;
  14915. zx: Vector3;
  14916. addAmbient(color: Color3): void;
  14917. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  14918. scale(scale: number): void;
  14919. }
  14920. class SphericalHarmonics {
  14921. L00: Vector3;
  14922. L1_1: Vector3;
  14923. L10: Vector3;
  14924. L11: Vector3;
  14925. L2_2: Vector3;
  14926. L2_1: Vector3;
  14927. L20: Vector3;
  14928. L21: Vector3;
  14929. L22: Vector3;
  14930. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  14931. scale(scale: number): void;
  14932. convertIncidentRadianceToIrradiance(): void;
  14933. convertIrradianceToLambertianRadiance(): void;
  14934. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  14935. }
  14936. }
  14937. declare module BABYLON {
  14938. /**
  14939. * Defines a target to use with MorphTargetManager
  14940. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14941. */
  14942. class MorphTarget implements IAnimatable {
  14943. /** defines the name of the target */
  14944. name: string;
  14945. /**
  14946. * Gets or sets the list of animations
  14947. */
  14948. animations: Animation[];
  14949. private _scene;
  14950. private _positions;
  14951. private _normals;
  14952. private _tangents;
  14953. private _influence;
  14954. /**
  14955. * Observable raised when the influence changes
  14956. */
  14957. onInfluenceChanged: Observable<boolean>;
  14958. /**
  14959. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  14960. */
  14961. influence: number;
  14962. private _animationPropertiesOverride;
  14963. /**
  14964. * Gets or sets the animation properties override
  14965. */
  14966. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14967. /**
  14968. * Creates a new MorphTarget
  14969. * @param name defines the name of the target
  14970. * @param influence defines the influence to use
  14971. */
  14972. constructor(
  14973. /** defines the name of the target */
  14974. name: string, influence?: number, scene?: Nullable<Scene>);
  14975. /**
  14976. * Gets a boolean defining if the target contains position data
  14977. */
  14978. readonly hasPositions: boolean;
  14979. /**
  14980. * Gets a boolean defining if the target contains normal data
  14981. */
  14982. readonly hasNormals: boolean;
  14983. /**
  14984. * Gets a boolean defining if the target contains tangent data
  14985. */
  14986. readonly hasTangents: boolean;
  14987. /**
  14988. * Affects position data to this target
  14989. * @param data defines the position data to use
  14990. */
  14991. setPositions(data: Nullable<FloatArray>): void;
  14992. /**
  14993. * Gets the position data stored in this target
  14994. * @returns a FloatArray containing the position data (or null if not present)
  14995. */
  14996. getPositions(): Nullable<FloatArray>;
  14997. /**
  14998. * Affects normal data to this target
  14999. * @param data defines the normal data to use
  15000. */
  15001. setNormals(data: Nullable<FloatArray>): void;
  15002. /**
  15003. * Gets the normal data stored in this target
  15004. * @returns a FloatArray containing the normal data (or null if not present)
  15005. */
  15006. getNormals(): Nullable<FloatArray>;
  15007. /**
  15008. * Affects tangent data to this target
  15009. * @param data defines the tangent data to use
  15010. */
  15011. setTangents(data: Nullable<FloatArray>): void;
  15012. /**
  15013. * Gets the tangent data stored in this target
  15014. * @returns a FloatArray containing the tangent data (or null if not present)
  15015. */
  15016. getTangents(): Nullable<FloatArray>;
  15017. /**
  15018. * Serializes the current target into a Serialization object
  15019. * @returns the serialized object
  15020. */
  15021. serialize(): any;
  15022. /**
  15023. * Creates a new target from serialized data
  15024. * @param serializationObject defines the serialized data to use
  15025. * @returns a new MorphTarget
  15026. */
  15027. static Parse(serializationObject: any): MorphTarget;
  15028. /**
  15029. * Creates a MorphTarget from mesh data
  15030. * @param mesh defines the source mesh
  15031. * @param name defines the name to use for the new target
  15032. * @param influence defines the influence to attach to the target
  15033. * @returns a new MorphTarget
  15034. */
  15035. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  15036. }
  15037. }
  15038. declare module BABYLON {
  15039. /**
  15040. * This class is used to deform meshes using morphing between different targets
  15041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  15042. */
  15043. class MorphTargetManager {
  15044. private _targets;
  15045. private _targetObservable;
  15046. private _activeTargets;
  15047. private _scene;
  15048. private _influences;
  15049. private _supportsNormals;
  15050. private _supportsTangents;
  15051. private _vertexCount;
  15052. private _uniqueId;
  15053. private _tempInfluences;
  15054. /**
  15055. * Creates a new MorphTargetManager
  15056. * @param scene defines the current scene
  15057. */
  15058. constructor(scene?: Nullable<Scene>);
  15059. /**
  15060. * Gets the unique ID of this manager
  15061. */
  15062. readonly uniqueId: number;
  15063. /**
  15064. * Gets the number of vertices handled by this manager
  15065. */
  15066. readonly vertexCount: number;
  15067. /**
  15068. * Gets a boolean indicating if this manager supports morphing of normals
  15069. */
  15070. readonly supportsNormals: boolean;
  15071. /**
  15072. * Gets a boolean indicating if this manager supports morphing of tangents
  15073. */
  15074. readonly supportsTangents: boolean;
  15075. /**
  15076. * Gets the number of targets stored in this manager
  15077. */
  15078. readonly numTargets: number;
  15079. /**
  15080. * Gets the number of influencers (ie. the number of targets with influences > 0)
  15081. */
  15082. readonly numInfluencers: number;
  15083. /**
  15084. * Gets the list of influences (one per target)
  15085. */
  15086. readonly influences: Float32Array;
  15087. /**
  15088. * Gets the active target at specified index. An active target is a target with an influence > 0
  15089. * @param index defines the index to check
  15090. * @returns the requested target
  15091. */
  15092. getActiveTarget(index: number): MorphTarget;
  15093. /**
  15094. * Gets the target at specified index
  15095. * @param index defines the index to check
  15096. * @returns the requested target
  15097. */
  15098. getTarget(index: number): MorphTarget;
  15099. /**
  15100. * Add a new target to this manager
  15101. * @param target defines the target to add
  15102. */
  15103. addTarget(target: MorphTarget): void;
  15104. /**
  15105. * Removes a target from the manager
  15106. * @param target defines the target to remove
  15107. */
  15108. removeTarget(target: MorphTarget): void;
  15109. /**
  15110. * Serializes the current manager into a Serialization object
  15111. * @returns the serialized object
  15112. */
  15113. serialize(): any;
  15114. private _syncActiveTargets(needUpdate);
  15115. /**
  15116. * Syncrhonize the targets with all the meshes using this morph target manager
  15117. */
  15118. synchronize(): void;
  15119. /**
  15120. * Creates a new MorphTargetManager from serialized data
  15121. * @param serializationObject defines the serialized data
  15122. * @param scene defines the hosting scene
  15123. * @returns the new MorphTargetManager
  15124. */
  15125. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  15126. }
  15127. }
  15128. declare module BABYLON {
  15129. /**
  15130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15132. * 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;
  15133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15134. */
  15135. class ColorCurves {
  15136. private _dirty;
  15137. private _tempColor;
  15138. private _globalCurve;
  15139. private _highlightsCurve;
  15140. private _midtonesCurve;
  15141. private _shadowsCurve;
  15142. private _positiveCurve;
  15143. private _negativeCurve;
  15144. private _globalHue;
  15145. private _globalDensity;
  15146. private _globalSaturation;
  15147. private _globalExposure;
  15148. /**
  15149. * Gets the global Hue value.
  15150. * 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).
  15151. */
  15152. /**
  15153. * Sets the global Hue value.
  15154. * 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).
  15155. */
  15156. globalHue: number;
  15157. /**
  15158. * Gets the global Density value.
  15159. * 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.
  15160. * Values less than zero provide a filter of opposite hue.
  15161. */
  15162. /**
  15163. * Sets the global Density value.
  15164. * 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.
  15165. * Values less than zero provide a filter of opposite hue.
  15166. */
  15167. globalDensity: number;
  15168. /**
  15169. * Gets the global Saturation value.
  15170. * 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.
  15171. */
  15172. /**
  15173. * Sets the global Saturation value.
  15174. * 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.
  15175. */
  15176. globalSaturation: number;
  15177. private _highlightsHue;
  15178. private _highlightsDensity;
  15179. private _highlightsSaturation;
  15180. private _highlightsExposure;
  15181. /**
  15182. * Gets the highlights Hue value.
  15183. * 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).
  15184. */
  15185. /**
  15186. * Sets the highlights Hue value.
  15187. * 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).
  15188. */
  15189. highlightsHue: number;
  15190. /**
  15191. * Gets the highlights Density value.
  15192. * 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.
  15193. * Values less than zero provide a filter of opposite hue.
  15194. */
  15195. /**
  15196. * Sets the highlights Density value.
  15197. * 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.
  15198. * Values less than zero provide a filter of opposite hue.
  15199. */
  15200. highlightsDensity: number;
  15201. /**
  15202. * Gets the highlights Saturation value.
  15203. * 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.
  15204. */
  15205. /**
  15206. * Sets the highlights Saturation value.
  15207. * 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.
  15208. */
  15209. highlightsSaturation: number;
  15210. /**
  15211. * Gets the highlights Exposure value.
  15212. * 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.
  15213. */
  15214. /**
  15215. * Sets the highlights Exposure value.
  15216. * 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.
  15217. */
  15218. highlightsExposure: number;
  15219. private _midtonesHue;
  15220. private _midtonesDensity;
  15221. private _midtonesSaturation;
  15222. private _midtonesExposure;
  15223. /**
  15224. * Gets the midtones Hue value.
  15225. * 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).
  15226. */
  15227. /**
  15228. * Sets the midtones Hue value.
  15229. * 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).
  15230. */
  15231. midtonesHue: number;
  15232. /**
  15233. * Gets the midtones Density value.
  15234. * 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.
  15235. * Values less than zero provide a filter of opposite hue.
  15236. */
  15237. /**
  15238. * Sets the midtones Density value.
  15239. * 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.
  15240. * Values less than zero provide a filter of opposite hue.
  15241. */
  15242. midtonesDensity: number;
  15243. /**
  15244. * Gets the midtones Saturation value.
  15245. * 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.
  15246. */
  15247. /**
  15248. * Sets the midtones Saturation value.
  15249. * 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.
  15250. */
  15251. midtonesSaturation: number;
  15252. /**
  15253. * Gets the midtones Exposure value.
  15254. * 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.
  15255. */
  15256. /**
  15257. * Sets the midtones Exposure value.
  15258. * 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.
  15259. */
  15260. midtonesExposure: number;
  15261. private _shadowsHue;
  15262. private _shadowsDensity;
  15263. private _shadowsSaturation;
  15264. private _shadowsExposure;
  15265. /**
  15266. * Gets the shadows Hue value.
  15267. * 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).
  15268. */
  15269. /**
  15270. * Sets the shadows Hue value.
  15271. * 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).
  15272. */
  15273. shadowsHue: number;
  15274. /**
  15275. * Gets the shadows Density value.
  15276. * 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.
  15277. * Values less than zero provide a filter of opposite hue.
  15278. */
  15279. /**
  15280. * Sets the shadows Density value.
  15281. * 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.
  15282. * Values less than zero provide a filter of opposite hue.
  15283. */
  15284. shadowsDensity: number;
  15285. /**
  15286. * Gets the shadows Saturation value.
  15287. * 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.
  15288. */
  15289. /**
  15290. * Sets the shadows Saturation value.
  15291. * 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.
  15292. */
  15293. shadowsSaturation: number;
  15294. /**
  15295. * Gets the shadows Exposure value.
  15296. * 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.
  15297. */
  15298. /**
  15299. * Sets the shadows Exposure value.
  15300. * 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.
  15301. */
  15302. shadowsExposure: number;
  15303. getClassName(): string;
  15304. /**
  15305. * Binds the color curves to the shader.
  15306. * @param colorCurves The color curve to bind
  15307. * @param effect The effect to bind to
  15308. */
  15309. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15310. /**
  15311. * Prepare the list of uniforms associated with the ColorCurves effects.
  15312. * @param uniformsList The list of uniforms used in the effect
  15313. */
  15314. static PrepareUniforms(uniformsList: string[]): void;
  15315. /**
  15316. * Returns color grading data based on a hue, density, saturation and exposure value.
  15317. * @param filterHue The hue of the color filter.
  15318. * @param filterDensity The density of the color filter.
  15319. * @param saturation The saturation.
  15320. * @param exposure The exposure.
  15321. * @param result The result data container.
  15322. */
  15323. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  15324. /**
  15325. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15326. * @param value The input slider value in range [-100,100].
  15327. * @returns Adjusted value.
  15328. */
  15329. private static applyColorGradingSliderNonlinear(value);
  15330. /**
  15331. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15332. * @param hue The hue (H) input.
  15333. * @param saturation The saturation (S) input.
  15334. * @param brightness The brightness (B) input.
  15335. * @result An RGBA color represented as Vector4.
  15336. */
  15337. private static fromHSBToRef(hue, saturation, brightness, result);
  15338. /**
  15339. * Returns a value clamped between min and max
  15340. * @param value The value to clamp
  15341. * @param min The minimum of value
  15342. * @param max The maximum of value
  15343. * @returns The clamped value.
  15344. */
  15345. private static clamp(value, min, max);
  15346. /**
  15347. * Clones the current color curve instance.
  15348. * @return The cloned curves
  15349. */
  15350. clone(): ColorCurves;
  15351. /**
  15352. * Serializes the current color curve instance to a json representation.
  15353. * @return a JSON representation
  15354. */
  15355. serialize(): any;
  15356. /**
  15357. * Parses the color curve from a json representation.
  15358. * @param source the JSON source to parse
  15359. * @return The parsed curves
  15360. */
  15361. static Parse(source: any): ColorCurves;
  15362. }
  15363. }
  15364. declare module BABYLON {
  15365. /**
  15366. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15367. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15368. */
  15369. class EffectFallbacks {
  15370. private _defines;
  15371. private _currentRank;
  15372. private _maxRank;
  15373. private _mesh;
  15374. /**
  15375. * Removes the fallback from the bound mesh.
  15376. */
  15377. unBindMesh(): void;
  15378. /**
  15379. * Adds a fallback on the specified property.
  15380. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15381. * @param define The name of the define in the shader
  15382. */
  15383. addFallback(rank: number, define: string): void;
  15384. /**
  15385. * Sets the mesh to use CPU skinning when needing to fallback.
  15386. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15387. * @param mesh The mesh to use the fallbacks.
  15388. */
  15389. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15390. /**
  15391. * Checks to see if more fallbacks are still availible.
  15392. */
  15393. readonly isMoreFallbacks: boolean;
  15394. /**
  15395. * Removes the defines that shoould be removed when falling back.
  15396. * @param currentDefines defines the current define statements for the shader.
  15397. * @param effect defines the current effect we try to compile
  15398. * @returns The resulting defines with defines of the current rank removed.
  15399. */
  15400. reduce(currentDefines: string, effect: Effect): string;
  15401. }
  15402. /**
  15403. * Options to be used when creating an effect.
  15404. */
  15405. class EffectCreationOptions {
  15406. /**
  15407. * Atrributes that will be used in the shader.
  15408. */
  15409. attributes: string[];
  15410. /**
  15411. * Uniform varible names that will be set in the shader.
  15412. */
  15413. uniformsNames: string[];
  15414. /**
  15415. * Uniform buffer varible names that will be set in the shader.
  15416. */
  15417. uniformBuffersNames: string[];
  15418. /**
  15419. * Sampler texture variable names that will be set in the shader.
  15420. */
  15421. samplers: string[];
  15422. /**
  15423. * Define statements that will be set in the shader.
  15424. */
  15425. defines: any;
  15426. /**
  15427. * Possible fallbacks for this effect to improve performance when needed.
  15428. */
  15429. fallbacks: Nullable<EffectFallbacks>;
  15430. /**
  15431. * Callback that will be called when the shader is compiled.
  15432. */
  15433. onCompiled: Nullable<(effect: Effect) => void>;
  15434. /**
  15435. * Callback that will be called if an error occurs during shader compilation.
  15436. */
  15437. onError: Nullable<(effect: Effect, errors: string) => void>;
  15438. /**
  15439. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15440. */
  15441. indexParameters: any;
  15442. /**
  15443. * Max number of lights that can be used in the shader.
  15444. */
  15445. maxSimultaneousLights: number;
  15446. /**
  15447. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  15448. */
  15449. transformFeedbackVaryings: Nullable<string[]>;
  15450. }
  15451. /**
  15452. * Effect containing vertex and fragment shader that can be executed on an object.
  15453. */
  15454. class Effect {
  15455. /**
  15456. * Name of the effect.
  15457. */
  15458. name: any;
  15459. /**
  15460. * String container all the define statements that should be set on the shader.
  15461. */
  15462. defines: string;
  15463. /**
  15464. * Callback that will be called when the shader is compiled.
  15465. */
  15466. onCompiled: Nullable<(effect: Effect) => void>;
  15467. /**
  15468. * Callback that will be called if an error occurs during shader compilation.
  15469. */
  15470. onError: Nullable<(effect: Effect, errors: string) => void>;
  15471. /**
  15472. * Callback that will be called when effect is bound.
  15473. */
  15474. onBind: Nullable<(effect: Effect) => void>;
  15475. /**
  15476. * Unique ID of the effect.
  15477. */
  15478. uniqueId: number;
  15479. /**
  15480. * Observable that will be called when the shader is compiled.
  15481. */
  15482. onCompileObservable: Observable<Effect>;
  15483. /**
  15484. * Observable that will be called if an error occurs during shader compilation.
  15485. */
  15486. onErrorObservable: Observable<Effect>;
  15487. /**
  15488. * Observable that will be called when effect is bound.
  15489. */
  15490. onBindObservable: Observable<Effect>;
  15491. private static _uniqueIdSeed;
  15492. private _engine;
  15493. private _uniformBuffersNames;
  15494. private _uniformsNames;
  15495. private _samplers;
  15496. private _isReady;
  15497. private _compilationError;
  15498. private _attributesNames;
  15499. private _attributes;
  15500. private _uniforms;
  15501. /**
  15502. * Key for the effect.
  15503. */
  15504. private _indexParameters;
  15505. private _fallbacks;
  15506. private _vertexSourceCode;
  15507. private _fragmentSourceCode;
  15508. private _vertexSourceCodeOverride;
  15509. private _fragmentSourceCodeOverride;
  15510. private _transformFeedbackVaryings;
  15511. /**
  15512. * Compiled shader to webGL program.
  15513. */
  15514. private _valueCache;
  15515. private static _baseCache;
  15516. /**
  15517. * Instantiates an effect.
  15518. * An effect can be used to create/manage/execute vertex and fragment shaders.
  15519. * @param baseName Name of the effect.
  15520. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  15521. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  15522. * @param samplers List of sampler variables that will be passed to the shader.
  15523. * @param engine Engine to be used to render the effect
  15524. * @param defines Define statements to be added to the shader.
  15525. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  15526. * @param onCompiled Callback that will be called when the shader is compiled.
  15527. * @param onError Callback that will be called if an error occurs during shader compilation.
  15528. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15529. */
  15530. 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);
  15531. /**
  15532. * Unique key for this effect
  15533. */
  15534. readonly key: string;
  15535. /**
  15536. * If the effect has been compiled and prepared.
  15537. * @returns if the effect is compiled and prepared.
  15538. */
  15539. isReady(): boolean;
  15540. /**
  15541. * The engine the effect was initialized with.
  15542. * @returns the engine.
  15543. */
  15544. getEngine(): Engine;
  15545. /**
  15546. * The compiled webGL program for the effect
  15547. * @returns the webGL program.
  15548. */
  15549. getProgram(): WebGLProgram;
  15550. /**
  15551. * The set of names of attribute variables for the shader.
  15552. * @returns An array of attribute names.
  15553. */
  15554. getAttributesNames(): string[];
  15555. /**
  15556. * Returns the attribute at the given index.
  15557. * @param index The index of the attribute.
  15558. * @returns The location of the attribute.
  15559. */
  15560. getAttributeLocation(index: number): number;
  15561. /**
  15562. * Returns the attribute based on the name of the variable.
  15563. * @param name of the attribute to look up.
  15564. * @returns the attribute location.
  15565. */
  15566. getAttributeLocationByName(name: string): number;
  15567. /**
  15568. * The number of attributes.
  15569. * @returns the numnber of attributes.
  15570. */
  15571. getAttributesCount(): number;
  15572. /**
  15573. * Gets the index of a uniform variable.
  15574. * @param uniformName of the uniform to look up.
  15575. * @returns the index.
  15576. */
  15577. getUniformIndex(uniformName: string): number;
  15578. /**
  15579. * Returns the attribute based on the name of the variable.
  15580. * @param uniformName of the uniform to look up.
  15581. * @returns the location of the uniform.
  15582. */
  15583. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  15584. /**
  15585. * Returns an array of sampler variable names
  15586. * @returns The array of sampler variable neames.
  15587. */
  15588. getSamplers(): string[];
  15589. /**
  15590. * The error from the last compilation.
  15591. * @returns the error string.
  15592. */
  15593. getCompilationError(): string;
  15594. /**
  15595. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  15596. * @param func The callback to be used.
  15597. */
  15598. executeWhenCompiled(func: (effect: Effect) => void): void;
  15599. /** @hidden */
  15600. /** @hidden */
  15601. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  15602. private _processShaderConversion(sourceCode, isFragment, callback);
  15603. private _processIncludes(sourceCode, callback);
  15604. private _processPrecision(source);
  15605. /**
  15606. * Recompiles the webGL program
  15607. * @param vertexSourceCode The source code for the vertex shader.
  15608. * @param fragmentSourceCode The source code for the fragment shader.
  15609. * @param onCompiled Callback called when completed.
  15610. * @param onError Callback called on error.
  15611. */
  15612. /**
  15613. * Gets the uniform locations of the the specified variable names
  15614. * @param names THe names of the variables to lookup.
  15615. * @returns Array of locations in the same order as variable names.
  15616. */
  15617. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  15618. /**
  15619. * Prepares the effect
  15620. */
  15621. /**
  15622. * Checks if the effect is supported. (Must be called after compilation)
  15623. */
  15624. readonly isSupported: boolean;
  15625. /**
  15626. * Binds a texture to the engine to be used as output of the shader.
  15627. * @param channel Name of the output variable.
  15628. * @param texture Texture to bind.
  15629. */
  15630. /**
  15631. * Sets a texture on the engine to be used in the shader.
  15632. * @param channel Name of the sampler variable.
  15633. * @param texture Texture to set.
  15634. */
  15635. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  15636. /**
  15637. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  15638. * @param channel Name of the sampler variable.
  15639. * @param texture Texture to set.
  15640. */
  15641. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  15642. /**
  15643. * Sets an array of textures on the engine to be used in the shader.
  15644. * @param channel Name of the variable.
  15645. * @param textures Textures to set.
  15646. */
  15647. setTextureArray(channel: string, textures: BaseTexture[]): void;
  15648. /**
  15649. * 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)
  15650. * @param channel Name of the sampler variable.
  15651. * @param postProcess Post process to get the input texture from.
  15652. */
  15653. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  15654. /**
  15655. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  15656. * 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)
  15657. * @param channel Name of the sampler variable.
  15658. * @param postProcess Post process to get the output texture from.
  15659. */
  15660. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  15661. /** @hidden */
  15662. /** @hidden */
  15663. /** @hidden */
  15664. /** @hidden */
  15665. /**
  15666. * Binds a buffer to a uniform.
  15667. * @param buffer Buffer to bind.
  15668. * @param name Name of the uniform variable to bind to.
  15669. */
  15670. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  15671. /**
  15672. * Binds block to a uniform.
  15673. * @param blockName Name of the block to bind.
  15674. * @param index Index to bind.
  15675. */
  15676. bindUniformBlock(blockName: string, index: number): void;
  15677. /**
  15678. * Sets an interger value on a uniform variable.
  15679. * @param uniformName Name of the variable.
  15680. * @param value Value to be set.
  15681. * @returns this effect.
  15682. */
  15683. setInt(uniformName: string, value: number): Effect;
  15684. /**
  15685. * Sets an int array on a uniform variable.
  15686. * @param uniformName Name of the variable.
  15687. * @param array array to be set.
  15688. * @returns this effect.
  15689. */
  15690. setIntArray(uniformName: string, array: Int32Array): Effect;
  15691. /**
  15692. * 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)
  15693. * @param uniformName Name of the variable.
  15694. * @param array array to be set.
  15695. * @returns this effect.
  15696. */
  15697. setIntArray2(uniformName: string, array: Int32Array): Effect;
  15698. /**
  15699. * 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)
  15700. * @param uniformName Name of the variable.
  15701. * @param array array to be set.
  15702. * @returns this effect.
  15703. */
  15704. setIntArray3(uniformName: string, array: Int32Array): Effect;
  15705. /**
  15706. * 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)
  15707. * @param uniformName Name of the variable.
  15708. * @param array array to be set.
  15709. * @returns this effect.
  15710. */
  15711. setIntArray4(uniformName: string, array: Int32Array): Effect;
  15712. /**
  15713. * Sets an float array on a uniform variable.
  15714. * @param uniformName Name of the variable.
  15715. * @param array array to be set.
  15716. * @returns this effect.
  15717. */
  15718. setFloatArray(uniformName: string, array: Float32Array): Effect;
  15719. /**
  15720. * 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)
  15721. * @param uniformName Name of the variable.
  15722. * @param array array to be set.
  15723. * @returns this effect.
  15724. */
  15725. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  15726. /**
  15727. * 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)
  15728. * @param uniformName Name of the variable.
  15729. * @param array array to be set.
  15730. * @returns this effect.
  15731. */
  15732. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  15733. /**
  15734. * 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)
  15735. * @param uniformName Name of the variable.
  15736. * @param array array to be set.
  15737. * @returns this effect.
  15738. */
  15739. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  15740. /**
  15741. * Sets an array on a uniform variable.
  15742. * @param uniformName Name of the variable.
  15743. * @param array array to be set.
  15744. * @returns this effect.
  15745. */
  15746. setArray(uniformName: string, array: number[]): Effect;
  15747. /**
  15748. * 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)
  15749. * @param uniformName Name of the variable.
  15750. * @param array array to be set.
  15751. * @returns this effect.
  15752. */
  15753. setArray2(uniformName: string, array: number[]): Effect;
  15754. /**
  15755. * 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)
  15756. * @param uniformName Name of the variable.
  15757. * @param array array to be set.
  15758. * @returns this effect.
  15759. */
  15760. setArray3(uniformName: string, array: number[]): Effect;
  15761. /**
  15762. * 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)
  15763. * @param uniformName Name of the variable.
  15764. * @param array array to be set.
  15765. * @returns this effect.
  15766. */
  15767. setArray4(uniformName: string, array: number[]): Effect;
  15768. /**
  15769. * Sets matrices on a uniform variable.
  15770. * @param uniformName Name of the variable.
  15771. * @param matrices matrices to be set.
  15772. * @returns this effect.
  15773. */
  15774. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  15775. /**
  15776. * Sets matrix on a uniform variable.
  15777. * @param uniformName Name of the variable.
  15778. * @param matrix matrix to be set.
  15779. * @returns this effect.
  15780. */
  15781. setMatrix(uniformName: string, matrix: Matrix): Effect;
  15782. /**
  15783. * 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)
  15784. * @param uniformName Name of the variable.
  15785. * @param matrix matrix to be set.
  15786. * @returns this effect.
  15787. */
  15788. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  15789. /**
  15790. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  15791. * @param uniformName Name of the variable.
  15792. * @param matrix matrix to be set.
  15793. * @returns this effect.
  15794. */
  15795. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  15796. /**
  15797. * Sets a float on a uniform variable.
  15798. * @param uniformName Name of the variable.
  15799. * @param value value to be set.
  15800. * @returns this effect.
  15801. */
  15802. setFloat(uniformName: string, value: number): Effect;
  15803. /**
  15804. * Sets a boolean on a uniform variable.
  15805. * @param uniformName Name of the variable.
  15806. * @param bool value to be set.
  15807. * @returns this effect.
  15808. */
  15809. setBool(uniformName: string, bool: boolean): Effect;
  15810. /**
  15811. * Sets a Vector2 on a uniform variable.
  15812. * @param uniformName Name of the variable.
  15813. * @param vector2 vector2 to be set.
  15814. * @returns this effect.
  15815. */
  15816. setVector2(uniformName: string, vector2: Vector2): Effect;
  15817. /**
  15818. * Sets a float2 on a uniform variable.
  15819. * @param uniformName Name of the variable.
  15820. * @param x First float in float2.
  15821. * @param y Second float in float2.
  15822. * @returns this effect.
  15823. */
  15824. setFloat2(uniformName: string, x: number, y: number): Effect;
  15825. /**
  15826. * Sets a Vector3 on a uniform variable.
  15827. * @param uniformName Name of the variable.
  15828. * @param vector3 Value to be set.
  15829. * @returns this effect.
  15830. */
  15831. setVector3(uniformName: string, vector3: Vector3): Effect;
  15832. /**
  15833. * Sets a float3 on a uniform variable.
  15834. * @param uniformName Name of the variable.
  15835. * @param x First float in float3.
  15836. * @param y Second float in float3.
  15837. * @param z Third float in float3.
  15838. * @returns this effect.
  15839. */
  15840. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  15841. /**
  15842. * Sets a Vector4 on a uniform variable.
  15843. * @param uniformName Name of the variable.
  15844. * @param vector4 Value to be set.
  15845. * @returns this effect.
  15846. */
  15847. setVector4(uniformName: string, vector4: Vector4): Effect;
  15848. /**
  15849. * Sets a float4 on a uniform variable.
  15850. * @param uniformName Name of the variable.
  15851. * @param x First float in float4.
  15852. * @param y Second float in float4.
  15853. * @param z Third float in float4.
  15854. * @param w Fourth float in float4.
  15855. * @returns this effect.
  15856. */
  15857. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  15858. /**
  15859. * Sets a Color3 on a uniform variable.
  15860. * @param uniformName Name of the variable.
  15861. * @param color3 Value to be set.
  15862. * @returns this effect.
  15863. */
  15864. setColor3(uniformName: string, color3: Color3): Effect;
  15865. /**
  15866. * Sets a Color4 on a uniform variable.
  15867. * @param uniformName Name of the variable.
  15868. * @param color3 Value to be set.
  15869. * @param alpha Alpha value to be set.
  15870. * @returns this effect.
  15871. */
  15872. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  15873. /**
  15874. * Sets a Color4 on a uniform variable
  15875. * @param uniformName defines the name of the variable
  15876. * @param color4 defines the value to be set
  15877. * @returns this effect.
  15878. */
  15879. setDirectColor4(uniformName: string, color4: Color4): Effect;
  15880. /**
  15881. * Store of each shader (The can be looked up using effect.key)
  15882. */
  15883. static ShadersStore: {
  15884. [key: string]: string;
  15885. };
  15886. /**
  15887. * Store of each included file for a shader (The can be looked up using effect.key)
  15888. */
  15889. static IncludesShadersStore: {
  15890. [key: string]: string;
  15891. };
  15892. /**
  15893. * Resets the cache of effects.
  15894. */
  15895. static ResetCache(): void;
  15896. }
  15897. }
  15898. declare module BABYLON {
  15899. class FresnelParameters {
  15900. private _isEnabled;
  15901. isEnabled: boolean;
  15902. leftColor: Color3;
  15903. rightColor: Color3;
  15904. bias: number;
  15905. power: number;
  15906. clone(): FresnelParameters;
  15907. serialize(): any;
  15908. static Parse(parsedFresnelParameters: any): FresnelParameters;
  15909. }
  15910. }
  15911. declare module BABYLON {
  15912. /**
  15913. * Interface to follow in your material defines to integrate easily the
  15914. * Image proccessing functions.
  15915. * @hidden
  15916. */
  15917. interface IImageProcessingConfigurationDefines {
  15918. IMAGEPROCESSING: boolean;
  15919. VIGNETTE: boolean;
  15920. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15921. VIGNETTEBLENDMODEOPAQUE: boolean;
  15922. TONEMAPPING: boolean;
  15923. CONTRAST: boolean;
  15924. EXPOSURE: boolean;
  15925. COLORCURVES: boolean;
  15926. COLORGRADING: boolean;
  15927. COLORGRADING3D: boolean;
  15928. SAMPLER3DGREENDEPTH: boolean;
  15929. SAMPLER3DBGRMAP: boolean;
  15930. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15931. }
  15932. /**
  15933. * This groups together the common properties used for image processing either in direct forward pass
  15934. * or through post processing effect depending on the use of the image processing pipeline in your scene
  15935. * or not.
  15936. */
  15937. class ImageProcessingConfiguration {
  15938. /**
  15939. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  15940. */
  15941. colorCurves: Nullable<ColorCurves>;
  15942. private _colorCurvesEnabled;
  15943. /**
  15944. * Gets wether the color curves effect is enabled.
  15945. */
  15946. /**
  15947. * Sets wether the color curves effect is enabled.
  15948. */
  15949. colorCurvesEnabled: boolean;
  15950. /**
  15951. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  15952. */
  15953. colorGradingTexture: Nullable<BaseTexture>;
  15954. private _colorGradingEnabled;
  15955. /**
  15956. * Gets wether the color grading effect is enabled.
  15957. */
  15958. /**
  15959. * Sets wether the color grading effect is enabled.
  15960. */
  15961. colorGradingEnabled: boolean;
  15962. private _colorGradingWithGreenDepth;
  15963. /**
  15964. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  15965. */
  15966. /**
  15967. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  15968. */
  15969. colorGradingWithGreenDepth: boolean;
  15970. private _colorGradingBGR;
  15971. /**
  15972. * Gets wether the color grading texture contains BGR values.
  15973. */
  15974. /**
  15975. * Sets wether the color grading texture contains BGR values.
  15976. */
  15977. colorGradingBGR: boolean;
  15978. /**
  15979. * Gets the Exposure used in the effect.
  15980. */
  15981. /**
  15982. * Sets the Exposure used in the effect.
  15983. */
  15984. exposure: number;
  15985. private _toneMappingEnabled;
  15986. /**
  15987. * Gets wether the tone mapping effect is enabled.
  15988. */
  15989. /**
  15990. * Sets wether the tone mapping effect is enabled.
  15991. */
  15992. toneMappingEnabled: boolean;
  15993. protected _contrast: number;
  15994. /**
  15995. * Gets the contrast used in the effect.
  15996. */
  15997. /**
  15998. * Sets the contrast used in the effect.
  15999. */
  16000. contrast: number;
  16001. /**
  16002. * Vignette stretch size.
  16003. */
  16004. vignetteStretch: number;
  16005. /**
  16006. * Vignette centre X Offset.
  16007. */
  16008. vignetteCentreX: number;
  16009. /**
  16010. * Vignette centre Y Offset.
  16011. */
  16012. vignetteCentreY: number;
  16013. /**
  16014. * Vignette weight or intensity of the vignette effect.
  16015. */
  16016. vignetteWeight: number;
  16017. /**
  16018. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16019. * if vignetteEnabled is set to true.
  16020. */
  16021. vignetteColor: Color4;
  16022. /**
  16023. * Camera field of view used by the Vignette effect.
  16024. */
  16025. vignetteCameraFov: number;
  16026. private _vignetteBlendMode;
  16027. /**
  16028. * Gets the vignette blend mode allowing different kind of effect.
  16029. */
  16030. /**
  16031. * Sets the vignette blend mode allowing different kind of effect.
  16032. */
  16033. vignetteBlendMode: number;
  16034. private _vignetteEnabled;
  16035. /**
  16036. * Gets wether the vignette effect is enabled.
  16037. */
  16038. /**
  16039. * Sets wether the vignette effect is enabled.
  16040. */
  16041. vignetteEnabled: boolean;
  16042. private _applyByPostProcess;
  16043. /**
  16044. * Gets wether the image processing is applied through a post process or not.
  16045. */
  16046. /**
  16047. * Sets wether the image processing is applied through a post process or not.
  16048. */
  16049. applyByPostProcess: boolean;
  16050. private _isEnabled;
  16051. /**
  16052. * Gets wether the image processing is enabled or not.
  16053. */
  16054. /**
  16055. * Sets wether the image processing is enabled or not.
  16056. */
  16057. isEnabled: boolean;
  16058. /**
  16059. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16060. */
  16061. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16062. /**
  16063. * Method called each time the image processing information changes requires to recompile the effect.
  16064. */
  16065. protected _updateParameters(): void;
  16066. getClassName(): string;
  16067. /**
  16068. * Prepare the list of uniforms associated with the Image Processing effects.
  16069. * @param uniformsList The list of uniforms used in the effect
  16070. * @param defines the list of defines currently in use
  16071. */
  16072. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16073. /**
  16074. * Prepare the list of samplers associated with the Image Processing effects.
  16075. * @param uniformsList The list of uniforms used in the effect
  16076. * @param defines the list of defines currently in use
  16077. */
  16078. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16079. /**
  16080. * Prepare the list of defines associated to the shader.
  16081. * @param defines the list of defines to complete
  16082. */
  16083. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16084. /**
  16085. * Returns true if all the image processing information are ready.
  16086. */
  16087. isReady(): boolean;
  16088. /**
  16089. * Binds the image processing to the shader.
  16090. * @param effect The effect to bind to
  16091. */
  16092. bind(effect: Effect, aspectRatio?: number): void;
  16093. /**
  16094. * Clones the current image processing instance.
  16095. * @return The cloned image processing
  16096. */
  16097. clone(): ImageProcessingConfiguration;
  16098. /**
  16099. * Serializes the current image processing instance to a json representation.
  16100. * @return a JSON representation
  16101. */
  16102. serialize(): any;
  16103. /**
  16104. * Parses the image processing from a json representation.
  16105. * @param source the JSON source to parse
  16106. * @return The parsed image processing
  16107. */
  16108. static Parse(source: any): ImageProcessingConfiguration;
  16109. private static _VIGNETTEMODE_MULTIPLY;
  16110. private static _VIGNETTEMODE_OPAQUE;
  16111. /**
  16112. * Used to apply the vignette as a mix with the pixel color.
  16113. */
  16114. static readonly VIGNETTEMODE_MULTIPLY: number;
  16115. /**
  16116. * Used to apply the vignette as a replacement of the pixel color.
  16117. */
  16118. static readonly VIGNETTEMODE_OPAQUE: number;
  16119. }
  16120. }
  16121. declare module BABYLON {
  16122. /**
  16123. * Manages the defines for the Material
  16124. */
  16125. class MaterialDefines {
  16126. private _keys;
  16127. private _isDirty;
  16128. /** @hidden */
  16129. /** @hidden */
  16130. /** @hidden */
  16131. /** @hidden */
  16132. /** @hidden */
  16133. /** @hidden */
  16134. /** @hidden */
  16135. /** @hidden */
  16136. /** @hidden */
  16137. /** @hidden */
  16138. /** @hidden */
  16139. /**
  16140. * Specifies if the material needs to be re-calculated
  16141. */
  16142. readonly isDirty: boolean;
  16143. /**
  16144. * Marks the material to indicate that it has been re-calculated
  16145. */
  16146. markAsProcessed(): void;
  16147. /**
  16148. * Marks the material to indicate that it needs to be re-calculated
  16149. */
  16150. markAsUnprocessed(): void;
  16151. /**
  16152. * Marks the material to indicate all of its defines need to be re-calculated
  16153. */
  16154. markAllAsDirty(): void;
  16155. /**
  16156. * Marks the material to indicate that image processing needs to be re-calculated
  16157. */
  16158. markAsImageProcessingDirty(): void;
  16159. /**
  16160. * Marks the material to indicate the lights need to be re-calculated
  16161. */
  16162. markAsLightDirty(): void;
  16163. /**
  16164. * Marks the attribute state as changed
  16165. */
  16166. markAsAttributesDirty(): void;
  16167. /**
  16168. * Marks the texture state as changed
  16169. */
  16170. markAsTexturesDirty(): void;
  16171. /**
  16172. * Marks the fresnel state as changed
  16173. */
  16174. markAsFresnelDirty(): void;
  16175. /**
  16176. * Marks the misc state as changed
  16177. */
  16178. markAsMiscDirty(): void;
  16179. /**
  16180. * Rebuilds the material defines
  16181. */
  16182. rebuild(): void;
  16183. /**
  16184. * Specifies if two material defines are equal
  16185. * @param other - A material define instance to compare to
  16186. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16187. */
  16188. isEqual(other: MaterialDefines): boolean;
  16189. /**
  16190. * Clones this instance's defines to another instance
  16191. * @param other - material defines to clone values to
  16192. */
  16193. cloneTo(other: MaterialDefines): void;
  16194. /**
  16195. * Resets the material define values
  16196. */
  16197. reset(): void;
  16198. /**
  16199. * Converts the material define values to a string
  16200. * @returns - String of material define information
  16201. */
  16202. toString(): string;
  16203. }
  16204. /**
  16205. * Base class for the main features of a material in Babylon.js
  16206. */
  16207. class Material implements IAnimatable {
  16208. private static _TriangleFillMode;
  16209. private static _WireFrameFillMode;
  16210. private static _PointFillMode;
  16211. private static _PointListDrawMode;
  16212. private static _LineListDrawMode;
  16213. private static _LineLoopDrawMode;
  16214. private static _LineStripDrawMode;
  16215. private static _TriangleStripDrawMode;
  16216. private static _TriangleFanDrawMode;
  16217. /**
  16218. * Returns the triangle fill mode
  16219. */
  16220. static readonly TriangleFillMode: number;
  16221. /**
  16222. * Returns the wireframe mode
  16223. */
  16224. static readonly WireFrameFillMode: number;
  16225. /**
  16226. * Returns the point fill mode
  16227. */
  16228. static readonly PointFillMode: number;
  16229. /**
  16230. * Returns the point list draw mode
  16231. */
  16232. static readonly PointListDrawMode: number;
  16233. /**
  16234. * Returns the line list draw mode
  16235. */
  16236. static readonly LineListDrawMode: number;
  16237. /**
  16238. * Returns the line loop draw mode
  16239. */
  16240. static readonly LineLoopDrawMode: number;
  16241. /**
  16242. * Returns the line strip draw mode
  16243. */
  16244. static readonly LineStripDrawMode: number;
  16245. /**
  16246. * Returns the triangle strip draw mode
  16247. */
  16248. static readonly TriangleStripDrawMode: number;
  16249. /**
  16250. * Returns the triangle fan draw mode
  16251. */
  16252. static readonly TriangleFanDrawMode: number;
  16253. /**
  16254. * Stores the clock-wise side orientation
  16255. */
  16256. private static _ClockWiseSideOrientation;
  16257. /**
  16258. * Stores the counter clock-wise side orientation
  16259. */
  16260. private static _CounterClockWiseSideOrientation;
  16261. /**
  16262. * Returns the clock-wise side orientation
  16263. */
  16264. static readonly ClockWiseSideOrientation: number;
  16265. /**
  16266. * Returns the counter clock-wise side orientation
  16267. */
  16268. static readonly CounterClockWiseSideOrientation: number;
  16269. /**
  16270. * The dirty texture flag value
  16271. */
  16272. private static _TextureDirtyFlag;
  16273. /**
  16274. * The dirty light flag value
  16275. */
  16276. private static _LightDirtyFlag;
  16277. /**
  16278. * The dirty fresnel flag value
  16279. */
  16280. private static _FresnelDirtyFlag;
  16281. /**
  16282. * The dirty attribute flag value
  16283. */
  16284. private static _AttributesDirtyFlag;
  16285. /**
  16286. * The dirty misc flag value
  16287. */
  16288. private static _MiscDirtyFlag;
  16289. /**
  16290. * Returns the dirty texture flag value
  16291. */
  16292. static readonly TextureDirtyFlag: number;
  16293. /**
  16294. * Returns the dirty light flag value
  16295. */
  16296. static readonly LightDirtyFlag: number;
  16297. /**
  16298. * Returns the dirty fresnel flag value
  16299. */
  16300. static readonly FresnelDirtyFlag: number;
  16301. /**
  16302. * Returns the dirty attributes flag value
  16303. */
  16304. static readonly AttributesDirtyFlag: number;
  16305. /**
  16306. * Returns the dirty misc flag value
  16307. */
  16308. static readonly MiscDirtyFlag: number;
  16309. /**
  16310. * The ID of the material
  16311. */
  16312. id: string;
  16313. /**
  16314. * The name of the material
  16315. */
  16316. name: string;
  16317. /**
  16318. * Specifies if the ready state should be checked on each call
  16319. */
  16320. checkReadyOnEveryCall: boolean;
  16321. /**
  16322. * Specifies if the ready state should be checked once
  16323. */
  16324. checkReadyOnlyOnce: boolean;
  16325. /**
  16326. * The state of the material
  16327. */
  16328. state: string;
  16329. /**
  16330. * The alpha value of the material
  16331. */
  16332. protected _alpha: number;
  16333. /**
  16334. * Gets the alpha value of the material
  16335. */
  16336. /**
  16337. * Sets the alpha value of the material
  16338. */
  16339. alpha: number;
  16340. /**
  16341. * Specifies if back face culling is enabled
  16342. */
  16343. protected _backFaceCulling: boolean;
  16344. /**
  16345. * Gets the back-face culling state
  16346. */
  16347. /**
  16348. * Sets the back-face culling state
  16349. */
  16350. backFaceCulling: boolean;
  16351. /**
  16352. * Stores the value for side orientation
  16353. */
  16354. sideOrientation: number;
  16355. /**
  16356. * Callback triggered when the material is compiled
  16357. */
  16358. onCompiled: (effect: Effect) => void;
  16359. /**
  16360. * Callback triggered when an error occurs
  16361. */
  16362. onError: (effect: Effect, errors: string) => void;
  16363. /**
  16364. * Callback triggered to get the render target textures
  16365. */
  16366. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16367. /**
  16368. * Specifies if the material should be serialized
  16369. */
  16370. doNotSerialize: boolean;
  16371. /**
  16372. * Specifies if the effect should be stored on sub meshes
  16373. */
  16374. storeEffectOnSubMeshes: boolean;
  16375. /**
  16376. * Stores the animations for the material
  16377. */
  16378. animations: Array<Animation>;
  16379. /**
  16380. * An event triggered when the material is disposed
  16381. */
  16382. onDisposeObservable: Observable<Material>;
  16383. /**
  16384. * An observer which watches for dispose events
  16385. */
  16386. private _onDisposeObserver;
  16387. /**
  16388. * Called during a dispose event
  16389. */
  16390. onDispose: () => void;
  16391. /**
  16392. * An event triggered when the material is bound
  16393. */
  16394. onBindObservable: Observable<AbstractMesh>;
  16395. /**
  16396. * An observer which watches for bind events
  16397. */
  16398. private _onBindObserver;
  16399. /**
  16400. * Called during a bind event
  16401. */
  16402. onBind: (Mesh: AbstractMesh) => void;
  16403. /**
  16404. * An event triggered when the material is unbound
  16405. */
  16406. onUnBindObservable: Observable<Material>;
  16407. /**
  16408. * Stores the value of the alpha mode
  16409. */
  16410. private _alphaMode;
  16411. /**
  16412. * Gets the value of the alpha mode
  16413. */
  16414. /**
  16415. * Sets the value of the alpha mode.
  16416. *
  16417. * | Value | Type | Description |
  16418. * | --- | --- | --- |
  16419. * | 0 | ALPHA_DISABLE | |
  16420. * | 1 | ALPHA_ADD | |
  16421. * | 2 | ALPHA_COMBINE | |
  16422. * | 3 | ALPHA_SUBTRACT | |
  16423. * | 4 | ALPHA_MULTIPLY | |
  16424. * | 5 | ALPHA_MAXIMIZED | |
  16425. * | 6 | ALPHA_ONEONE | |
  16426. * | 7 | ALPHA_PREMULTIPLIED | |
  16427. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  16428. * | 9 | ALPHA_INTERPOLATE | |
  16429. * | 10 | ALPHA_SCREENMODE | |
  16430. *
  16431. */
  16432. alphaMode: number;
  16433. /**
  16434. * Stores the state of the need depth pre-pass value
  16435. */
  16436. private _needDepthPrePass;
  16437. /**
  16438. * Gets the depth pre-pass value
  16439. */
  16440. /**
  16441. * Sets the need depth pre-pass value
  16442. */
  16443. needDepthPrePass: boolean;
  16444. /**
  16445. * Specifies if depth writing should be disabled
  16446. */
  16447. disableDepthWrite: boolean;
  16448. /**
  16449. * Specifies if depth writing should be forced
  16450. */
  16451. forceDepthWrite: boolean;
  16452. /**
  16453. * Specifies if there should be a separate pass for culling
  16454. */
  16455. separateCullingPass: boolean;
  16456. /**
  16457. * Stores the state specifing if fog should be enabled
  16458. */
  16459. private _fogEnabled;
  16460. /**
  16461. * Gets the value of the fog enabled state
  16462. */
  16463. /**
  16464. * Sets the state for enabling fog
  16465. */
  16466. fogEnabled: boolean;
  16467. /**
  16468. * Stores the size of points
  16469. */
  16470. pointSize: number;
  16471. /**
  16472. * Stores the z offset value
  16473. */
  16474. zOffset: number;
  16475. /**
  16476. * Gets a value specifying if wireframe mode is enabled
  16477. */
  16478. /**
  16479. * Sets the state of wireframe mode
  16480. */
  16481. wireframe: boolean;
  16482. /**
  16483. * Gets the value specifying if point clouds are enabled
  16484. */
  16485. /**
  16486. * Sets the state of point cloud mode
  16487. */
  16488. pointsCloud: boolean;
  16489. /**
  16490. * Gets the material fill mode
  16491. */
  16492. /**
  16493. * Sets the material fill mode
  16494. */
  16495. fillMode: number;
  16496. /**
  16497. * Stores the effects for the material
  16498. */
  16499. /**
  16500. * Specifies if the material was previously ready
  16501. */
  16502. /**
  16503. * Specifies if uniform buffers should be used
  16504. */
  16505. private _useUBO;
  16506. /**
  16507. * Stores a reference to the scene
  16508. */
  16509. private _scene;
  16510. /**
  16511. * Stores the fill mode state
  16512. */
  16513. private _fillMode;
  16514. /**
  16515. * Specifies if the depth write state should be cached
  16516. */
  16517. private _cachedDepthWriteState;
  16518. /**
  16519. * Stores the uniform buffer
  16520. */
  16521. protected _uniformBuffer: UniformBuffer;
  16522. /**
  16523. * Creates a material instance
  16524. * @param name defines the name of the material
  16525. * @param scene defines the scene to reference
  16526. * @param doNotAdd specifies if the material should be added to the scene
  16527. */
  16528. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  16529. /**
  16530. * Returns a string representation of the current material
  16531. * @param fullDetails defines a boolean indicating which levels of logging is desired
  16532. * @returns a string with material information
  16533. */
  16534. toString(fullDetails?: boolean): string;
  16535. /**
  16536. * Gets the class name of the material
  16537. * @returns a string with the class name of the material
  16538. */
  16539. getClassName(): string;
  16540. /**
  16541. * Specifies if updates for the material been locked
  16542. */
  16543. readonly isFrozen: boolean;
  16544. /**
  16545. * Locks updates for the material
  16546. */
  16547. freeze(): void;
  16548. /**
  16549. * Unlocks updates for the material
  16550. */
  16551. unfreeze(): void;
  16552. /**
  16553. * Specifies if the material is ready to be used
  16554. * @param mesh defines the mesh to check
  16555. * @param useInstances specifies if instances should be used
  16556. * @returns a boolean indicating if the material is ready to be used
  16557. */
  16558. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16559. /**
  16560. * Specifies that the submesh is ready to be used
  16561. * @param mesh defines the mesh to check
  16562. * @param subMesh defines which submesh to check
  16563. * @param useInstances specifies that instances should be used
  16564. * @returns a boolean indicating that the submesh is ready or not
  16565. */
  16566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16567. /**
  16568. * Returns the material effect
  16569. * @returns the effect associated with the material
  16570. */
  16571. getEffect(): Nullable<Effect>;
  16572. /**
  16573. * Returns the current scene
  16574. * @returns a Scene
  16575. */
  16576. getScene(): Scene;
  16577. /**
  16578. * Specifies if the material will require alpha blending
  16579. * @returns a boolean specifying if alpha blending is needed
  16580. */
  16581. needAlphaBlending(): boolean;
  16582. /**
  16583. * Specifies if the mesh will require alpha blending
  16584. * @param mesh defines the mesh to check
  16585. * @returns a boolean specifying if alpha blending is needed for the mesh
  16586. */
  16587. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  16588. /**
  16589. * Specifies if this material should be rendered in alpha test mode
  16590. * @returns a boolean specifying if an alpha test is needed.
  16591. */
  16592. needAlphaTesting(): boolean;
  16593. /**
  16594. * Gets the texture used for the alpha test
  16595. * @returns the texture to use for alpha testing
  16596. */
  16597. getAlphaTestTexture(): Nullable<BaseTexture>;
  16598. /**
  16599. * Marks the material to indicate that it needs to be re-calculated
  16600. */
  16601. markDirty(): void;
  16602. /** @hidden */
  16603. /**
  16604. * Binds the material to the mesh
  16605. * @param world defines the world transformation matrix
  16606. * @param mesh defines the mesh to bind the material to
  16607. */
  16608. bind(world: Matrix, mesh?: Mesh): void;
  16609. /**
  16610. * Binds the submesh to the material
  16611. * @param world defines the world transformation matrix
  16612. * @param mesh defines the mesh containing the submesh
  16613. * @param subMesh defines the submesh to bind the material to
  16614. */
  16615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16616. /**
  16617. * Binds the world matrix to the material
  16618. * @param world defines the world transformation matrix
  16619. */
  16620. bindOnlyWorldMatrix(world: Matrix): void;
  16621. /**
  16622. * Binds the scene's uniform buffer to the effect.
  16623. * @param effect defines the effect to bind to the scene uniform buffer
  16624. * @param sceneUbo defines the uniform buffer storing scene data
  16625. */
  16626. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  16627. /**
  16628. * Binds the view matrix to the effect
  16629. * @param effect defines the effect to bind the view matrix to
  16630. */
  16631. bindView(effect: Effect): void;
  16632. /**
  16633. * Binds the view projection matrix to the effect
  16634. * @param effect defines the effect to bind the view projection matrix to
  16635. */
  16636. bindViewProjection(effect: Effect): void;
  16637. /**
  16638. * Specifies if material alpha testing should be turned on for the mesh
  16639. * @param mesh defines the mesh to check
  16640. */
  16641. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  16642. /**
  16643. * Processes to execute after binding the material to a mesh
  16644. * @param mesh defines the rendered mesh
  16645. */
  16646. protected _afterBind(mesh?: Mesh): void;
  16647. /**
  16648. * Unbinds the material from the mesh
  16649. */
  16650. unbind(): void;
  16651. /**
  16652. * Gets the active textures from the material
  16653. * @returns an array of textures
  16654. */
  16655. getActiveTextures(): BaseTexture[];
  16656. /**
  16657. * Specifies if the material uses a texture
  16658. * @param texture defines the texture to check against the material
  16659. * @returns a boolean specifying if the material uses the texture
  16660. */
  16661. hasTexture(texture: BaseTexture): boolean;
  16662. /**
  16663. * Makes a duplicate of the material, and gives it a new name
  16664. * @param name defines the new name for the duplicated material
  16665. * @returns the cloned material
  16666. */
  16667. clone(name: string): Nullable<Material>;
  16668. /**
  16669. * Gets the meshes bound to the material
  16670. * @returns an array of meshes bound to the material
  16671. */
  16672. getBindedMeshes(): AbstractMesh[];
  16673. /**
  16674. * Force shader compilation
  16675. * @param mesh defines the mesh associated with this material
  16676. * @param onCompiled defines a function to execute once the material is compiled
  16677. * @param options defines the options to configure the compilation
  16678. */
  16679. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  16680. clipPlane: boolean;
  16681. }>): void;
  16682. /**
  16683. * Force shader compilation
  16684. * @param mesh defines the mesh that will use this material
  16685. * @param options defines additional options for compiling the shaders
  16686. * @returns a promise that resolves when the compilation completes
  16687. */
  16688. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  16689. clipPlane: boolean;
  16690. }>): Promise<void>;
  16691. /**
  16692. * Marks a define in the material to indicate that it needs to be re-computed
  16693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  16694. */
  16695. markAsDirty(flag: number): void;
  16696. /**
  16697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  16698. * @param func defines a function which checks material defines against the submeshes
  16699. */
  16700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  16701. /**
  16702. * Indicates that image processing needs to be re-calculated for all submeshes
  16703. */
  16704. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  16705. /**
  16706. * Indicates that textures need to be re-calculated for all submeshes
  16707. */
  16708. protected _markAllSubMeshesAsTexturesDirty(): void;
  16709. /**
  16710. * Indicates that fresnel needs to be re-calculated for all submeshes
  16711. */
  16712. protected _markAllSubMeshesAsFresnelDirty(): void;
  16713. /**
  16714. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  16715. */
  16716. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  16717. /**
  16718. * Indicates that lights need to be re-calculated for all submeshes
  16719. */
  16720. protected _markAllSubMeshesAsLightsDirty(): void;
  16721. /**
  16722. * Indicates that attributes need to be re-calculated for all submeshes
  16723. */
  16724. protected _markAllSubMeshesAsAttributesDirty(): void;
  16725. /**
  16726. * Indicates that misc needs to be re-calculated for all submeshes
  16727. */
  16728. protected _markAllSubMeshesAsMiscDirty(): void;
  16729. /**
  16730. * Indicates that textures and misc need to be re-calculated for all submeshes
  16731. */
  16732. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  16733. /**
  16734. * Disposes the material
  16735. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16736. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16737. */
  16738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  16739. /**
  16740. * Serializes this material
  16741. * @returns the serialized material object
  16742. */
  16743. serialize(): any;
  16744. /**
  16745. * Creates a MultiMaterial from parsed MultiMaterial data.
  16746. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  16747. * @param scene defines the hosting scene
  16748. * @returns a new MultiMaterial
  16749. */
  16750. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  16751. /**
  16752. * Creates a material from parsed material data
  16753. * @param parsedMaterial defines parsed material data
  16754. * @param scene defines the hosting scene
  16755. * @param rootUrl defines the root URL to use to load textures
  16756. * @returns a new material
  16757. */
  16758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  16759. }
  16760. }
  16761. declare module BABYLON {
  16762. /**
  16763. * "Static Class" containing the most commonly used helper while dealing with material for
  16764. * rendering purpose.
  16765. *
  16766. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  16767. *
  16768. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  16769. */
  16770. class MaterialHelper {
  16771. /**
  16772. * Bind the current view position to an effect.
  16773. * @param effect The effect to be bound
  16774. * @param scene The scene the eyes position is used from
  16775. */
  16776. static BindEyePosition(effect: Effect, scene: Scene): void;
  16777. /**
  16778. * Helps preparing the defines values about the UVs in used in the effect.
  16779. * UVs are shared as much as we can accross chanels in the shaders.
  16780. * @param texture The texture we are preparing the UVs for
  16781. * @param defines The defines to update
  16782. * @param key The chanel key "diffuse", "specular"... used in the shader
  16783. */
  16784. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  16785. /**
  16786. * Binds a texture matrix value to its corrsponding uniform
  16787. * @param texture The texture to bind the matrix for
  16788. * @param uniformBuffer The uniform buffer receivin the data
  16789. * @param key The chanel key "diffuse", "specular"... used in the shader
  16790. */
  16791. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  16792. /**
  16793. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  16794. * @param mesh defines the current mesh
  16795. * @param scene defines the current scene
  16796. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  16797. * @param pointsCloud defines if point cloud rendering has to be turned on
  16798. * @param fogEnabled defines if fog has to be turned on
  16799. * @param alphaTest defines if alpha testing has to be turned on
  16800. * @param defines defines the current list of defines
  16801. */
  16802. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  16803. /**
  16804. * Helper used to prepare the list of defines associated with frame values for shader compilation
  16805. * @param scene defines the current scene
  16806. * @param engine defines the current engine
  16807. * @param defines specifies the list of active defines
  16808. * @param useInstances defines if instances have to be turned on
  16809. * @param useClipPlane defines if clip plane have to be turned on
  16810. */
  16811. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  16812. /**
  16813. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  16814. * @param mesh The mesh containing the geometry data we will draw
  16815. * @param defines The defines to update
  16816. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  16817. * @param useBones Precise whether bones should be used or not (override mesh info)
  16818. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  16819. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  16820. * @returns false if defines are considered not dirty and have not been checked
  16821. */
  16822. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  16823. /**
  16824. * Prepares the defines related to the light information passed in parameter
  16825. * @param scene The scene we are intending to draw
  16826. * @param mesh The mesh the effect is compiling for
  16827. * @param defines The defines to update
  16828. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  16829. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  16830. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  16831. * @returns true if normals will be required for the rest of the effect
  16832. */
  16833. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  16834. /**
  16835. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  16836. * that won t be acctive due to defines being turned off.
  16837. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  16838. * @param samplersList The samplers list
  16839. * @param defines The defines helping in the list generation
  16840. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  16841. */
  16842. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  16843. /**
  16844. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  16845. * @param defines The defines to update while falling back
  16846. * @param fallbacks The authorized effect fallbacks
  16847. * @param maxSimultaneousLights The maximum number of lights allowed
  16848. * @param rank the current rank of the Effect
  16849. * @returns The newly affected rank
  16850. */
  16851. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  16852. /**
  16853. * Prepares the list of attributes required for morph targets according to the effect defines.
  16854. * @param attribs The current list of supported attribs
  16855. * @param mesh The mesh to prepare the morph targets attributes for
  16856. * @param defines The current Defines of the effect
  16857. */
  16858. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  16859. /**
  16860. * Prepares the list of attributes required for bones according to the effect defines.
  16861. * @param attribs The current list of supported attribs
  16862. * @param mesh The mesh to prepare the bones attributes for
  16863. * @param defines The current Defines of the effect
  16864. * @param fallbacks The current efffect fallback strategy
  16865. */
  16866. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  16867. /**
  16868. * Prepares the list of attributes required for instances according to the effect defines.
  16869. * @param attribs The current list of supported attribs
  16870. * @param defines The current Defines of the effect
  16871. */
  16872. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  16873. /**
  16874. * Binds the light shadow information to the effect for the given mesh.
  16875. * @param light The light containing the generator
  16876. * @param scene The scene the lights belongs to
  16877. * @param mesh The mesh we are binding the information to render
  16878. * @param lightIndex The light index in the effect used to render the mesh
  16879. * @param effect The effect we are binding the data to
  16880. */
  16881. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  16882. /**
  16883. * Binds the light information to the effect.
  16884. * @param light The light containing the generator
  16885. * @param effect The effect we are binding the data to
  16886. * @param lightIndex The light index in the effect used to render
  16887. */
  16888. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  16889. /**
  16890. * Binds the lights information from the scene to the effect for the given mesh.
  16891. * @param scene The scene the lights belongs to
  16892. * @param mesh The mesh we are binding the information to render
  16893. * @param effect The effect we are binding the data to
  16894. * @param defines The generated defines for the effect
  16895. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  16896. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  16897. */
  16898. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  16899. /**
  16900. * Binds the fog information from the scene to the effect for the given mesh.
  16901. * @param scene The scene the lights belongs to
  16902. * @param mesh The mesh we are binding the information to render
  16903. * @param effect The effect we are binding the data to
  16904. */
  16905. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  16906. /**
  16907. * Binds the bones information from the mesh to the effect.
  16908. * @param mesh The mesh we are binding the information to render
  16909. * @param effect The effect we are binding the data to
  16910. */
  16911. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  16912. /**
  16913. * Binds the morph targets information from the mesh to the effect.
  16914. * @param abstractMesh The mesh we are binding the information to render
  16915. * @param effect The effect we are binding the data to
  16916. */
  16917. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  16918. /**
  16919. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  16920. * @param defines The generated defines used in the effect
  16921. * @param effect The effect we are binding the data to
  16922. * @param scene The scene we are willing to render with logarithmic scale for
  16923. */
  16924. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  16925. /**
  16926. * Binds the clip plane information from the scene to the effect.
  16927. * @param scene The scene the clip plane information are extracted from
  16928. * @param effect The effect we are binding the data to
  16929. */
  16930. static BindClipPlane(effect: Effect, scene: Scene): void;
  16931. }
  16932. }
  16933. declare module BABYLON {
  16934. class MultiMaterial extends Material {
  16935. private _subMaterials;
  16936. subMaterials: Nullable<Material>[];
  16937. constructor(name: string, scene: Scene);
  16938. private _hookArray(array);
  16939. getSubMaterial(index: number): Nullable<Material>;
  16940. getActiveTextures(): BaseTexture[];
  16941. getClassName(): string;
  16942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16943. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  16944. serialize(): any;
  16945. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  16946. }
  16947. }
  16948. declare module BABYLON {
  16949. class PushMaterial extends Material {
  16950. protected _activeEffect: Effect;
  16951. protected _normalMatrix: Matrix;
  16952. constructor(name: string, scene: Scene);
  16953. getEffect(): Effect;
  16954. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16955. /**
  16956. * Binds the given world matrix to the active effect
  16957. *
  16958. * @param world the matrix to bind
  16959. */
  16960. bindOnlyWorldMatrix(world: Matrix): void;
  16961. /**
  16962. * Binds the given normal matrix to the active effect
  16963. *
  16964. * @param normalMatrix the matrix to bind
  16965. */
  16966. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  16967. bind(world: Matrix, mesh?: Mesh): void;
  16968. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  16969. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  16970. }
  16971. }
  16972. declare module BABYLON {
  16973. class ShaderMaterial extends Material {
  16974. private _shaderPath;
  16975. private _options;
  16976. private _textures;
  16977. private _textureArrays;
  16978. private _floats;
  16979. private _ints;
  16980. private _floatsArrays;
  16981. private _colors3;
  16982. private _colors3Arrays;
  16983. private _colors4;
  16984. private _vectors2;
  16985. private _vectors3;
  16986. private _vectors4;
  16987. private _matrices;
  16988. private _matrices3x3;
  16989. private _matrices2x2;
  16990. private _vectors2Arrays;
  16991. private _vectors3Arrays;
  16992. private _cachedWorldViewMatrix;
  16993. private _renderId;
  16994. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  16995. getClassName(): string;
  16996. needAlphaBlending(): boolean;
  16997. needAlphaTesting(): boolean;
  16998. private _checkUniform(uniformName);
  16999. setTexture(name: string, texture: Texture): ShaderMaterial;
  17000. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17001. setFloat(name: string, value: number): ShaderMaterial;
  17002. setInt(name: string, value: number): ShaderMaterial;
  17003. setFloats(name: string, value: number[]): ShaderMaterial;
  17004. setColor3(name: string, value: Color3): ShaderMaterial;
  17005. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17006. setColor4(name: string, value: Color4): ShaderMaterial;
  17007. setVector2(name: string, value: Vector2): ShaderMaterial;
  17008. setVector3(name: string, value: Vector3): ShaderMaterial;
  17009. setVector4(name: string, value: Vector4): ShaderMaterial;
  17010. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17011. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17012. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17013. setArray2(name: string, value: number[]): ShaderMaterial;
  17014. setArray3(name: string, value: number[]): ShaderMaterial;
  17015. private _checkCache(scene, mesh?, useInstances?);
  17016. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17017. bindOnlyWorldMatrix(world: Matrix): void;
  17018. bind(world: Matrix, mesh?: Mesh): void;
  17019. getActiveTextures(): BaseTexture[];
  17020. hasTexture(texture: BaseTexture): boolean;
  17021. clone(name: string): ShaderMaterial;
  17022. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17023. serialize(): any;
  17024. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17025. }
  17026. }
  17027. declare module BABYLON {
  17028. /** @hidden */
  17029. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17030. MAINUV1: boolean;
  17031. MAINUV2: boolean;
  17032. DIFFUSE: boolean;
  17033. DIFFUSEDIRECTUV: number;
  17034. AMBIENT: boolean;
  17035. AMBIENTDIRECTUV: number;
  17036. OPACITY: boolean;
  17037. OPACITYDIRECTUV: number;
  17038. OPACITYRGB: boolean;
  17039. REFLECTION: boolean;
  17040. EMISSIVE: boolean;
  17041. EMISSIVEDIRECTUV: number;
  17042. SPECULAR: boolean;
  17043. SPECULARDIRECTUV: number;
  17044. BUMP: boolean;
  17045. BUMPDIRECTUV: number;
  17046. PARALLAX: boolean;
  17047. PARALLAXOCCLUSION: boolean;
  17048. SPECULAROVERALPHA: boolean;
  17049. CLIPPLANE: boolean;
  17050. ALPHATEST: boolean;
  17051. DEPTHPREPASS: boolean;
  17052. ALPHAFROMDIFFUSE: boolean;
  17053. POINTSIZE: boolean;
  17054. FOG: boolean;
  17055. SPECULARTERM: boolean;
  17056. DIFFUSEFRESNEL: boolean;
  17057. OPACITYFRESNEL: boolean;
  17058. REFLECTIONFRESNEL: boolean;
  17059. REFRACTIONFRESNEL: boolean;
  17060. EMISSIVEFRESNEL: boolean;
  17061. FRESNEL: boolean;
  17062. NORMAL: boolean;
  17063. UV1: boolean;
  17064. UV2: boolean;
  17065. VERTEXCOLOR: boolean;
  17066. VERTEXALPHA: boolean;
  17067. NUM_BONE_INFLUENCERS: number;
  17068. BonesPerMesh: number;
  17069. INSTANCES: boolean;
  17070. GLOSSINESS: boolean;
  17071. ROUGHNESS: boolean;
  17072. EMISSIVEASILLUMINATION: boolean;
  17073. LINKEMISSIVEWITHDIFFUSE: boolean;
  17074. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17075. LIGHTMAP: boolean;
  17076. LIGHTMAPDIRECTUV: number;
  17077. OBJECTSPACE_NORMALMAP: boolean;
  17078. USELIGHTMAPASSHADOWMAP: boolean;
  17079. REFLECTIONMAP_3D: boolean;
  17080. REFLECTIONMAP_SPHERICAL: boolean;
  17081. REFLECTIONMAP_PLANAR: boolean;
  17082. REFLECTIONMAP_CUBIC: boolean;
  17083. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17084. REFLECTIONMAP_PROJECTION: boolean;
  17085. REFLECTIONMAP_SKYBOX: boolean;
  17086. REFLECTIONMAP_EXPLICIT: boolean;
  17087. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17088. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17089. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17090. INVERTCUBICMAP: boolean;
  17091. LOGARITHMICDEPTH: boolean;
  17092. REFRACTION: boolean;
  17093. REFRACTIONMAP_3D: boolean;
  17094. REFLECTIONOVERALPHA: boolean;
  17095. TWOSIDEDLIGHTING: boolean;
  17096. SHADOWFLOAT: boolean;
  17097. MORPHTARGETS: boolean;
  17098. MORPHTARGETS_NORMAL: boolean;
  17099. MORPHTARGETS_TANGENT: boolean;
  17100. NUM_MORPH_INFLUENCERS: number;
  17101. NONUNIFORMSCALING: boolean;
  17102. PREMULTIPLYALPHA: boolean;
  17103. IMAGEPROCESSING: boolean;
  17104. VIGNETTE: boolean;
  17105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17106. VIGNETTEBLENDMODEOPAQUE: boolean;
  17107. TONEMAPPING: boolean;
  17108. CONTRAST: boolean;
  17109. COLORCURVES: boolean;
  17110. COLORGRADING: boolean;
  17111. COLORGRADING3D: boolean;
  17112. SAMPLER3DGREENDEPTH: boolean;
  17113. SAMPLER3DBGRMAP: boolean;
  17114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17115. /**
  17116. * If the reflection texture on this material is in linear color space
  17117. * @hidden
  17118. */
  17119. IS_REFLECTION_LINEAR: boolean;
  17120. /**
  17121. * If the refraction texture on this material is in linear color space
  17122. * @hidden
  17123. */
  17124. IS_REFRACTION_LINEAR: boolean;
  17125. EXPOSURE: boolean;
  17126. constructor();
  17127. setReflectionMode(modeToEnable: string): void;
  17128. }
  17129. class StandardMaterial extends PushMaterial {
  17130. private _diffuseTexture;
  17131. diffuseTexture: Nullable<BaseTexture>;
  17132. private _ambientTexture;
  17133. ambientTexture: Nullable<BaseTexture>;
  17134. private _opacityTexture;
  17135. opacityTexture: Nullable<BaseTexture>;
  17136. private _reflectionTexture;
  17137. reflectionTexture: Nullable<BaseTexture>;
  17138. private _emissiveTexture;
  17139. emissiveTexture: Nullable<BaseTexture>;
  17140. private _specularTexture;
  17141. specularTexture: Nullable<BaseTexture>;
  17142. private _bumpTexture;
  17143. bumpTexture: Nullable<BaseTexture>;
  17144. private _lightmapTexture;
  17145. lightmapTexture: Nullable<BaseTexture>;
  17146. private _refractionTexture;
  17147. refractionTexture: Nullable<BaseTexture>;
  17148. ambientColor: Color3;
  17149. diffuseColor: Color3;
  17150. specularColor: Color3;
  17151. emissiveColor: Color3;
  17152. specularPower: number;
  17153. private _useAlphaFromDiffuseTexture;
  17154. useAlphaFromDiffuseTexture: boolean;
  17155. private _useEmissiveAsIllumination;
  17156. useEmissiveAsIllumination: boolean;
  17157. private _linkEmissiveWithDiffuse;
  17158. linkEmissiveWithDiffuse: boolean;
  17159. private _useSpecularOverAlpha;
  17160. useSpecularOverAlpha: boolean;
  17161. private _useReflectionOverAlpha;
  17162. useReflectionOverAlpha: boolean;
  17163. private _disableLighting;
  17164. disableLighting: boolean;
  17165. private _useObjectSpaceNormalMap;
  17166. /**
  17167. * Allows using an object space normal map (instead of tangent space).
  17168. */
  17169. useObjectSpaceNormalMap: boolean;
  17170. private _useParallax;
  17171. useParallax: boolean;
  17172. private _useParallaxOcclusion;
  17173. useParallaxOcclusion: boolean;
  17174. parallaxScaleBias: number;
  17175. private _roughness;
  17176. roughness: number;
  17177. indexOfRefraction: number;
  17178. invertRefractionY: boolean;
  17179. /**
  17180. * Defines the alpha limits in alpha test mode
  17181. */
  17182. alphaCutOff: number;
  17183. private _useLightmapAsShadowmap;
  17184. useLightmapAsShadowmap: boolean;
  17185. private _diffuseFresnelParameters;
  17186. diffuseFresnelParameters: FresnelParameters;
  17187. private _opacityFresnelParameters;
  17188. opacityFresnelParameters: FresnelParameters;
  17189. private _reflectionFresnelParameters;
  17190. reflectionFresnelParameters: FresnelParameters;
  17191. private _refractionFresnelParameters;
  17192. refractionFresnelParameters: FresnelParameters;
  17193. private _emissiveFresnelParameters;
  17194. emissiveFresnelParameters: FresnelParameters;
  17195. private _useReflectionFresnelFromSpecular;
  17196. useReflectionFresnelFromSpecular: boolean;
  17197. private _useGlossinessFromSpecularMapAlpha;
  17198. useGlossinessFromSpecularMapAlpha: boolean;
  17199. private _maxSimultaneousLights;
  17200. maxSimultaneousLights: number;
  17201. /**
  17202. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17203. */
  17204. private _invertNormalMapX;
  17205. invertNormalMapX: boolean;
  17206. /**
  17207. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17208. */
  17209. private _invertNormalMapY;
  17210. invertNormalMapY: boolean;
  17211. /**
  17212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17213. */
  17214. private _twoSidedLighting;
  17215. twoSidedLighting: boolean;
  17216. /**
  17217. * Default configuration related to image processing available in the standard Material.
  17218. */
  17219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17220. /**
  17221. * Gets the image processing configuration used either in this material.
  17222. */
  17223. /**
  17224. * Sets the Default image processing configuration used either in the this material.
  17225. *
  17226. * If sets to null, the scene one is in use.
  17227. */
  17228. imageProcessingConfiguration: ImageProcessingConfiguration;
  17229. /**
  17230. * Keep track of the image processing observer to allow dispose and replace.
  17231. */
  17232. private _imageProcessingObserver;
  17233. /**
  17234. * Attaches a new image processing configuration to the Standard Material.
  17235. * @param configuration
  17236. */
  17237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17238. /**
  17239. * Gets wether the color curves effect is enabled.
  17240. */
  17241. /**
  17242. * Sets wether the color curves effect is enabled.
  17243. */
  17244. cameraColorCurvesEnabled: boolean;
  17245. /**
  17246. * Gets wether the color grading effect is enabled.
  17247. */
  17248. /**
  17249. * Gets wether the color grading effect is enabled.
  17250. */
  17251. cameraColorGradingEnabled: boolean;
  17252. /**
  17253. * Gets wether tonemapping is enabled or not.
  17254. */
  17255. /**
  17256. * Sets wether tonemapping is enabled or not
  17257. */
  17258. cameraToneMappingEnabled: boolean;
  17259. /**
  17260. * The camera exposure used on this material.
  17261. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17262. * This corresponds to a photographic exposure.
  17263. */
  17264. /**
  17265. * The camera exposure used on this material.
  17266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17267. * This corresponds to a photographic exposure.
  17268. */
  17269. cameraExposure: number;
  17270. /**
  17271. * Gets The camera contrast used on this material.
  17272. */
  17273. /**
  17274. * Sets The camera contrast used on this material.
  17275. */
  17276. cameraContrast: number;
  17277. /**
  17278. * Gets the Color Grading 2D Lookup Texture.
  17279. */
  17280. /**
  17281. * Sets the Color Grading 2D Lookup Texture.
  17282. */
  17283. cameraColorGradingTexture: Nullable<BaseTexture>;
  17284. /**
  17285. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17286. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17287. * 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;
  17288. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17289. */
  17290. /**
  17291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17293. * 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;
  17294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17295. */
  17296. cameraColorCurves: Nullable<ColorCurves>;
  17297. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17298. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17299. protected _worldViewProjectionMatrix: Matrix;
  17300. protected _globalAmbientColor: Color3;
  17301. protected _useLogarithmicDepth: boolean;
  17302. constructor(name: string, scene: Scene);
  17303. getClassName(): string;
  17304. useLogarithmicDepth: boolean;
  17305. needAlphaBlending(): boolean;
  17306. needAlphaTesting(): boolean;
  17307. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17308. getAlphaTestTexture(): Nullable<BaseTexture>;
  17309. /**
  17310. * Child classes can use it to update shaders
  17311. */
  17312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17313. buildUniformLayout(): void;
  17314. unbind(): void;
  17315. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17316. getAnimatables(): IAnimatable[];
  17317. getActiveTextures(): BaseTexture[];
  17318. hasTexture(texture: BaseTexture): boolean;
  17319. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17320. clone(name: string): StandardMaterial;
  17321. serialize(): any;
  17322. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17323. private static _DiffuseTextureEnabled: boolean;
  17324. static DiffuseTextureEnabled: boolean;
  17325. private static _AmbientTextureEnabled: boolean;
  17326. static AmbientTextureEnabled: boolean;
  17327. private static _OpacityTextureEnabled: boolean;
  17328. static OpacityTextureEnabled: boolean;
  17329. private static _ReflectionTextureEnabled: boolean;
  17330. static ReflectionTextureEnabled: boolean;
  17331. private static _EmissiveTextureEnabled: boolean;
  17332. static EmissiveTextureEnabled: boolean;
  17333. private static _SpecularTextureEnabled: boolean;
  17334. static SpecularTextureEnabled: boolean;
  17335. private static _BumpTextureEnabled: boolean;
  17336. static BumpTextureEnabled: boolean;
  17337. private static _LightmapTextureEnabled: boolean;
  17338. static LightmapTextureEnabled: boolean;
  17339. private static _RefractionTextureEnabled: boolean;
  17340. static RefractionTextureEnabled: boolean;
  17341. private static _ColorGradingTextureEnabled: boolean;
  17342. static ColorGradingTextureEnabled: boolean;
  17343. private static _FresnelEnabled: boolean;
  17344. static FresnelEnabled: boolean;
  17345. }
  17346. }
  17347. declare module BABYLON {
  17348. class UniformBuffer {
  17349. private _engine;
  17350. private _buffer;
  17351. private _data;
  17352. private _bufferData;
  17353. private _dynamic?;
  17354. private _uniformLocations;
  17355. private _uniformSizes;
  17356. private _uniformLocationPointer;
  17357. private _needSync;
  17358. private _noUBO;
  17359. private _currentEffect;
  17360. private static _MAX_UNIFORM_SIZE;
  17361. private static _tempBuffer;
  17362. /**
  17363. * Wrapper for updateUniform.
  17364. * @method updateMatrix3x3
  17365. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17366. * @param {Float32Array} matrix
  17367. */
  17368. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17369. /**
  17370. * Wrapper for updateUniform.
  17371. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17372. * @param {Float32Array} matrix
  17373. */
  17374. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17375. /**
  17376. * Wrapper for updateUniform.
  17377. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17378. * @param {number} x
  17379. */
  17380. updateFloat: (name: string, x: number) => void;
  17381. /**
  17382. * Wrapper for updateUniform.
  17383. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17384. * @param {number} x
  17385. * @param {number} y
  17386. * @param {string} [suffix] Suffix to add to the uniform name.
  17387. */
  17388. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17389. /**
  17390. * Wrapper for updateUniform.
  17391. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17392. * @param {number} x
  17393. * @param {number} y
  17394. * @param {number} z
  17395. * @param {string} [suffix] Suffix to add to the uniform name.
  17396. */
  17397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17398. /**
  17399. * Wrapper for updateUniform.
  17400. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17401. * @param {number} x
  17402. * @param {number} y
  17403. * @param {number} z
  17404. * @param {number} w
  17405. * @param {string} [suffix] Suffix to add to the uniform name.
  17406. */
  17407. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  17408. /**
  17409. * Wrapper for updateUniform.
  17410. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17411. * @param {Matrix} A 4x4 matrix.
  17412. */
  17413. updateMatrix: (name: string, mat: Matrix) => void;
  17414. /**
  17415. * Wrapper for updateUniform.
  17416. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17417. * @param {Vector3} vector
  17418. */
  17419. updateVector3: (name: string, vector: Vector3) => void;
  17420. /**
  17421. * Wrapper for updateUniform.
  17422. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17423. * @param {Vector4} vector
  17424. */
  17425. updateVector4: (name: string, vector: Vector4) => void;
  17426. /**
  17427. * Wrapper for updateUniform.
  17428. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17429. * @param {Color3} color
  17430. * @param {string} [suffix] Suffix to add to the uniform name.
  17431. */
  17432. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  17433. /**
  17434. * Wrapper for updateUniform.
  17435. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17436. * @param {Color3} color
  17437. * @param {number} alpha
  17438. * @param {string} [suffix] Suffix to add to the uniform name.
  17439. */
  17440. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  17441. /**
  17442. * Uniform buffer objects.
  17443. *
  17444. * Handles blocks of uniform on the GPU.
  17445. *
  17446. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  17447. *
  17448. * For more information, please refer to :
  17449. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  17450. */
  17451. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  17452. /**
  17453. * Indicates if the buffer is using the WebGL2 UBO implementation,
  17454. * or just falling back on setUniformXXX calls.
  17455. */
  17456. readonly useUbo: boolean;
  17457. /**
  17458. * Indicates if the WebGL underlying uniform buffer is in sync
  17459. * with the javascript cache data.
  17460. */
  17461. readonly isSync: boolean;
  17462. /**
  17463. * Indicates if the WebGL underlying uniform buffer is dynamic.
  17464. * Also, a dynamic UniformBuffer will disable cache verification and always
  17465. * update the underlying WebGL uniform buffer to the GPU.
  17466. */
  17467. isDynamic(): boolean;
  17468. /**
  17469. * The data cache on JS side.
  17470. */
  17471. getData(): Float32Array;
  17472. /**
  17473. * The underlying WebGL Uniform buffer.
  17474. */
  17475. getBuffer(): Nullable<WebGLBuffer>;
  17476. /**
  17477. * std140 layout specifies how to align data within an UBO structure.
  17478. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  17479. * for specs.
  17480. */
  17481. private _fillAlignment(size);
  17482. /**
  17483. * Adds an uniform in the buffer.
  17484. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  17485. * for the layout to be correct !
  17486. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17487. * @param {number|number[]} size Data size, or data directly.
  17488. */
  17489. addUniform(name: string, size: number | number[]): void;
  17490. /**
  17491. * Wrapper for addUniform.
  17492. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17493. * @param {Matrix} mat A 4x4 matrix.
  17494. */
  17495. addMatrix(name: string, mat: Matrix): void;
  17496. /**
  17497. * Wrapper for addUniform.
  17498. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17499. * @param {number} x
  17500. * @param {number} y
  17501. */
  17502. addFloat2(name: string, x: number, y: number): void;
  17503. /**
  17504. * Wrapper for addUniform.
  17505. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17506. * @param {number} x
  17507. * @param {number} y
  17508. * @param {number} z
  17509. */
  17510. addFloat3(name: string, x: number, y: number, z: number): void;
  17511. /**
  17512. * Wrapper for addUniform.
  17513. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17514. * @param {Color3} color
  17515. */
  17516. addColor3(name: string, color: Color3): void;
  17517. /**
  17518. * Wrapper for addUniform.
  17519. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17520. * @param {Color3} color
  17521. * @param {number} alpha
  17522. */
  17523. addColor4(name: string, color: Color3, alpha: number): void;
  17524. /**
  17525. * Wrapper for addUniform.
  17526. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17527. * @param {Vector3} vector
  17528. */
  17529. addVector3(name: string, vector: Vector3): void;
  17530. /**
  17531. * Wrapper for addUniform.
  17532. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17533. */
  17534. addMatrix3x3(name: string): void;
  17535. /**
  17536. * Wrapper for addUniform.
  17537. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17538. */
  17539. addMatrix2x2(name: string): void;
  17540. /**
  17541. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  17542. */
  17543. create(): void;
  17544. /**
  17545. * Updates the WebGL Uniform Buffer on the GPU.
  17546. * If the `dynamic` flag is set to true, no cache comparison is done.
  17547. * Otherwise, the buffer will be updated only if the cache differs.
  17548. */
  17549. update(): void;
  17550. /**
  17551. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  17552. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17553. * @param {number[]|Float32Array} data Flattened data
  17554. * @param {number} size Size of the data.
  17555. */
  17556. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  17557. private _updateMatrix3x3ForUniform(name, matrix);
  17558. private _updateMatrix3x3ForEffect(name, matrix);
  17559. private _updateMatrix2x2ForEffect(name, matrix);
  17560. private _updateMatrix2x2ForUniform(name, matrix);
  17561. private _updateFloatForEffect(name, x);
  17562. private _updateFloatForUniform(name, x);
  17563. private _updateFloat2ForEffect(name, x, y, suffix?);
  17564. private _updateFloat2ForUniform(name, x, y, suffix?);
  17565. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  17566. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  17567. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  17568. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  17569. private _updateMatrixForEffect(name, mat);
  17570. private _updateMatrixForUniform(name, mat);
  17571. private _updateVector3ForEffect(name, vector);
  17572. private _updateVector3ForUniform(name, vector);
  17573. private _updateVector4ForEffect(name, vector);
  17574. private _updateVector4ForUniform(name, vector);
  17575. private _updateColor3ForEffect(name, color, suffix?);
  17576. private _updateColor3ForUniform(name, color, suffix?);
  17577. private _updateColor4ForEffect(name, color, alpha, suffix?);
  17578. private _updateColor4ForUniform(name, color, alpha, suffix?);
  17579. /**
  17580. * Sets a sampler uniform on the effect.
  17581. * @param {string} name Name of the sampler.
  17582. * @param {Texture} texture
  17583. */
  17584. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  17585. /**
  17586. * Directly updates the value of the uniform in the cache AND on the GPU.
  17587. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17588. * @param {number[]|Float32Array} data Flattened data
  17589. */
  17590. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  17591. /**
  17592. * Binds this uniform buffer to an effect.
  17593. * @param {Effect} effect
  17594. * @param {string} name Name of the uniform block in the shader.
  17595. */
  17596. bindToEffect(effect: Effect, name: string): void;
  17597. /**
  17598. * Disposes the uniform buffer.
  17599. */
  17600. dispose(): void;
  17601. }
  17602. }
  17603. declare module BABYLON {
  17604. /**
  17605. * This represents a GPU particle system in Babylon
  17606. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17607. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17608. */
  17609. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17610. /**
  17611. * The id of the Particle system.
  17612. */
  17613. id: string;
  17614. /**
  17615. * The friendly name of the Particle system.
  17616. */
  17617. name: string;
  17618. /**
  17619. * The emitter represents the Mesh or position we are attaching the particle system to.
  17620. */
  17621. emitter: Nullable<AbstractMesh | Vector3>;
  17622. /**
  17623. * The rendering group used by the Particle system to chose when to render.
  17624. */
  17625. renderingGroupId: number;
  17626. /**
  17627. * The layer mask we are rendering the particles through.
  17628. */
  17629. layerMask: number;
  17630. private _capacity;
  17631. private _activeCount;
  17632. private _currentActiveCount;
  17633. private _renderEffect;
  17634. private _updateEffect;
  17635. private _buffer0;
  17636. private _buffer1;
  17637. private _spriteBuffer;
  17638. private _updateVAO;
  17639. private _renderVAO;
  17640. private _targetIndex;
  17641. private _sourceBuffer;
  17642. private _targetBuffer;
  17643. private _scene;
  17644. private _engine;
  17645. private _currentRenderId;
  17646. private _started;
  17647. private _stopped;
  17648. private _timeDelta;
  17649. private _randomTexture;
  17650. private readonly _attributesStrideSize;
  17651. private _updateEffectOptions;
  17652. private _randomTextureSize;
  17653. private _actualFrame;
  17654. /**
  17655. * List of animations used by the particle system.
  17656. */
  17657. animations: Animation[];
  17658. /**
  17659. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17660. */
  17661. static readonly IsSupported: boolean;
  17662. /**
  17663. * An event triggered when the system is disposed.
  17664. */
  17665. onDisposeObservable: Observable<GPUParticleSystem>;
  17666. /**
  17667. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17668. */
  17669. updateSpeed: number;
  17670. /**
  17671. * The amount of time the particle system is running (depends of the overall update speed).
  17672. */
  17673. targetStopDuration: number;
  17674. /**
  17675. * The texture used to render each particle. (this can be a spritesheet)
  17676. */
  17677. particleTexture: Nullable<Texture>;
  17678. /**
  17679. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17680. */
  17681. blendMode: number;
  17682. /**
  17683. * Minimum life time of emitting particles.
  17684. */
  17685. minLifeTime: number;
  17686. /**
  17687. * Maximum life time of emitting particles.
  17688. */
  17689. maxLifeTime: number;
  17690. /**
  17691. * Minimum Size of emitting particles.
  17692. */
  17693. minSize: number;
  17694. /**
  17695. * Maximum Size of emitting particles.
  17696. */
  17697. maxSize: number;
  17698. /**
  17699. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17700. */
  17701. color1: Color4;
  17702. /**
  17703. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17704. */
  17705. color2: Color4;
  17706. /**
  17707. * Color the particle will have at the end of its lifetime.
  17708. */
  17709. colorDead: Color4;
  17710. /**
  17711. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17712. */
  17713. emitRate: number;
  17714. /**
  17715. * You can use gravity if you want to give an orientation to your particles.
  17716. */
  17717. gravity: Vector3;
  17718. /**
  17719. * Minimum power of emitting particles.
  17720. */
  17721. minEmitPower: number;
  17722. /**
  17723. * Maximum power of emitting particles.
  17724. */
  17725. maxEmitPower: number;
  17726. /**
  17727. * The particle emitter type defines the emitter used by the particle system.
  17728. * It can be for example box, sphere, or cone...
  17729. */
  17730. particleEmitterType: Nullable<IParticleEmitterType>;
  17731. /**
  17732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17734. */
  17735. direction1: Vector3;
  17736. /**
  17737. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17739. */
  17740. direction2: Vector3;
  17741. /**
  17742. * 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.
  17743. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17744. */
  17745. minEmitBox: Vector3;
  17746. /**
  17747. * 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.
  17748. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17749. */
  17750. maxEmitBox: Vector3;
  17751. /**
  17752. * Gets the maximum number of particles active at the same time.
  17753. * @returns The max number of active particles.
  17754. */
  17755. getCapacity(): number;
  17756. /**
  17757. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17758. * to override the particles.
  17759. */
  17760. forceDepthWrite: boolean;
  17761. /**
  17762. * Gets or set the number of active particles
  17763. */
  17764. activeParticleCount: number;
  17765. /**
  17766. * Is this system ready to be used/rendered
  17767. * @return true if the system is ready
  17768. */
  17769. isReady(): boolean;
  17770. /**
  17771. * Gets Wether the system has been started.
  17772. * @returns True if it has been started, otherwise false.
  17773. */
  17774. isStarted(): boolean;
  17775. /**
  17776. * Starts the particle system and begins to emit.
  17777. */
  17778. start(): void;
  17779. /**
  17780. * Stops the particle system.
  17781. */
  17782. stop(): void;
  17783. /**
  17784. * Remove all active particles
  17785. */
  17786. reset(): void;
  17787. /**
  17788. * Returns the string "GPUParticleSystem"
  17789. * @returns a string containing the class name
  17790. */
  17791. getClassName(): string;
  17792. /**
  17793. * Instantiates a GPU particle system.
  17794. * 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.
  17795. * @param name The name of the particle system
  17796. * @param capacity The max number of particles alive at the same time
  17797. * @param scene The scene the particle system belongs to
  17798. */
  17799. constructor(name: string, options: Partial<{
  17800. capacity: number;
  17801. randomTextureSize: number;
  17802. }>, scene: Scene);
  17803. private _createUpdateVAO(source);
  17804. private _createRenderVAO(source, spriteSource);
  17805. private _initialize(force?);
  17806. /** @hidden */
  17807. /** @hidden */
  17808. /**
  17809. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17810. */
  17811. animate(): void;
  17812. /**
  17813. * Renders the particle system in its current state.
  17814. * @returns the current number of particles
  17815. */
  17816. render(): number;
  17817. /**
  17818. * Rebuilds the particle system
  17819. */
  17820. rebuild(): void;
  17821. private _releaseBuffers();
  17822. private _releaseVAOs();
  17823. /**
  17824. * Disposes the particle system and free the associated resources
  17825. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17826. */
  17827. dispose(disposeTexture?: boolean): void;
  17828. /**
  17829. * Clones the particle system.
  17830. * @param name The name of the cloned object
  17831. * @param newEmitter The new emitter to use
  17832. * @returns the cloned particle system
  17833. */
  17834. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17835. /**
  17836. * Serializes the particle system to a JSON object.
  17837. * @returns the JSON object
  17838. */
  17839. serialize(): any;
  17840. /**
  17841. * Parses a JSON object to create a GPU particle system.
  17842. * @param parsedParticleSystem The JSON object to parse
  17843. * @param scene The scene to create the particle system in
  17844. * @param rootUrl The root url to use to load external dependencies like texture
  17845. * @returns the parsed GPU particle system
  17846. */
  17847. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17848. }
  17849. }
  17850. declare module BABYLON {
  17851. /**
  17852. * Interface representing a particle system in Babylon.
  17853. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17854. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17855. */
  17856. interface IParticleSystem {
  17857. /**
  17858. * The id of the Particle system.
  17859. */
  17860. id: string;
  17861. /**
  17862. * The name of the Particle system.
  17863. */
  17864. name: string;
  17865. /**
  17866. * The emitter represents the Mesh or position we are attaching the particle system to.
  17867. */
  17868. emitter: Nullable<AbstractMesh | Vector3>;
  17869. /**
  17870. * The rendering group used by the Particle system to chose when to render.
  17871. */
  17872. renderingGroupId: number;
  17873. /**
  17874. * The layer mask we are rendering the particles through.
  17875. */
  17876. layerMask: number;
  17877. /**
  17878. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17879. */
  17880. updateSpeed: number;
  17881. /**
  17882. * The amount of time the particle system is running (depends of the overall update speed).
  17883. */
  17884. targetStopDuration: number;
  17885. /**
  17886. * The texture used to render each particle. (this can be a spritesheet)
  17887. */
  17888. particleTexture: Nullable<Texture>;
  17889. /**
  17890. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17891. */
  17892. blendMode: number;
  17893. /**
  17894. * Minimum life time of emitting particles.
  17895. */
  17896. minLifeTime: number;
  17897. /**
  17898. * Maximum life time of emitting particles.
  17899. */
  17900. maxLifeTime: number;
  17901. /**
  17902. * Minimum Size of emitting particles.
  17903. */
  17904. minSize: number;
  17905. /**
  17906. * Maximum Size of emitting particles.
  17907. */
  17908. maxSize: number;
  17909. /**
  17910. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17911. */
  17912. color1: Color4;
  17913. /**
  17914. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17915. */
  17916. color2: Color4;
  17917. /**
  17918. * Color the particle will have at the end of its lifetime.
  17919. */
  17920. colorDead: Color4;
  17921. /**
  17922. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17923. */
  17924. emitRate: number;
  17925. /**
  17926. * You can use gravity if you want to give an orientation to your particles.
  17927. */
  17928. gravity: Vector3;
  17929. /**
  17930. * Minimum power of emitting particles.
  17931. */
  17932. minEmitPower: number;
  17933. /**
  17934. * Maximum power of emitting particles.
  17935. */
  17936. maxEmitPower: number;
  17937. /**
  17938. * The particle emitter type defines the emitter used by the particle system.
  17939. * It can be for example box, sphere, or cone...
  17940. */
  17941. particleEmitterType: Nullable<IParticleEmitterType>;
  17942. /**
  17943. * Gets the maximum number of particles active at the same time.
  17944. * @returns The max number of active particles.
  17945. */
  17946. getCapacity(): number;
  17947. /**
  17948. * Gets Wether the system has been started.
  17949. * @returns True if it has been started, otherwise false.
  17950. */
  17951. isStarted(): boolean;
  17952. /**
  17953. * Gets if the particle system has been started.
  17954. * @return true if the system has been started, otherwise false.
  17955. */
  17956. isStarted(): boolean;
  17957. /**
  17958. * Animates the particle system for this frame.
  17959. */
  17960. animate(): void;
  17961. /**
  17962. * Renders the particle system in its current state.
  17963. * @returns the current number of particles
  17964. */
  17965. render(): number;
  17966. /**
  17967. * Dispose the particle system and frees its associated resources.
  17968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17969. */
  17970. dispose(disposeTexture?: boolean): void;
  17971. /**
  17972. * Clones the particle system.
  17973. * @param name The name of the cloned object
  17974. * @param newEmitter The new emitter to use
  17975. * @returns the cloned particle system
  17976. */
  17977. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17978. /**
  17979. * Serializes the particle system to a JSON object.
  17980. * @returns the JSON object
  17981. */
  17982. serialize(): any;
  17983. /**
  17984. * Rebuild the particle system
  17985. */
  17986. rebuild(): void;
  17987. /**
  17988. * Starts the particle system and begins to emit.
  17989. */
  17990. start(): void;
  17991. /**
  17992. * Stops the particle system.
  17993. */
  17994. stop(): void;
  17995. /**
  17996. * Remove all active particles
  17997. */
  17998. reset(): void;
  17999. /**
  18000. * Is this system ready to be used/rendered
  18001. * @return true if the system is ready
  18002. */
  18003. isReady(): boolean;
  18004. }
  18005. }
  18006. declare module BABYLON {
  18007. /**
  18008. * A particle represents one of the element emitted by a particle system.
  18009. * This is mainly define by its coordinates, direction, velocity and age.
  18010. */
  18011. class Particle {
  18012. /**
  18013. * particleSystem the particle system the particle belongs to.
  18014. */
  18015. particleSystem: ParticleSystem;
  18016. /**
  18017. * The world position of the particle in the scene.
  18018. */
  18019. position: Vector3;
  18020. /**
  18021. * The world direction of the particle in the scene.
  18022. */
  18023. direction: Vector3;
  18024. /**
  18025. * The color of the particle.
  18026. */
  18027. color: Color4;
  18028. /**
  18029. * The color change of the particle per step.
  18030. */
  18031. colorStep: Color4;
  18032. /**
  18033. * Defines how long will the life of the particle be.
  18034. */
  18035. lifeTime: number;
  18036. /**
  18037. * The current age of the particle.
  18038. */
  18039. age: number;
  18040. /**
  18041. * The current size of the particle.
  18042. */
  18043. size: number;
  18044. /**
  18045. * The current angle of the particle.
  18046. */
  18047. angle: number;
  18048. /**
  18049. * Defines how fast is the angle changing.
  18050. */
  18051. angularSpeed: number;
  18052. /**
  18053. * Defines the cell index used by the particle to be rendered from a sprite.
  18054. */
  18055. cellIndex: number;
  18056. private _currentFrameCounter;
  18057. /**
  18058. * Creates a new instance Particle
  18059. * @param particleSystem the particle system the particle belongs to
  18060. */
  18061. constructor(
  18062. /**
  18063. * particleSystem the particle system the particle belongs to.
  18064. */
  18065. particleSystem: ParticleSystem);
  18066. private updateCellInfoFromSystem();
  18067. /**
  18068. * Defines how the sprite cell index is updated for the particle. This is
  18069. * defined as a callback.
  18070. */
  18071. updateCellIndex: (scaledUpdateSpeed: number) => void;
  18072. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  18073. private _updateCellIndexWithCustomSpeed();
  18074. /**
  18075. * Copy the properties of particle to another one.
  18076. * @param other the particle to copy the information to.
  18077. */
  18078. copyTo(other: Particle): void;
  18079. }
  18080. }
  18081. declare module BABYLON {
  18082. /**
  18083. * This represents a particle system in Babylon.
  18084. * 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.
  18085. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18086. * @example https://doc.babylonjs.com/babylon101/particles
  18087. */
  18088. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18089. /**
  18090. * Source color is added to the destination color without alpha affecting the result.
  18091. */
  18092. static BLENDMODE_ONEONE: number;
  18093. /**
  18094. * Blend current color and particle color using particle’s alpha.
  18095. */
  18096. static BLENDMODE_STANDARD: number;
  18097. /**
  18098. * List of animations used by the particle system.
  18099. */
  18100. animations: Animation[];
  18101. /**
  18102. * The id of the Particle system.
  18103. */
  18104. id: string;
  18105. /**
  18106. * The friendly name of the Particle system.
  18107. */
  18108. name: string;
  18109. /**
  18110. * The rendering group used by the Particle system to chose when to render.
  18111. */
  18112. renderingGroupId: number;
  18113. /**
  18114. * The emitter represents the Mesh or position we are attaching the particle system to.
  18115. */
  18116. emitter: Nullable<AbstractMesh | Vector3>;
  18117. /**
  18118. * The maximum number of particles to emit per frame
  18119. */
  18120. emitRate: number;
  18121. /**
  18122. * If you want to launch only a few particles at once, that can be done, as well.
  18123. */
  18124. manualEmitCount: number;
  18125. /**
  18126. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18127. */
  18128. updateSpeed: number;
  18129. /**
  18130. * The amount of time the particle system is running (depends of the overall update speed).
  18131. */
  18132. targetStopDuration: number;
  18133. /**
  18134. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18135. */
  18136. disposeOnStop: boolean;
  18137. /**
  18138. * Minimum power of emitting particles.
  18139. */
  18140. minEmitPower: number;
  18141. /**
  18142. * Maximum power of emitting particles.
  18143. */
  18144. maxEmitPower: number;
  18145. /**
  18146. * Minimum life time of emitting particles.
  18147. */
  18148. minLifeTime: number;
  18149. /**
  18150. * Maximum life time of emitting particles.
  18151. */
  18152. maxLifeTime: number;
  18153. /**
  18154. * Minimum Size of emitting particles.
  18155. */
  18156. minSize: number;
  18157. /**
  18158. * Maximum Size of emitting particles.
  18159. */
  18160. maxSize: number;
  18161. /**
  18162. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18163. */
  18164. minAngularSpeed: number;
  18165. /**
  18166. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18167. */
  18168. maxAngularSpeed: number;
  18169. /**
  18170. * The texture used to render each particle. (this can be a spritesheet)
  18171. */
  18172. particleTexture: Nullable<Texture>;
  18173. /**
  18174. * The layer mask we are rendering the particles through.
  18175. */
  18176. layerMask: number;
  18177. /**
  18178. * This can help using your own shader to render the particle system.
  18179. * The according effect will be created
  18180. */
  18181. customShader: any;
  18182. /**
  18183. * By default particle system starts as soon as they are created. This prevents the
  18184. * automatic start to happen and let you decide when to start emitting particles.
  18185. */
  18186. preventAutoStart: boolean;
  18187. /**
  18188. * This function can be defined to provide custom update for active particles.
  18189. * This function will be called instead of regular update (age, position, color, etc.).
  18190. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18191. */
  18192. updateFunction: (particles: Particle[]) => void;
  18193. /**
  18194. * Callback triggered when the particle animation is ending.
  18195. */
  18196. onAnimationEnd: Nullable<() => void>;
  18197. /**
  18198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18199. */
  18200. blendMode: number;
  18201. /**
  18202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18203. * to override the particles.
  18204. */
  18205. forceDepthWrite: boolean;
  18206. /**
  18207. * You can use gravity if you want to give an orientation to your particles.
  18208. */
  18209. gravity: Vector3;
  18210. /**
  18211. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18213. */
  18214. direction1: Vector3;
  18215. /**
  18216. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18218. */
  18219. direction2: Vector3;
  18220. /**
  18221. * 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.
  18222. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18223. */
  18224. minEmitBox: Vector3;
  18225. /**
  18226. * 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.
  18227. * This only works when particleEmitterTyps is a BoxParticleEmitter
  18228. */
  18229. maxEmitBox: Vector3;
  18230. /**
  18231. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18232. */
  18233. color1: Color4;
  18234. /**
  18235. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18236. */
  18237. color2: Color4;
  18238. /**
  18239. * Color the particle will have at the end of its lifetime.
  18240. */
  18241. colorDead: Color4;
  18242. /**
  18243. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  18244. */
  18245. textureMask: Color4;
  18246. /**
  18247. * The particle emitter type defines the emitter used by the particle system.
  18248. * It can be for example box, sphere, or cone...
  18249. */
  18250. particleEmitterType: IParticleEmitterType;
  18251. /**
  18252. * This function can be defined to specify initial direction for every new particle.
  18253. * It by default use the emitterType defined function.
  18254. */
  18255. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18256. /**
  18257. * This function can be defined to specify initial position for every new particle.
  18258. * It by default use the emitterType defined function.
  18259. */
  18260. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18261. /**
  18262. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  18263. */
  18264. spriteCellLoop: boolean;
  18265. /**
  18266. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  18267. */
  18268. spriteCellChangeSpeed: number;
  18269. /**
  18270. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  18271. */
  18272. startSpriteCellID: number;
  18273. /**
  18274. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  18275. */
  18276. endSpriteCellID: number;
  18277. /**
  18278. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  18279. */
  18280. spriteCellWidth: number;
  18281. /**
  18282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  18283. */
  18284. spriteCellHeight: number;
  18285. /**
  18286. * An event triggered when the system is disposed.
  18287. */
  18288. onDisposeObservable: Observable<ParticleSystem>;
  18289. private _onDisposeObserver;
  18290. /**
  18291. * Sets a callback that will be triggered when the system is disposed.
  18292. */
  18293. onDispose: () => void;
  18294. /**
  18295. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  18296. */
  18297. readonly isAnimationSheetEnabled: Boolean;
  18298. private _particles;
  18299. private _epsilon;
  18300. private _capacity;
  18301. private _scene;
  18302. private _stockParticles;
  18303. private _newPartsExcess;
  18304. private _vertexData;
  18305. private _vertexBuffer;
  18306. private _vertexBuffers;
  18307. private _indexBuffer;
  18308. private _effect;
  18309. private _customEffect;
  18310. private _cachedDefines;
  18311. private _scaledColorStep;
  18312. private _colorDiff;
  18313. private _scaledDirection;
  18314. private _scaledGravity;
  18315. private _currentRenderId;
  18316. private _alive;
  18317. private _started;
  18318. private _stopped;
  18319. private _actualFrame;
  18320. private _scaledUpdateSpeed;
  18321. private _vertexBufferSize;
  18322. private _isAnimationSheetEnabled;
  18323. /**
  18324. * 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.
  18325. */
  18326. subEmitters: ParticleSystem[];
  18327. /**
  18328. * The current active Sub-systems, this property is used by the root particle system only.
  18329. */
  18330. activeSubSystems: Array<ParticleSystem>;
  18331. private _rootParticleSystem;
  18332. /**
  18333. * Gets the current list of active particles
  18334. */
  18335. readonly particles: Particle[];
  18336. /**
  18337. * Returns the string "ParticleSystem"
  18338. * @returns a string containing the class name
  18339. */
  18340. getClassName(): string;
  18341. /**
  18342. * Instantiates a particle system.
  18343. * 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.
  18344. * @param name The name of the particle system
  18345. * @param capacity The max number of particles alive at the same time
  18346. * @param scene The scene the particle system belongs to
  18347. * @param customEffect a custom effect used to change the way particles are rendered by default
  18348. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18349. * @param epsilon Offset used to render the particles
  18350. */
  18351. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18352. private _createIndexBuffer();
  18353. /**
  18354. * Gets the maximum number of particles active at the same time.
  18355. * @returns The max number of active particles.
  18356. */
  18357. getCapacity(): number;
  18358. /**
  18359. * Gets Wether there are still active particles in the system.
  18360. * @returns True if it is alive, otherwise false.
  18361. */
  18362. isAlive(): boolean;
  18363. /**
  18364. * Gets Wether the system has been started.
  18365. * @returns True if it has been started, otherwise false.
  18366. */
  18367. isStarted(): boolean;
  18368. /**
  18369. * Starts the particle system and begins to emit.
  18370. */
  18371. start(): void;
  18372. /**
  18373. * Stops the particle system.
  18374. * @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.
  18375. */
  18376. stop(stopSubEmitters?: boolean): void;
  18377. /**
  18378. * Remove all active particles
  18379. */
  18380. reset(): void;
  18381. /**
  18382. * @hidden (for internal use only)
  18383. */
  18384. /**
  18385. * @hidden (for internal use only)
  18386. */
  18387. /**
  18388. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18389. * Its lifetime will start back at 0.
  18390. */
  18391. recycleParticle: (particle: Particle) => void;
  18392. private _stopSubEmitters();
  18393. private _createParticle;
  18394. private _removeFromRoot();
  18395. private _emitFromParticle;
  18396. private _update(newParticles);
  18397. private _getEffect();
  18398. /**
  18399. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18400. */
  18401. animate(): void;
  18402. private _appendParticleVertexes;
  18403. private _appenedParticleVertexesWithSheet(offset, particle);
  18404. private _appenedParticleVertexesNoSheet(offset, particle);
  18405. /**
  18406. * Rebuilds the particle system.
  18407. */
  18408. rebuild(): void;
  18409. /**
  18410. * Is this system ready to be used/rendered
  18411. * @return true if the system is ready
  18412. */
  18413. isReady(): boolean;
  18414. /**
  18415. * Renders the particle system in its current state.
  18416. * @returns the current number of particles
  18417. */
  18418. render(): number;
  18419. /**
  18420. * Disposes the particle system and free the associated resources
  18421. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18422. */
  18423. dispose(disposeTexture?: boolean): void;
  18424. /**
  18425. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18426. * @param radius The radius of the sphere to emit from
  18427. * @returns the emitter
  18428. */
  18429. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18430. /**
  18431. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18432. * @param radius The radius of the sphere to emit from
  18433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18435. * @returns the emitter
  18436. */
  18437. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18438. /**
  18439. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18440. * @param radius The radius of the cone to emit from
  18441. * @param angle The base angle of the cone
  18442. * @returns the emitter
  18443. */
  18444. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18445. /**
  18446. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18449. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18450. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18451. * @returns the emitter
  18452. */
  18453. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18454. /**
  18455. * Clones the particle system.
  18456. * @param name The name of the cloned object
  18457. * @param newEmitter The new emitter to use
  18458. * @returns the cloned particle system
  18459. */
  18460. clone(name: string, newEmitter: any): ParticleSystem;
  18461. /**
  18462. * Serializes the particle system to a JSON object.
  18463. * @returns the JSON object
  18464. */
  18465. serialize(): any;
  18466. /**
  18467. * Parses a JSON object to create a particle system.
  18468. * @param parsedParticleSystem The JSON object to parse
  18469. * @param scene The scene to create the particle system in
  18470. * @param rootUrl The root url to use to load external dependencies like texture
  18471. * @returns the Parsed particle system
  18472. */
  18473. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18474. }
  18475. }
  18476. declare module BABYLON {
  18477. /**
  18478. * Represents one particle of a solid particle system.
  18479. */
  18480. class SolidParticle {
  18481. /**
  18482. * particle global index
  18483. */
  18484. idx: number;
  18485. /**
  18486. * The color of the particle
  18487. */
  18488. color: Nullable<Color4>;
  18489. /**
  18490. * The world space position of the particle.
  18491. */
  18492. position: Vector3;
  18493. /**
  18494. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18495. */
  18496. rotation: Vector3;
  18497. /**
  18498. * The world space rotation quaternion of the particle.
  18499. */
  18500. rotationQuaternion: Nullable<Quaternion>;
  18501. /**
  18502. * The scaling of the particle.
  18503. */
  18504. scaling: Vector3;
  18505. /**
  18506. * The uvs of the particle.
  18507. */
  18508. uvs: Vector4;
  18509. /**
  18510. * The current speed of the particle.
  18511. */
  18512. velocity: Vector3;
  18513. /**
  18514. * The pivot point in the particle local space.
  18515. */
  18516. pivot: Vector3;
  18517. /**
  18518. * Must the particle be translated from its pivot point in its local space ?
  18519. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18520. * Default : false
  18521. */
  18522. translateFromPivot: boolean;
  18523. /**
  18524. * Is the particle active or not ?
  18525. */
  18526. alive: boolean;
  18527. /**
  18528. * Is the particle visible or not ?
  18529. */
  18530. isVisible: boolean;
  18531. /**
  18532. * Index of this particle in the global "positions" array (Internal use)
  18533. */
  18534. /**
  18535. * Index of this particle in the global "indices" array (Internal use)
  18536. */
  18537. /**
  18538. * ModelShape of this particle (Internal use)
  18539. */
  18540. /**
  18541. * ModelShape id of this particle
  18542. */
  18543. shapeId: number;
  18544. /**
  18545. * Index of the particle in its shape id (Internal use)
  18546. */
  18547. idxInShape: number;
  18548. /**
  18549. * Reference to the shape model BoundingInfo object (Internal use)
  18550. */
  18551. /**
  18552. * Particle BoundingInfo object (Internal use)
  18553. */
  18554. /**
  18555. * Reference to the SPS what the particle belongs to (Internal use)
  18556. */
  18557. /**
  18558. * Still set as invisible in order to skip useless computations (Internal use)
  18559. */
  18560. /**
  18561. * Last computed particle rotation matrix
  18562. */
  18563. /**
  18564. * Parent particle Id, if any.
  18565. * Default null.
  18566. */
  18567. parentId: Nullable<number>;
  18568. /**
  18569. * Internal global position in the SPS.
  18570. */
  18571. /**
  18572. * Creates a Solid Particle object.
  18573. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18574. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18575. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18576. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18577. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18578. * @param shapeId (integer) is the model shape identifier in the SPS.
  18579. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18580. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18581. */
  18582. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18583. /**
  18584. * Legacy support, changed scale to scaling
  18585. */
  18586. /**
  18587. * Legacy support, changed scale to scaling
  18588. */
  18589. scale: Vector3;
  18590. /**
  18591. * Legacy support, changed quaternion to rotationQuaternion
  18592. */
  18593. /**
  18594. * Legacy support, changed quaternion to rotationQuaternion
  18595. */
  18596. quaternion: Nullable<Quaternion>;
  18597. /**
  18598. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18599. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18600. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18601. * @returns true if it intersects
  18602. */
  18603. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18604. }
  18605. /**
  18606. * Represents the shape of the model used by one particle of a solid particle system.
  18607. * SPS internal tool, don't use it manually.
  18608. */
  18609. class ModelShape {
  18610. /**
  18611. * The shape id.
  18612. */
  18613. shapeID: number;
  18614. /**
  18615. * flat array of model positions (internal use)
  18616. */
  18617. /**
  18618. * flat array of model UVs (internal use)
  18619. */
  18620. /**
  18621. * length of the shape in the model indices array (internal use)
  18622. */
  18623. /**
  18624. * Custom position function (internal use)
  18625. */
  18626. /**
  18627. * Custom vertex function (internal use)
  18628. */
  18629. /**
  18630. * 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.
  18631. * SPS internal tool, don't use it manually.
  18632. * @hidden
  18633. */
  18634. 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>);
  18635. }
  18636. /**
  18637. * Represents a Depth Sorted Particle in the solid particle system.
  18638. */
  18639. class DepthSortedParticle {
  18640. /**
  18641. * Index of the particle in the "indices" array
  18642. */
  18643. ind: number;
  18644. /**
  18645. * Length of the particle shape in the "indices" array
  18646. */
  18647. indicesLength: number;
  18648. /**
  18649. * Squared distance from the particle to the camera
  18650. */
  18651. sqDistance: number;
  18652. }
  18653. }
  18654. declare module BABYLON {
  18655. /**
  18656. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18657. *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.
  18658. * The SPS is also a particle system. It provides some methods to manage the particles.
  18659. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18660. *
  18661. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18662. */
  18663. class SolidParticleSystem implements IDisposable {
  18664. /**
  18665. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18666. * Example : var p = SPS.particles[i];
  18667. */
  18668. particles: SolidParticle[];
  18669. /**
  18670. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18671. */
  18672. nbParticles: number;
  18673. /**
  18674. * If the particles must ever face the camera (default false). Useful for planar particles.
  18675. */
  18676. billboard: boolean;
  18677. /**
  18678. * Recompute normals when adding a shape
  18679. */
  18680. recomputeNormals: boolean;
  18681. /**
  18682. * This a counter ofr your own usage. It's not set by any SPS functions.
  18683. */
  18684. counter: number;
  18685. /**
  18686. * The SPS name. This name is also given to the underlying mesh.
  18687. */
  18688. name: string;
  18689. /**
  18690. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18691. */
  18692. mesh: Mesh;
  18693. /**
  18694. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18695. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18696. */
  18697. vars: any;
  18698. /**
  18699. * This array is populated when the SPS is set as 'pickable'.
  18700. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18701. * Each element of this array is an object `{idx: int, faceId: int}`.
  18702. * `idx` is the picked particle index in the `SPS.particles` array
  18703. * `faceId` is the picked face index counted within this particle.
  18704. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18705. */
  18706. pickedParticles: {
  18707. idx: number;
  18708. faceId: number;
  18709. }[];
  18710. /**
  18711. * This array is populated when `enableDepthSort` is set to true.
  18712. * Each element of this array is an instance of the class DepthSortedParticle.
  18713. */
  18714. depthSortedParticles: DepthSortedParticle[];
  18715. /**
  18716. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18717. */
  18718. /**
  18719. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18720. */
  18721. private _scene;
  18722. private _positions;
  18723. private _indices;
  18724. private _normals;
  18725. private _colors;
  18726. private _uvs;
  18727. private _indices32;
  18728. private _positions32;
  18729. private _normals32;
  18730. private _fixedNormal32;
  18731. private _colors32;
  18732. private _uvs32;
  18733. private _index;
  18734. private _updatable;
  18735. private _pickable;
  18736. private _isVisibilityBoxLocked;
  18737. private _alwaysVisible;
  18738. private _depthSort;
  18739. private _shapeCounter;
  18740. private _copy;
  18741. private _shape;
  18742. private _shapeUV;
  18743. private _color;
  18744. private _computeParticleColor;
  18745. private _computeParticleTexture;
  18746. private _computeParticleRotation;
  18747. private _computeParticleVertex;
  18748. private _computeBoundingBox;
  18749. private _depthSortParticles;
  18750. private _cam_axisZ;
  18751. private _cam_axisY;
  18752. private _cam_axisX;
  18753. private _axisZ;
  18754. private _camera;
  18755. private _particle;
  18756. private _camDir;
  18757. private _camInvertedPosition;
  18758. private _rotMatrix;
  18759. private _invertMatrix;
  18760. private _rotated;
  18761. private _quaternion;
  18762. private _vertex;
  18763. private _normal;
  18764. private _yaw;
  18765. private _pitch;
  18766. private _roll;
  18767. private _halfroll;
  18768. private _halfpitch;
  18769. private _halfyaw;
  18770. private _sinRoll;
  18771. private _cosRoll;
  18772. private _sinPitch;
  18773. private _cosPitch;
  18774. private _sinYaw;
  18775. private _cosYaw;
  18776. private _mustUnrotateFixedNormals;
  18777. private _minimum;
  18778. private _maximum;
  18779. private _minBbox;
  18780. private _maxBbox;
  18781. private _particlesIntersect;
  18782. private _depthSortFunction;
  18783. private _needs32Bits;
  18784. private _pivotBackTranslation;
  18785. private _scaledPivot;
  18786. private _particleHasParent;
  18787. private _parent;
  18788. /**
  18789. * Creates a SPS (Solid Particle System) object.
  18790. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18791. * @param scene (Scene) is the scene in which the SPS is added.
  18792. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18793. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18794. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18795. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18796. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18797. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18798. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18799. */
  18800. constructor(name: string, scene: Scene, options?: {
  18801. updatable?: boolean;
  18802. isPickable?: boolean;
  18803. enableDepthSort?: boolean;
  18804. particleIntersection?: boolean;
  18805. boundingSphereOnly?: boolean;
  18806. bSphereRadiusFactor?: number;
  18807. });
  18808. /**
  18809. * Builds the SPS underlying mesh. Returns a standard Mesh.
  18810. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  18811. * @returns the created mesh
  18812. */
  18813. buildMesh(): Mesh;
  18814. /**
  18815. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18816. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18817. * Thus the particles generated from `digest()` have their property `position` set yet.
  18818. * @param mesh ( Mesh ) is the mesh to be digested
  18819. * @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
  18820. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18821. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18822. * @returns the current SPS
  18823. */
  18824. digest(mesh: Mesh, options?: {
  18825. facetNb?: number;
  18826. number?: number;
  18827. delta?: number;
  18828. }): SolidParticleSystem;
  18829. private _unrotateFixedNormals();
  18830. private _resetCopy();
  18831. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18832. private _posToShape(positions);
  18833. private _uvsToShapeUV(uvs);
  18834. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18835. /**
  18836. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18837. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18838. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18839. * @param nb (positive integer) the number of particles to be created from this model
  18840. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18841. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18842. * @returns the number of shapes in the system
  18843. */
  18844. addShape(mesh: Mesh, nb: number, options?: {
  18845. positionFunction?: any;
  18846. vertexFunction?: any;
  18847. }): number;
  18848. private _rebuildParticle(particle);
  18849. /**
  18850. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18851. * @returns the SPS.
  18852. */
  18853. rebuildMesh(): SolidParticleSystem;
  18854. /**
  18855. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18856. * This method calls `updateParticle()` for each particle of the SPS.
  18857. * For an animated SPS, it is usually called within the render loop.
  18858. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18859. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18860. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18861. * @returns the SPS.
  18862. */
  18863. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18864. private _quaternionRotationYPR();
  18865. private _quaternionToRotationMatrix();
  18866. /**
  18867. * Disposes the SPS.
  18868. */
  18869. dispose(): void;
  18870. /**
  18871. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18873. * @returns the SPS.
  18874. */
  18875. refreshVisibleSize(): SolidParticleSystem;
  18876. /**
  18877. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18878. * @param size the size (float) of the visibility box
  18879. * note : this doesn't lock the SPS mesh bounding box.
  18880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18881. */
  18882. setVisibilityBox(size: number): void;
  18883. /**
  18884. * Gets whether the SPS as always visible or not
  18885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18886. */
  18887. /**
  18888. * Sets the SPS as always visible or not
  18889. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18890. */
  18891. isAlwaysVisible: boolean;
  18892. /**
  18893. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18894. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18895. */
  18896. /**
  18897. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18898. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18899. */
  18900. isVisibilityBoxLocked: boolean;
  18901. /**
  18902. * Gets if `setParticles()` computes the particle rotations or not.
  18903. * Default value : true. The SPS is faster when it's set to false.
  18904. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18905. */
  18906. /**
  18907. * Tells to `setParticles()` to compute the particle rotations or not.
  18908. * Default value : true. The SPS is faster when it's set to false.
  18909. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18910. */
  18911. computeParticleRotation: boolean;
  18912. /**
  18913. * Gets if `setParticles()` computes the particle colors or not.
  18914. * Default value : true. The SPS is faster when it's set to false.
  18915. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18916. */
  18917. /**
  18918. * Tells to `setParticles()` to compute the particle colors or not.
  18919. * Default value : true. The SPS is faster when it's set to false.
  18920. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18921. */
  18922. computeParticleColor: boolean;
  18923. /**
  18924. * Gets if `setParticles()` computes the particle textures or not.
  18925. * Default value : true. The SPS is faster when it's set to false.
  18926. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  18927. */
  18928. computeParticleTexture: boolean;
  18929. /**
  18930. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  18931. * Default value : false. The SPS is faster when it's set to false.
  18932. * Note : the particle custom vertex positions aren't stored values.
  18933. */
  18934. /**
  18935. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  18936. * Default value : false. The SPS is faster when it's set to false.
  18937. * Note : the particle custom vertex positions aren't stored values.
  18938. */
  18939. computeParticleVertex: boolean;
  18940. /**
  18941. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  18942. */
  18943. /**
  18944. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  18945. */
  18946. computeBoundingBox: boolean;
  18947. /**
  18948. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  18949. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18950. * Default : `true`
  18951. */
  18952. /**
  18953. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  18954. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18955. * Default : `true`
  18956. */
  18957. depthSortParticles: boolean;
  18958. /**
  18959. * This function does nothing. It may be overwritten to set all the particle first values.
  18960. * The SPS doesn't call this function, you may have to call it by your own.
  18961. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18962. */
  18963. initParticles(): void;
  18964. /**
  18965. * This function does nothing. It may be overwritten to recycle a particle.
  18966. * The SPS doesn't call this function, you may have to call it by your own.
  18967. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18968. * @param particle The particle to recycle
  18969. * @returns the recycled particle
  18970. */
  18971. recycleParticle(particle: SolidParticle): SolidParticle;
  18972. /**
  18973. * Updates a particle : this function should be overwritten by the user.
  18974. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  18975. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18976. * @example : just set a particle position or velocity and recycle conditions
  18977. * @param particle The particle to update
  18978. * @returns the updated particle
  18979. */
  18980. updateParticle(particle: SolidParticle): SolidParticle;
  18981. /**
  18982. * Updates a vertex of a particle : it can be overwritten by the user.
  18983. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  18984. * @param particle the current particle
  18985. * @param vertex the current index of the current particle
  18986. * @param pt the index of the current vertex in the particle shape
  18987. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  18988. * @example : just set a vertex particle position
  18989. * @returns the updated vertex
  18990. */
  18991. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  18992. /**
  18993. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  18994. * This does nothing and may be overwritten by the user.
  18995. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18996. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18997. * @param update the boolean update value actually passed to setParticles()
  18998. */
  18999. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19000. /**
  19001. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19002. * This will be passed three parameters.
  19003. * This does nothing and may be overwritten by the user.
  19004. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19005. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19006. * @param update the boolean update value actually passed to setParticles()
  19007. */
  19008. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19009. }
  19010. }
  19011. declare module BABYLON {
  19012. /**
  19013. * Class used to store all common mesh properties
  19014. */
  19015. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19016. /** No occlusion */
  19017. static OCCLUSION_TYPE_NONE: number;
  19018. /** Occlusion set to optimisitic */
  19019. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19020. /** Occlusion set to strict */
  19021. static OCCLUSION_TYPE_STRICT: number;
  19022. /** Use an accurante occlusion algorithm */
  19023. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19024. /** Use a conservative occlusion algorithm */
  19025. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19026. /**
  19027. * No billboard
  19028. */
  19029. static readonly BILLBOARDMODE_NONE: number;
  19030. /** Billboard on X axis */
  19031. static readonly BILLBOARDMODE_X: number;
  19032. /** Billboard on Y axis */
  19033. static readonly BILLBOARDMODE_Y: number;
  19034. /** Billboard on Z axis */
  19035. static readonly BILLBOARDMODE_Z: number;
  19036. /** Billboard on all axes */
  19037. static readonly BILLBOARDMODE_ALL: number;
  19038. private _facetPositions;
  19039. private _facetNormals;
  19040. private _facetPartitioning;
  19041. private _facetNb;
  19042. private _partitioningSubdivisions;
  19043. private _partitioningBBoxRatio;
  19044. private _facetDataEnabled;
  19045. private _facetParameters;
  19046. private _bbSize;
  19047. private _subDiv;
  19048. private _facetDepthSort;
  19049. private _facetDepthSortEnabled;
  19050. private _depthSortedIndices;
  19051. private _depthSortedFacets;
  19052. private _facetDepthSortFunction;
  19053. private _facetDepthSortFrom;
  19054. private _facetDepthSortOrigin;
  19055. private _invertedMatrix;
  19056. /**
  19057. * Gets the number of facets in the mesh
  19058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19059. */
  19060. readonly facetNb: number;
  19061. /**
  19062. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19064. */
  19065. partitioningSubdivisions: number;
  19066. /**
  19067. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19068. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19070. */
  19071. partitioningBBoxRatio: number;
  19072. /**
  19073. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19074. * Works only for updatable meshes.
  19075. * Doesn't work with multi-materials
  19076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19077. */
  19078. mustDepthSortFacets: boolean;
  19079. /**
  19080. * The location (Vector3) where the facet depth sort must be computed from.
  19081. * By default, the active camera position.
  19082. * Used only when facet depth sort is enabled
  19083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19084. */
  19085. facetDepthSortFrom: Vector3;
  19086. /**
  19087. * gets a boolean indicating if facetData is enabled
  19088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19089. */
  19090. readonly isFacetDataEnabled: boolean;
  19091. /** @hidden */
  19092. /**
  19093. * An event triggered when this mesh collides with another one
  19094. */
  19095. onCollideObservable: Observable<AbstractMesh>;
  19096. private _onCollideObserver;
  19097. /** Set a function to call when this mesh collides with another one */
  19098. onCollide: () => void;
  19099. /**
  19100. * An event triggered when the collision's position changes
  19101. */
  19102. onCollisionPositionChangeObservable: Observable<Vector3>;
  19103. private _onCollisionPositionChangeObserver;
  19104. /** Set a function to call when the collision's position changes */
  19105. onCollisionPositionChange: () => void;
  19106. /**
  19107. * An event triggered when material is changed
  19108. */
  19109. onMaterialChangedObservable: Observable<AbstractMesh>;
  19110. /**
  19111. * Gets or sets the orientation for POV movement & rotation
  19112. */
  19113. definedFacingForward: boolean;
  19114. /**
  19115. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19116. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19117. * * 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.
  19118. * @see http://doc.babylonjs.com/features/occlusionquery
  19119. */
  19120. occlusionQueryAlgorithmType: number;
  19121. /**
  19122. * 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:
  19123. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19124. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19125. * * 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.
  19126. * @see http://doc.babylonjs.com/features/occlusionquery
  19127. */
  19128. occlusionType: number;
  19129. /**
  19130. * 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.
  19131. * The default value is -1 which means don't break the query and wait till the result
  19132. * @see http://doc.babylonjs.com/features/occlusionquery
  19133. */
  19134. occlusionRetryCount: number;
  19135. private _occlusionInternalRetryCounter;
  19136. protected _isOccluded: boolean;
  19137. /**
  19138. * 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
  19139. * @see http://doc.babylonjs.com/features/occlusionquery
  19140. */
  19141. isOccluded: boolean;
  19142. private _isOcclusionQueryInProgress;
  19143. /**
  19144. * Flag to check the progress status of the query
  19145. * @see http://doc.babylonjs.com/features/occlusionquery
  19146. */
  19147. readonly isOcclusionQueryInProgress: boolean;
  19148. private _occlusionQuery;
  19149. private _visibility;
  19150. /**
  19151. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19152. */
  19153. /**
  19154. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19155. */
  19156. visibility: number;
  19157. /** Gets or sets the alpha index used to sort transparent meshes
  19158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19159. */
  19160. alphaIndex: number;
  19161. /**
  19162. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19163. */
  19164. isVisible: boolean;
  19165. /**
  19166. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19167. */
  19168. isPickable: boolean;
  19169. /**
  19170. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  19171. */
  19172. showBoundingBox: boolean;
  19173. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19174. showSubMeshesBoundingBox: boolean;
  19175. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19176. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19177. */
  19178. isBlocker: boolean;
  19179. /**
  19180. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19181. */
  19182. enablePointerMoveEvents: boolean;
  19183. /**
  19184. * Specifies the rendering group id for this mesh (0 by default)
  19185. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19186. */
  19187. renderingGroupId: number;
  19188. private _material;
  19189. /** Gets or sets current material */
  19190. material: Nullable<Material>;
  19191. private _receiveShadows;
  19192. /**
  19193. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19194. * @see http://doc.babylonjs.com/babylon101/shadows
  19195. */
  19196. receiveShadows: boolean;
  19197. /**
  19198. * Gets or sets a boolean indicating if the outline must be rendered as well
  19199. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19200. */
  19201. renderOutline: boolean;
  19202. /** Defines color to use when rendering outline */
  19203. outlineColor: Color3;
  19204. /** Define width to use when rendering outline */
  19205. outlineWidth: number;
  19206. /**
  19207. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19208. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19209. */
  19210. renderOverlay: boolean;
  19211. /** Defines color to use when rendering overlay */
  19212. overlayColor: Color3;
  19213. /** Defines alpha to use when rendering overlay */
  19214. overlayAlpha: number;
  19215. private _hasVertexAlpha;
  19216. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19217. hasVertexAlpha: boolean;
  19218. private _useVertexColors;
  19219. /** 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) */
  19220. useVertexColors: boolean;
  19221. private _computeBonesUsingShaders;
  19222. /**
  19223. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19224. */
  19225. computeBonesUsingShaders: boolean;
  19226. private _numBoneInfluencers;
  19227. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19228. numBoneInfluencers: number;
  19229. private _applyFog;
  19230. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19231. applyFog: boolean;
  19232. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19233. useOctreeForRenderingSelection: boolean;
  19234. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19235. useOctreeForPicking: boolean;
  19236. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19237. useOctreeForCollisions: boolean;
  19238. private _layerMask;
  19239. /**
  19240. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19241. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19242. */
  19243. layerMask: number;
  19244. /**
  19245. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19246. */
  19247. alwaysSelectAsActiveMesh: boolean;
  19248. /**
  19249. * Gets or sets the current action manager
  19250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19251. */
  19252. actionManager: Nullable<ActionManager>;
  19253. /**
  19254. * Gets or sets impostor used for physic simulation
  19255. * @see http://doc.babylonjs.com/features/physics_engine
  19256. */
  19257. physicsImpostor: Nullable<PhysicsImpostor>;
  19258. private _checkCollisions;
  19259. private _collisionMask;
  19260. private _collisionGroup;
  19261. /**
  19262. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19263. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19264. */
  19265. ellipsoid: Vector3;
  19266. /**
  19267. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19268. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19269. */
  19270. ellipsoidOffset: Vector3;
  19271. private _collider;
  19272. private _oldPositionForCollisions;
  19273. private _diffPositionForCollisions;
  19274. /**
  19275. * Gets or sets a collision mask used to mask collisions (default is -1).
  19276. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19277. */
  19278. collisionMask: number;
  19279. /**
  19280. * Gets or sets the current collision group mask (-1 by default).
  19281. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19282. */
  19283. collisionGroup: number;
  19284. /**
  19285. * Defines edge width used when edgesRenderer is enabled
  19286. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19287. */
  19288. edgesWidth: number;
  19289. /**
  19290. * Defines edge color used when edgesRenderer is enabled
  19291. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19292. */
  19293. edgesColor: Color4;
  19294. /** @hidden */
  19295. private _collisionsTransformMatrix;
  19296. private _collisionsScalingMatrix;
  19297. /** @hidden */
  19298. /** @hidden */
  19299. /** @hidden */
  19300. /**
  19301. * Gets or sets the list of subMeshes
  19302. * @see http://doc.babylonjs.com/how_to/multi_materials
  19303. */
  19304. subMeshes: SubMesh[];
  19305. /** @hidden */
  19306. /** @hidden */
  19307. /** @hidden */
  19308. /** @hidden */
  19309. /** @hidden */
  19310. protected readonly _positions: Nullable<Vector3[]>;
  19311. /** @hidden */
  19312. /** @hidden */
  19313. private _skeleton;
  19314. /** @hidden */
  19315. /**
  19316. * Gets or sets a skeleton to apply skining transformations
  19317. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19318. */
  19319. skeleton: Nullable<Skeleton>;
  19320. /**
  19321. * Creates a new AbstractMesh
  19322. * @param name defines the name of the mesh
  19323. * @param scene defines the hosting scene
  19324. */
  19325. constructor(name: string, scene?: Nullable<Scene>);
  19326. /**
  19327. * Returns the string "AbstractMesh"
  19328. * @returns "AbstractMesh"
  19329. */
  19330. getClassName(): string;
  19331. /**
  19332. * Gets a string representation of the current mesh
  19333. * @param fullDetails defines a boolean indicating if full details must be included
  19334. * @returns a string representation of the current mesh
  19335. */
  19336. toString(fullDetails?: boolean): string;
  19337. /** @hidden */
  19338. /** @hidden */
  19339. /** @hidden */
  19340. /** @hidden */
  19341. /** @hidden */
  19342. private _markSubMeshesAsDirty(func);
  19343. /** @hidden */
  19344. /** @hidden */
  19345. /** @hidden */
  19346. /**
  19347. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19348. */
  19349. scaling: Vector3;
  19350. /**
  19351. * Disables the mesh edge rendering mode
  19352. * @returns the currentAbstractMesh
  19353. */
  19354. disableEdgesRendering(): AbstractMesh;
  19355. /**
  19356. * Enables the edge rendering mode on the mesh.
  19357. * This mode makes the mesh edges visible
  19358. * @param epsilon defines the maximal distance between two angles to detect a face
  19359. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19360. * @returns the currentAbstractMesh
  19361. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19362. */
  19363. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19364. /**
  19365. * Returns true if the mesh is blocked. Implemented by child classes
  19366. */
  19367. readonly isBlocked: boolean;
  19368. /**
  19369. * Returns the mesh itself by default. Implemented by child classes
  19370. * @param camera defines the camera to use to pick the right LOD level
  19371. * @returns the currentAbstractMesh
  19372. */
  19373. getLOD(camera: Camera): AbstractMesh;
  19374. /**
  19375. * Returns 0 by default. Implemented by child classes
  19376. * @returns an integer
  19377. */
  19378. getTotalVertices(): number;
  19379. /**
  19380. * Returns null by default. Implemented by child classes
  19381. * @returns null
  19382. */
  19383. getIndices(): Nullable<IndicesArray>;
  19384. /**
  19385. * Returns the array of the requested vertex data kind. Implemented by child classes
  19386. * @param kind defines the vertex data kind to use
  19387. * @returns null
  19388. */
  19389. getVerticesData(kind: string): Nullable<FloatArray>;
  19390. /**
  19391. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19392. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19393. * Note that a new underlying VertexBuffer object is created each call.
  19394. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19395. * @param kind defines vertex data kind:
  19396. * * BABYLON.VertexBuffer.PositionKind
  19397. * * BABYLON.VertexBuffer.UVKind
  19398. * * BABYLON.VertexBuffer.UV2Kind
  19399. * * BABYLON.VertexBuffer.UV3Kind
  19400. * * BABYLON.VertexBuffer.UV4Kind
  19401. * * BABYLON.VertexBuffer.UV5Kind
  19402. * * BABYLON.VertexBuffer.UV6Kind
  19403. * * BABYLON.VertexBuffer.ColorKind
  19404. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19405. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19406. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19407. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19408. * @param data defines the data source
  19409. * @param updatable defines if the data must be flagged as updatable (or static)
  19410. * @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
  19411. * @returns the current mesh
  19412. */
  19413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19414. /**
  19415. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19416. * If the mesh has no geometry, it is simply returned as it is.
  19417. * @param kind defines vertex data kind:
  19418. * * BABYLON.VertexBuffer.PositionKind
  19419. * * BABYLON.VertexBuffer.UVKind
  19420. * * BABYLON.VertexBuffer.UV2Kind
  19421. * * BABYLON.VertexBuffer.UV3Kind
  19422. * * BABYLON.VertexBuffer.UV4Kind
  19423. * * BABYLON.VertexBuffer.UV5Kind
  19424. * * BABYLON.VertexBuffer.UV6Kind
  19425. * * BABYLON.VertexBuffer.ColorKind
  19426. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19427. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19428. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19429. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19430. * @param data defines the data source
  19431. * @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
  19432. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19433. * @returns the current mesh
  19434. */
  19435. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19436. /**
  19437. * Sets the mesh indices,
  19438. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19439. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19440. * @param totalVertices Defines the total number of vertices
  19441. * @returns the current mesh
  19442. */
  19443. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19444. /**
  19445. * Gets a boolean indicating if specific vertex data is present
  19446. * @param kind defines the vertex data kind to use
  19447. * @returns true is data kind is present
  19448. */
  19449. isVerticesDataPresent(kind: string): boolean;
  19450. /**
  19451. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19452. * @returns a BoundingInfo
  19453. */
  19454. getBoundingInfo(): BoundingInfo;
  19455. /**
  19456. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19457. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19458. * @returns the current mesh
  19459. */
  19460. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19461. /**
  19462. * Overwrite the current bounding info
  19463. * @param boundingInfo defines the new bounding info
  19464. * @returns the current mesh
  19465. */
  19466. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19467. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19468. readonly useBones: boolean;
  19469. /** @hidden */
  19470. /** @hidden */
  19471. /** @hidden */
  19472. /**
  19473. * Gets the current world matrix
  19474. * @returns a Matrix
  19475. */
  19476. getWorldMatrix(): Matrix;
  19477. /** @hidden */
  19478. /**
  19479. * Perform relative position change from the point of view of behind the front of the mesh.
  19480. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19481. * Supports definition of mesh facing forward or backward
  19482. * @param amountRight defines the distance on the right axis
  19483. * @param amountUp defines the distance on the up axis
  19484. * @param amountForward defines the distance on the forward axis
  19485. * @returns the current mesh
  19486. */
  19487. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19488. /**
  19489. * Calculate relative position change from the point of view of behind the front of the mesh.
  19490. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19491. * Supports definition of mesh facing forward or backward
  19492. * @param amountRight defines the distance on the right axis
  19493. * @param amountUp defines the distance on the up axis
  19494. * @param amountForward defines the distance on the forward axis
  19495. * @returns the new displacement vector
  19496. */
  19497. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19498. /**
  19499. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19500. * Supports definition of mesh facing forward or backward
  19501. * @param flipBack defines the flip
  19502. * @param twirlClockwise defines the twirl
  19503. * @param tiltRight defines the tilt
  19504. * @returns the current mesh
  19505. */
  19506. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19507. /**
  19508. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19509. * Supports definition of mesh facing forward or backward.
  19510. * @param flipBack defines the flip
  19511. * @param twirlClockwise defines the twirl
  19512. * @param tiltRight defines the tilt
  19513. * @returns the new rotation vector
  19514. */
  19515. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19516. /**
  19517. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19518. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19519. * @returns the new bounding vectors
  19520. */
  19521. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  19522. min: Vector3;
  19523. max: Vector3;
  19524. };
  19525. /** @hidden */
  19526. /** @hidden */
  19527. /** @hidden */
  19528. protected _afterComputeWorldMatrix(): void;
  19529. /**
  19530. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19531. * A mesh is in the frustum if its bounding box intersects the frustum
  19532. * @param frustumPlanes defines the frustum to test
  19533. * @returns true if the mesh is in the frustum planes
  19534. */
  19535. isInFrustum(frustumPlanes: Plane[]): boolean;
  19536. /**
  19537. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19538. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19539. * @param frustumPlanes defines the frustum to test
  19540. * @returns true if the mesh is completely in the frustum planes
  19541. */
  19542. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19543. /**
  19544. * True if the mesh intersects another mesh or a SolidParticle object
  19545. * @param mesh defines a target mesh or SolidParticle to test
  19546. * @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)
  19547. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19548. * @returns true if there is an intersection
  19549. */
  19550. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19551. /**
  19552. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19553. * @param point defines the point to test
  19554. * @returns true if there is an intersection
  19555. */
  19556. intersectsPoint(point: Vector3): boolean;
  19557. /**
  19558. * Gets the current physics impostor
  19559. * @see http://doc.babylonjs.com/features/physics_engine
  19560. * @returns a physics impostor or null
  19561. */
  19562. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19563. /**
  19564. * Gets the position of the current mesh in camera space
  19565. * @param camera defines the camera to use
  19566. * @returns a position
  19567. */
  19568. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19569. /**
  19570. * Returns the distance from the mesh to the active camera
  19571. * @param camera defines the camera to use
  19572. * @returns the distance
  19573. */
  19574. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19575. /**
  19576. * Apply a physic impulse to the mesh
  19577. * @param force defines the force to apply
  19578. * @param contactPoint defines where to apply the force
  19579. * @returns the current mesh
  19580. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19581. */
  19582. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19583. /**
  19584. * Creates a physic joint between two meshes
  19585. * @param otherMesh defines the other mesh to use
  19586. * @param pivot1 defines the pivot to use on this mesh
  19587. * @param pivot2 defines the pivot to use on the other mesh
  19588. * @param options defines additional options (can be plugin dependent)
  19589. * @returns the current mesh
  19590. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19591. */
  19592. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19593. /**
  19594. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19596. */
  19597. checkCollisions: boolean;
  19598. /**
  19599. * Gets Collider object used to compute collisions (not physics)
  19600. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19601. */
  19602. readonly collider: Collider;
  19603. /**
  19604. * Move the mesh using collision engine
  19605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19606. * @param displacement defines the requested displacement vector
  19607. * @returns the current mesh
  19608. */
  19609. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19610. private _onCollisionPositionChange;
  19611. /**
  19612. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19613. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19614. * @param maxCapacity defines the maximum size of each block (64 by default)
  19615. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19616. * @returns the new octree
  19617. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19619. */
  19620. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19621. /** @hidden */
  19622. /** @hidden */
  19623. /** @hidden */
  19624. /** @hidden */
  19625. /**
  19626. * Checks if the passed Ray intersects with the mesh
  19627. * @param ray defines the ray to use
  19628. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19629. * @returns the picking info
  19630. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19631. */
  19632. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19633. /**
  19634. * Clones the current mesh
  19635. * @param name defines the mesh name
  19636. * @param newParent defines the new mesh parent
  19637. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19638. * @returns the new mesh
  19639. */
  19640. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19641. /**
  19642. * Disposes all the submeshes of the current meshnp
  19643. * @returns the current mesh
  19644. */
  19645. releaseSubMeshes(): AbstractMesh;
  19646. /**
  19647. * Releases resources associated with this abstract mesh.
  19648. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19649. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19650. */
  19651. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19652. /**
  19653. * Adds the passed mesh as a child to the current mesh
  19654. * @param mesh defines the child mesh
  19655. * @returns the current mesh
  19656. */
  19657. addChild(mesh: AbstractMesh): AbstractMesh;
  19658. /**
  19659. * Removes the passed mesh from the current mesh children list
  19660. * @param mesh defines the child mesh
  19661. * @returns the current mesh
  19662. */
  19663. removeChild(mesh: AbstractMesh): AbstractMesh;
  19664. /** @hidden */
  19665. private _initFacetData();
  19666. /**
  19667. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19668. * This method can be called within the render loop.
  19669. * 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
  19670. * @returns the current mesh
  19671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19672. */
  19673. updateFacetData(): AbstractMesh;
  19674. /**
  19675. * Returns the facetLocalNormals array.
  19676. * The normals are expressed in the mesh local spac
  19677. * @returns an array of Vector3
  19678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19679. */
  19680. getFacetLocalNormals(): Vector3[];
  19681. /**
  19682. * Returns the facetLocalPositions array.
  19683. * The facet positions are expressed in the mesh local space
  19684. * @returns an array of Vector3
  19685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19686. */
  19687. getFacetLocalPositions(): Vector3[];
  19688. /**
  19689. * Returns the facetLocalPartioning array
  19690. * @returns an array of array of numbers
  19691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19692. */
  19693. getFacetLocalPartitioning(): number[][];
  19694. /**
  19695. * Returns the i-th facet position in the world system.
  19696. * This method allocates a new Vector3 per call
  19697. * @param i defines the facet index
  19698. * @returns a new Vector3
  19699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19700. */
  19701. getFacetPosition(i: number): Vector3;
  19702. /**
  19703. * Sets the reference Vector3 with the i-th facet position in the world system
  19704. * @param i defines the facet index
  19705. * @param ref defines the target vector
  19706. * @returns the current mesh
  19707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19708. */
  19709. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19710. /**
  19711. * Returns the i-th facet normal in the world system.
  19712. * This method allocates a new Vector3 per call
  19713. * @param i defines the facet index
  19714. * @returns a new Vector3
  19715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19716. */
  19717. getFacetNormal(i: number): Vector3;
  19718. /**
  19719. * Sets the reference Vector3 with the i-th facet normal in the world system
  19720. * @param i defines the facet index
  19721. * @param ref defines the target vector
  19722. * @returns the current mesh
  19723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19724. */
  19725. getFacetNormalToRef(i: number, ref: Vector3): this;
  19726. /**
  19727. * 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)
  19728. * @param x defines x coordinate
  19729. * @param y defines y coordinate
  19730. * @param z defines z coordinate
  19731. * @returns the array of facet indexes
  19732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19733. */
  19734. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19735. /**
  19736. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19737. * @param projected sets as the (x,y,z) world projection on the facet
  19738. * @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
  19739. * @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
  19740. * @param x defines x coordinate
  19741. * @param y defines y coordinate
  19742. * @param z defines z coordinate
  19743. * @returns the face index if found (or null instead)
  19744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19745. */
  19746. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19747. /**
  19748. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19749. * @param projected sets as the (x,y,z) local projection on the facet
  19750. * @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
  19751. * @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
  19752. * @param x defines x coordinate
  19753. * @param y defines y coordinate
  19754. * @param z defines z coordinate
  19755. * @returns the face index if found (or null instead)
  19756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19757. */
  19758. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19759. /**
  19760. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19761. * @returns the parameters
  19762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19763. */
  19764. getFacetDataParameters(): any;
  19765. /**
  19766. * Disables the feature FacetData and frees the related memory
  19767. * @returns the current mesh
  19768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19769. */
  19770. disableFacetData(): AbstractMesh;
  19771. /**
  19772. * Updates the AbstractMesh indices array
  19773. * @param indices defines the data source
  19774. * @returns the current mesh
  19775. */
  19776. updateIndices(indices: IndicesArray): AbstractMesh;
  19777. /**
  19778. * Creates new normals data for the mesh
  19779. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19780. * @returns the current mesh
  19781. */
  19782. createNormals(updatable: boolean): AbstractMesh;
  19783. /**
  19784. * Align the mesh with a normal
  19785. * @param normal defines the normal to use
  19786. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19787. * @returns the current mesh
  19788. */
  19789. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19790. /** @hidden */
  19791. protected _checkOcclusionQuery(): void;
  19792. }
  19793. }
  19794. declare module BABYLON {
  19795. class Buffer {
  19796. private _engine;
  19797. private _buffer;
  19798. private _data;
  19799. private _updatable;
  19800. private _instanced;
  19801. /**
  19802. * Gets the byte stride.
  19803. */
  19804. readonly byteStride: number;
  19805. /**
  19806. * Constructor
  19807. * @param engine the engine
  19808. * @param data the data to use for this buffer
  19809. * @param updatable whether the data is updatable
  19810. * @param stride the stride (optional)
  19811. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19812. * @param instanced whether the buffer is instanced (optional)
  19813. * @param useBytes set to true if the stride in in bytes (optional)
  19814. */
  19815. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19816. /**
  19817. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19818. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19819. * @param offset defines offset in the buffer (0 by default)
  19820. * @param size defines the size in floats of attributes (position is 3 for instance)
  19821. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19822. * @param instanced defines if the vertex buffer contains indexed data
  19823. * @param useBytes defines if the offset and stride are in bytes
  19824. * @returns the new vertex buffer
  19825. */
  19826. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19827. isUpdatable(): boolean;
  19828. getData(): Nullable<DataArray>;
  19829. getBuffer(): Nullable<WebGLBuffer>;
  19830. /**
  19831. * Gets the stride in float32 units (i.e. byte stride / 4).
  19832. * May not be an integer if the byte stride is not divisible by 4.
  19833. * DEPRECATED. Use byteStride instead.
  19834. * @returns the stride in float32 units
  19835. */
  19836. getStrideSize(): number;
  19837. create(data?: Nullable<DataArray>): void;
  19838. update(data: DataArray): void;
  19839. /**
  19840. * Updates the data directly.
  19841. * @param data the new data
  19842. * @param offset the new offset
  19843. * @param vertexCount the vertex count (optional)
  19844. * @param useBytes set to true if the offset is in bytes
  19845. */
  19846. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19847. dispose(): void;
  19848. }
  19849. }
  19850. declare module BABYLON {
  19851. class CSG {
  19852. private polygons;
  19853. matrix: Matrix;
  19854. position: Vector3;
  19855. rotation: Vector3;
  19856. rotationQuaternion: Nullable<Quaternion>;
  19857. scaling: Vector3;
  19858. static FromMesh(mesh: Mesh): CSG;
  19859. private static FromPolygons(polygons);
  19860. clone(): CSG;
  19861. union(csg: CSG): CSG;
  19862. unionInPlace(csg: CSG): void;
  19863. subtract(csg: CSG): CSG;
  19864. subtractInPlace(csg: CSG): void;
  19865. intersect(csg: CSG): CSG;
  19866. intersectInPlace(csg: CSG): void;
  19867. inverse(): CSG;
  19868. inverseInPlace(): void;
  19869. copyTransformAttributes(csg: CSG): CSG;
  19870. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19871. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19872. }
  19873. }
  19874. declare module BABYLON {
  19875. /**
  19876. * Class used to store geometry data (vertex buffers + index buffer)
  19877. */
  19878. class Geometry implements IGetSetVerticesData {
  19879. /**
  19880. * Gets or sets the unique ID of the geometry
  19881. */
  19882. id: string;
  19883. /**
  19884. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19885. */
  19886. delayLoadState: number;
  19887. /**
  19888. * Gets the file containing the data to load when running in delay load state
  19889. */
  19890. delayLoadingFile: Nullable<string>;
  19891. /**
  19892. * Callback called when the geometry is updated
  19893. */
  19894. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19895. private _scene;
  19896. private _engine;
  19897. private _meshes;
  19898. private _totalVertices;
  19899. private _indices;
  19900. private _vertexBuffers;
  19901. private _isDisposed;
  19902. private _extend;
  19903. private _boundingBias;
  19904. /** @hidden */
  19905. private _indexBuffer;
  19906. private _indexBufferIsUpdatable;
  19907. /** @hidden */
  19908. /** @hidden */
  19909. /** @hidden */
  19910. private _vertexArrayObjects;
  19911. private _updatable;
  19912. /** @hidden */
  19913. /**
  19914. * 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
  19915. */
  19916. /**
  19917. * 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
  19918. */
  19919. boundingBias: Vector2;
  19920. /**
  19921. * Static function used to attach a new empty geometry to a mesh
  19922. * @param mesh defines the mesh to attach the geometry to
  19923. * @returns the new {BABYLON.Geometry}
  19924. */
  19925. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19926. /**
  19927. * Creates a new geometry
  19928. * @param id defines the unique ID
  19929. * @param scene defines the hosting scene
  19930. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19931. * @param updatable defines if geometry must be updatable (false by default)
  19932. * @param mesh defines the mesh that will be associated with the geometry
  19933. */
  19934. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19935. /**
  19936. * Gets the current extend of the geometry
  19937. */
  19938. readonly extend: {
  19939. minimum: Vector3;
  19940. maximum: Vector3;
  19941. };
  19942. /**
  19943. * Gets the hosting scene
  19944. * @returns the hosting {BABYLON.Scene}
  19945. */
  19946. getScene(): Scene;
  19947. /**
  19948. * Gets the hosting engine
  19949. * @returns the hosting {BABYLON.Engine}
  19950. */
  19951. getEngine(): Engine;
  19952. /**
  19953. * Defines if the geometry is ready to use
  19954. * @returns true if the geometry is ready to be used
  19955. */
  19956. isReady(): boolean;
  19957. /**
  19958. * Gets a value indicating that the geometry should not be serialized
  19959. */
  19960. readonly doNotSerialize: boolean;
  19961. /** @hidden */
  19962. /**
  19963. * Affects all gemetry data in one call
  19964. * @param vertexData defines the geometry data
  19965. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19966. */
  19967. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19968. /**
  19969. * Set specific vertex data
  19970. * @param kind defines the data kind (Position, normal, etc...)
  19971. * @param data defines the vertex data to use
  19972. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19973. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19974. */
  19975. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19976. /**
  19977. * Removes a specific vertex data
  19978. * @param kind defines the data kind (Position, normal, etc...)
  19979. */
  19980. removeVerticesData(kind: string): void;
  19981. /**
  19982. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19983. * @param buffer defines the vertex buffer to use
  19984. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19985. */
  19986. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19987. /**
  19988. * Update a specific vertex buffer
  19989. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19990. * It will do nothing if the buffer is not updatable
  19991. * @param kind defines the data kind (Position, normal, etc...)
  19992. * @param data defines the data to use
  19993. * @param offset defines the offset in the target buffer where to store the data
  19994. * @param useBytes set to true if the offset is in bytes
  19995. */
  19996. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19997. /**
  19998. * Update a specific vertex buffer
  19999. * This function will create a new buffer if the current one is not updatable
  20000. * @param kind defines the data kind (Position, normal, etc...)
  20001. * @param data defines the data to use
  20002. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20003. */
  20004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20005. private _updateBoundingInfo(updateExtends, data);
  20006. /** @hidden */
  20007. /**
  20008. * Gets total number of vertices
  20009. * @returns the total number of vertices
  20010. */
  20011. getTotalVertices(): number;
  20012. /**
  20013. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20014. * @param kind defines the data kind (Position, normal, etc...)
  20015. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20017. * @returns a float array containing vertex data
  20018. */
  20019. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20020. /**
  20021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20022. * @param kind defines the data kind (Position, normal, etc...)
  20023. * @returns true if the vertex buffer with the specified kind is updatable
  20024. */
  20025. isVertexBufferUpdatable(kind: string): boolean;
  20026. /**
  20027. * Gets a specific vertex buffer
  20028. * @param kind defines the data kind (Position, normal, etc...)
  20029. * @returns a {BABYLON.VertexBuffer}
  20030. */
  20031. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20032. /**
  20033. * Returns all vertex buffers
  20034. * @return an object holding all vertex buffers indexed by kind
  20035. */
  20036. getVertexBuffers(): Nullable<{
  20037. [key: string]: VertexBuffer;
  20038. }>;
  20039. /**
  20040. * Gets a boolean indicating if specific vertex buffer is present
  20041. * @param kind defines the data kind (Position, normal, etc...)
  20042. * @returns true if data is present
  20043. */
  20044. isVerticesDataPresent(kind: string): boolean;
  20045. /**
  20046. * Gets a list of all attached data kinds (Position, normal, etc...)
  20047. * @returns a list of string containing all kinds
  20048. */
  20049. getVerticesDataKinds(): string[];
  20050. /**
  20051. * Update index buffer
  20052. * @param indices defines the indices to store in the index buffer
  20053. * @param offset defines the offset in the target buffer where to store the data
  20054. */
  20055. updateIndices(indices: IndicesArray, offset?: number): void;
  20056. /**
  20057. * Creates a new index buffer
  20058. * @param indices defines the indices to store in the index buffer
  20059. * @param totalVertices defines the total number of vertices (could be null)
  20060. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20061. */
  20062. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20063. /**
  20064. * Return the total number of indices
  20065. * @returns the total number of indices
  20066. */
  20067. getTotalIndices(): number;
  20068. /**
  20069. * Gets the index buffer array
  20070. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20071. * @returns the index buffer array
  20072. */
  20073. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20074. /**
  20075. * Gets the index buffer
  20076. * @return the index buffer
  20077. */
  20078. getIndexBuffer(): Nullable<WebGLBuffer>;
  20079. /** @hidden */
  20080. /**
  20081. * Release the associated resources for a specific mesh
  20082. * @param mesh defines the source mesh
  20083. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20084. */
  20085. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20086. /**
  20087. * Apply current geometry to a given mesh
  20088. * @param mesh defines the mesh to apply geometry to
  20089. */
  20090. applyToMesh(mesh: Mesh): void;
  20091. private _updateExtend(data?);
  20092. private _applyToMesh(mesh);
  20093. private notifyUpdate(kind?);
  20094. /**
  20095. * Load the geometry if it was flagged as delay loaded
  20096. * @param scene defines the hosting scene
  20097. * @param onLoaded defines a callback called when the geometry is loaded
  20098. */
  20099. load(scene: Scene, onLoaded?: () => void): void;
  20100. private _queueLoad(scene, onLoaded?);
  20101. /**
  20102. * Invert the geometry to move from a right handed system to a left handed one.
  20103. */
  20104. toLeftHanded(): void;
  20105. /** @hidden */
  20106. /** @hidden */
  20107. /**
  20108. * Gets a value indicating if the geometry is disposed
  20109. * @returns true if the geometry was disposed
  20110. */
  20111. isDisposed(): boolean;
  20112. private _disposeVertexArrayObjects();
  20113. /**
  20114. * Free all associated resources
  20115. */
  20116. dispose(): void;
  20117. /**
  20118. * Clone the current geometry into a new geometry
  20119. * @param id defines the unique ID of the new geometry
  20120. * @returns a new geometry object
  20121. */
  20122. copy(id: string): Geometry;
  20123. /**
  20124. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20125. * @return a JSON representation of the current geometry data (without the vertices data)
  20126. */
  20127. serialize(): any;
  20128. private toNumberArray(origin);
  20129. /**
  20130. * Serialize all vertices data into a JSON oject
  20131. * @returns a JSON representation of the current geometry data
  20132. */
  20133. serializeVerticeData(): any;
  20134. /**
  20135. * Extracts a clone of a mesh geometry
  20136. * @param mesh defines the source mesh
  20137. * @param id defines the unique ID of the new geometry object
  20138. * @returns the new geometry object
  20139. */
  20140. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20141. /**
  20142. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20143. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20144. * Be aware Math.random() could cause collisions, but:
  20145. * "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"
  20146. * @returns a string containing a new GUID
  20147. */
  20148. static RandomId(): string;
  20149. /** @hidden */
  20150. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20151. private static _CleanMatricesWeights(parsedGeometry, mesh);
  20152. /**
  20153. * Create a new geometry from persisted data (Using .babylon file format)
  20154. * @param parsedVertexData defines the persisted data
  20155. * @param scene defines the hosting scene
  20156. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20157. * @returns the new geometry object
  20158. */
  20159. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20160. }
  20161. /**
  20162. * Abstract class used to provide common services for all typed geometries
  20163. * @hidden
  20164. */
  20165. class _PrimitiveGeometry extends Geometry {
  20166. private _canBeRegenerated;
  20167. private _beingRegenerated;
  20168. /**
  20169. * Creates a new typed geometry
  20170. * @param id defines the unique ID of the geometry
  20171. * @param scene defines the hosting scene
  20172. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20173. * @param mesh defines the hosting mesh (can be null)
  20174. */
  20175. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20176. /**
  20177. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20178. * @returns true if the geometry can be regenerated
  20179. */
  20180. canBeRegenerated(): boolean;
  20181. /**
  20182. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20183. */
  20184. regenerate(): void;
  20185. /**
  20186. * Clone the geometry
  20187. * @param id defines the unique ID of the new geometry
  20188. * @returns the new geometry
  20189. */
  20190. asNewGeometry(id: string): Geometry;
  20191. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20192. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20193. /** @hidden */
  20194. copy(id: string): Geometry;
  20195. serialize(): any;
  20196. }
  20197. /**
  20198. * Creates a ribbon geometry
  20199. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20200. */
  20201. class RibbonGeometry extends _PrimitiveGeometry {
  20202. /**
  20203. * Defines the array of paths to use
  20204. */
  20205. pathArray: Vector3[][];
  20206. /**
  20207. * Defines if the last and first points of each path in your pathArray must be joined
  20208. */
  20209. closeArray: boolean;
  20210. /**
  20211. * Defines if the last and first points of each path in your pathArray must be joined
  20212. */
  20213. closePath: boolean;
  20214. /**
  20215. * Defines the offset between points
  20216. */
  20217. offset: number;
  20218. /**
  20219. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20220. */
  20221. side: number;
  20222. /**
  20223. * Creates a ribbon geometry
  20224. * @param id defines the unique ID of the geometry
  20225. * @param scene defines the hosting scene
  20226. * @param pathArray defines the array of paths to use
  20227. * @param closeArray defines if the last path and the first path must be joined
  20228. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20229. * @param offset defines the offset between points
  20230. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20231. * @param mesh defines the hosting mesh (can be null)
  20232. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20233. */
  20234. constructor(id: string, scene: Scene,
  20235. /**
  20236. * Defines the array of paths to use
  20237. */
  20238. pathArray: Vector3[][],
  20239. /**
  20240. * Defines if the last and first points of each path in your pathArray must be joined
  20241. */
  20242. closeArray: boolean,
  20243. /**
  20244. * Defines if the last and first points of each path in your pathArray must be joined
  20245. */
  20246. closePath: boolean,
  20247. /**
  20248. * Defines the offset between points
  20249. */
  20250. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20251. /**
  20252. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20253. */
  20254. side?: number);
  20255. /** @hidden */
  20256. copy(id: string): Geometry;
  20257. }
  20258. /**
  20259. * Creates a box geometry
  20260. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20261. */
  20262. class BoxGeometry extends _PrimitiveGeometry {
  20263. /**
  20264. * Defines the zise of the box (width, height and depth are the same)
  20265. */
  20266. size: number;
  20267. /**
  20268. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20269. */
  20270. side: number;
  20271. /**
  20272. * Creates a box geometry
  20273. * @param id defines the unique ID of the geometry
  20274. * @param scene defines the hosting scene
  20275. * @param size defines the zise of the box (width, height and depth are the same)
  20276. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20277. * @param mesh defines the hosting mesh (can be null)
  20278. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20279. */
  20280. constructor(id: string, scene: Scene,
  20281. /**
  20282. * Defines the zise of the box (width, height and depth are the same)
  20283. */
  20284. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20285. /**
  20286. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20287. */
  20288. side?: number);
  20289. copy(id: string): Geometry;
  20290. serialize(): any;
  20291. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20292. }
  20293. /**
  20294. * Creates a sphere geometry
  20295. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20296. */
  20297. class SphereGeometry extends _PrimitiveGeometry {
  20298. /**
  20299. * Defines the number of segments to use to create the sphere
  20300. */
  20301. segments: number;
  20302. /**
  20303. * Defines the diameter of the sphere
  20304. */
  20305. diameter: number;
  20306. /**
  20307. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20308. */
  20309. side: number;
  20310. /**
  20311. * Create a new sphere geometry
  20312. * @param id defines the unique ID of the geometry
  20313. * @param scene defines the hosting scene
  20314. * @param segments defines the number of segments to use to create the sphere
  20315. * @param diameter defines the diameter of the sphere
  20316. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20317. * @param mesh defines the hosting mesh (can be null)
  20318. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20319. */
  20320. constructor(id: string, scene: Scene,
  20321. /**
  20322. * Defines the number of segments to use to create the sphere
  20323. */
  20324. segments: number,
  20325. /**
  20326. * Defines the diameter of the sphere
  20327. */
  20328. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20329. /**
  20330. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20331. */
  20332. side?: number);
  20333. copy(id: string): Geometry;
  20334. serialize(): any;
  20335. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20336. }
  20337. /**
  20338. * Creates a disc geometry
  20339. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20340. */
  20341. class DiscGeometry extends _PrimitiveGeometry {
  20342. /**
  20343. * Defines the radius of the disc
  20344. */
  20345. radius: number;
  20346. /**
  20347. * Defines the tesselation factor to apply to the disc
  20348. */
  20349. tessellation: number;
  20350. /**
  20351. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20352. */
  20353. side: number;
  20354. /**
  20355. * Creates a new disc geometry
  20356. * @param id defines the unique ID of the geometry
  20357. * @param scene defines the hosting scene
  20358. * @param radius defines the radius of the disc
  20359. * @param tessellation defines the tesselation factor to apply to the disc
  20360. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20361. * @param mesh defines the hosting mesh (can be null)
  20362. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20363. */
  20364. constructor(id: string, scene: Scene,
  20365. /**
  20366. * Defines the radius of the disc
  20367. */
  20368. radius: number,
  20369. /**
  20370. * Defines the tesselation factor to apply to the disc
  20371. */
  20372. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20373. /**
  20374. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20375. */
  20376. side?: number);
  20377. copy(id: string): Geometry;
  20378. }
  20379. /**
  20380. * Creates a new cylinder geometry
  20381. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20382. */
  20383. class CylinderGeometry extends _PrimitiveGeometry {
  20384. /**
  20385. * Defines the height of the cylinder
  20386. */
  20387. height: number;
  20388. /**
  20389. * Defines the diameter of the cylinder's top cap
  20390. */
  20391. diameterTop: number;
  20392. /**
  20393. * Defines the diameter of the cylinder's bottom cap
  20394. */
  20395. diameterBottom: number;
  20396. /**
  20397. * Defines the tessellation factor to apply to the cylinder
  20398. */
  20399. tessellation: number;
  20400. /**
  20401. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20402. */
  20403. subdivisions: number;
  20404. /**
  20405. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20406. */
  20407. side: number;
  20408. /**
  20409. * Creates a new cylinder geometry
  20410. * @param id defines the unique ID of the geometry
  20411. * @param scene defines the hosting scene
  20412. * @param height defines the height of the cylinder
  20413. * @param diameterTop defines the diameter of the cylinder's top cap
  20414. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20415. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20416. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20417. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20418. * @param mesh defines the hosting mesh (can be null)
  20419. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20420. */
  20421. constructor(id: string, scene: Scene,
  20422. /**
  20423. * Defines the height of the cylinder
  20424. */
  20425. height: number,
  20426. /**
  20427. * Defines the diameter of the cylinder's top cap
  20428. */
  20429. diameterTop: number,
  20430. /**
  20431. * Defines the diameter of the cylinder's bottom cap
  20432. */
  20433. diameterBottom: number,
  20434. /**
  20435. * Defines the tessellation factor to apply to the cylinder
  20436. */
  20437. tessellation: number,
  20438. /**
  20439. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20440. */
  20441. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20442. /**
  20443. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20444. */
  20445. side?: number);
  20446. copy(id: string): Geometry;
  20447. serialize(): any;
  20448. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20449. }
  20450. /**
  20451. * Creates a new torus geometry
  20452. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20453. */
  20454. class TorusGeometry extends _PrimitiveGeometry {
  20455. /**
  20456. * Defines the diameter of the torus
  20457. */
  20458. diameter: number;
  20459. /**
  20460. * Defines the thickness of the torus (ie. internal diameter)
  20461. */
  20462. thickness: number;
  20463. /**
  20464. * Defines the tesselation factor to apply to the torus
  20465. */
  20466. tessellation: number;
  20467. /**
  20468. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20469. */
  20470. side: number;
  20471. /**
  20472. * Creates a new torus geometry
  20473. * @param id defines the unique ID of the geometry
  20474. * @param scene defines the hosting scene
  20475. * @param diameter defines the diameter of the torus
  20476. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20477. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20478. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20479. * @param mesh defines the hosting mesh (can be null)
  20480. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20481. */
  20482. constructor(id: string, scene: Scene,
  20483. /**
  20484. * Defines the diameter of the torus
  20485. */
  20486. diameter: number,
  20487. /**
  20488. * Defines the thickness of the torus (ie. internal diameter)
  20489. */
  20490. thickness: number,
  20491. /**
  20492. * Defines the tesselation factor to apply to the torus
  20493. */
  20494. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20495. /**
  20496. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20497. */
  20498. side?: number);
  20499. copy(id: string): Geometry;
  20500. serialize(): any;
  20501. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20502. }
  20503. /**
  20504. * Creates a new ground geometry
  20505. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20506. */
  20507. class GroundGeometry extends _PrimitiveGeometry {
  20508. /**
  20509. * Defines the width of the ground
  20510. */
  20511. width: number;
  20512. /**
  20513. * Defines the height of the ground
  20514. */
  20515. height: number;
  20516. /**
  20517. * Defines the subdivisions to apply to the ground
  20518. */
  20519. subdivisions: number;
  20520. /**
  20521. * Creates a new ground geometry
  20522. * @param id defines the unique ID of the geometry
  20523. * @param scene defines the hosting scene
  20524. * @param width defines the width of the ground
  20525. * @param height defines the height of the ground
  20526. * @param subdivisions defines the subdivisions to apply to the ground
  20527. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20528. * @param mesh defines the hosting mesh (can be null)
  20529. */
  20530. constructor(id: string, scene: Scene,
  20531. /**
  20532. * Defines the width of the ground
  20533. */
  20534. width: number,
  20535. /**
  20536. * Defines the height of the ground
  20537. */
  20538. height: number,
  20539. /**
  20540. * Defines the subdivisions to apply to the ground
  20541. */
  20542. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20543. copy(id: string): Geometry;
  20544. serialize(): any;
  20545. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20546. }
  20547. /**
  20548. * Creates a tiled ground geometry
  20549. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20550. */
  20551. class TiledGroundGeometry extends _PrimitiveGeometry {
  20552. /**
  20553. * Defines the minimum value on X axis
  20554. */
  20555. xmin: number;
  20556. /**
  20557. * Defines the minimum value on Z axis
  20558. */
  20559. zmin: number;
  20560. /**
  20561. * Defines the maximum value on X axis
  20562. */
  20563. xmax: number;
  20564. /**
  20565. * Defines the maximum value on Z axis
  20566. */
  20567. zmax: number;
  20568. /**
  20569. * Defines the subdivisions to apply to the ground
  20570. */
  20571. subdivisions: {
  20572. w: number;
  20573. h: number;
  20574. };
  20575. /**
  20576. * Defines the precision to use when computing the tiles
  20577. */
  20578. precision: {
  20579. w: number;
  20580. h: number;
  20581. };
  20582. /**
  20583. * Creates a tiled ground geometry
  20584. * @param id defines the unique ID of the geometry
  20585. * @param scene defines the hosting scene
  20586. * @param xmin defines the minimum value on X axis
  20587. * @param zmin defines the minimum value on Z axis
  20588. * @param xmax defines the maximum value on X axis
  20589. * @param zmax defines the maximum value on Z axis
  20590. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20591. * @param precision defines the precision to use when computing the tiles
  20592. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20593. * @param mesh defines the hosting mesh (can be null)
  20594. */
  20595. constructor(id: string, scene: Scene,
  20596. /**
  20597. * Defines the minimum value on X axis
  20598. */
  20599. xmin: number,
  20600. /**
  20601. * Defines the minimum value on Z axis
  20602. */
  20603. zmin: number,
  20604. /**
  20605. * Defines the maximum value on X axis
  20606. */
  20607. xmax: number,
  20608. /**
  20609. * Defines the maximum value on Z axis
  20610. */
  20611. zmax: number,
  20612. /**
  20613. * Defines the subdivisions to apply to the ground
  20614. */
  20615. subdivisions: {
  20616. w: number;
  20617. h: number;
  20618. },
  20619. /**
  20620. * Defines the precision to use when computing the tiles
  20621. */
  20622. precision: {
  20623. w: number;
  20624. h: number;
  20625. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20626. copy(id: string): Geometry;
  20627. }
  20628. /**
  20629. * Creates a plane geometry
  20630. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20631. */
  20632. class PlaneGeometry extends _PrimitiveGeometry {
  20633. /**
  20634. * Defines the size of the plane (width === height)
  20635. */
  20636. size: number;
  20637. /**
  20638. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20639. */
  20640. side: number;
  20641. /**
  20642. * Creates a plane geometry
  20643. * @param id defines the unique ID of the geometry
  20644. * @param scene defines the hosting scene
  20645. * @param size defines the size of the plane (width === height)
  20646. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20647. * @param mesh defines the hosting mesh (can be null)
  20648. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20649. */
  20650. constructor(id: string, scene: Scene,
  20651. /**
  20652. * Defines the size of the plane (width === height)
  20653. */
  20654. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20655. /**
  20656. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20657. */
  20658. side?: number);
  20659. copy(id: string): Geometry;
  20660. serialize(): any;
  20661. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20662. }
  20663. /**
  20664. * Creates a torus knot geometry
  20665. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20666. */
  20667. class TorusKnotGeometry extends _PrimitiveGeometry {
  20668. /**
  20669. * Defines the radius of the torus knot
  20670. */
  20671. radius: number;
  20672. /**
  20673. * Defines the thickness of the torus knot tube
  20674. */
  20675. tube: number;
  20676. /**
  20677. * Defines the number of radial segments
  20678. */
  20679. radialSegments: number;
  20680. /**
  20681. * Defines the number of tubular segments
  20682. */
  20683. tubularSegments: number;
  20684. /**
  20685. * Defines the first number of windings
  20686. */
  20687. p: number;
  20688. /**
  20689. * Defines the second number of windings
  20690. */
  20691. q: number;
  20692. /**
  20693. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20694. */
  20695. side: number;
  20696. /**
  20697. * Creates a torus knot geometry
  20698. * @param id defines the unique ID of the geometry
  20699. * @param scene defines the hosting scene
  20700. * @param radius defines the radius of the torus knot
  20701. * @param tube defines the thickness of the torus knot tube
  20702. * @param radialSegments defines the number of radial segments
  20703. * @param tubularSegments defines the number of tubular segments
  20704. * @param p defines the first number of windings
  20705. * @param q defines the second number of windings
  20706. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20707. * @param mesh defines the hosting mesh (can be null)
  20708. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20709. */
  20710. constructor(id: string, scene: Scene,
  20711. /**
  20712. * Defines the radius of the torus knot
  20713. */
  20714. radius: number,
  20715. /**
  20716. * Defines the thickness of the torus knot tube
  20717. */
  20718. tube: number,
  20719. /**
  20720. * Defines the number of radial segments
  20721. */
  20722. radialSegments: number,
  20723. /**
  20724. * Defines the number of tubular segments
  20725. */
  20726. tubularSegments: number,
  20727. /**
  20728. * Defines the first number of windings
  20729. */
  20730. p: number,
  20731. /**
  20732. * Defines the second number of windings
  20733. */
  20734. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20735. /**
  20736. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20737. */
  20738. side?: number);
  20739. copy(id: string): Geometry;
  20740. serialize(): any;
  20741. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20742. }
  20743. }
  20744. declare module BABYLON {
  20745. class GroundMesh extends Mesh {
  20746. generateOctree: boolean;
  20747. private _heightQuads;
  20748. constructor(name: string, scene: Scene);
  20749. getClassName(): string;
  20750. readonly subdivisions: number;
  20751. readonly subdivisionsX: number;
  20752. readonly subdivisionsY: number;
  20753. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20754. /**
  20755. * Returns a height (y) value in the Worl system :
  20756. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20757. * Returns the ground y position if (x, z) are outside the ground surface.
  20758. */
  20759. getHeightAtCoordinates(x: number, z: number): number;
  20760. /**
  20761. * Returns a normalized vector (Vector3) orthogonal to the ground
  20762. * at the ground coordinates (x, z) expressed in the World system.
  20763. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20764. */
  20765. getNormalAtCoordinates(x: number, z: number): Vector3;
  20766. /**
  20767. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20768. * at the ground coordinates (x, z) expressed in the World system.
  20769. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20770. * Returns the GroundMesh.
  20771. */
  20772. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20773. /**
  20774. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20775. * if the ground has been updated.
  20776. * This can be used in the render loop.
  20777. * Returns the GroundMesh.
  20778. */
  20779. updateCoordinateHeights(): GroundMesh;
  20780. private _getFacetAt(x, z);
  20781. private _initHeightQuads();
  20782. private _computeHeightQuads();
  20783. serialize(serializationObject: any): void;
  20784. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20785. }
  20786. }
  20787. declare module BABYLON {
  20788. /**
  20789. * Creates an instance based on a source mesh.
  20790. */
  20791. class InstancedMesh extends AbstractMesh {
  20792. private _sourceMesh;
  20793. private _currentLOD;
  20794. constructor(name: string, source: Mesh);
  20795. /**
  20796. * Returns the string "InstancedMesh".
  20797. */
  20798. getClassName(): string;
  20799. readonly receiveShadows: boolean;
  20800. readonly material: Nullable<Material>;
  20801. readonly visibility: number;
  20802. readonly skeleton: Nullable<Skeleton>;
  20803. renderingGroupId: number;
  20804. /**
  20805. * Returns the total number of vertices (integer).
  20806. */
  20807. getTotalVertices(): number;
  20808. readonly sourceMesh: Mesh;
  20809. /**
  20810. * Is this node ready to be used/rendered
  20811. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20812. * @return {boolean} is it ready
  20813. */
  20814. isReady(completeCheck?: boolean): boolean;
  20815. /**
  20816. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20817. */
  20818. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20819. /**
  20820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20822. * The `data` are either a numeric array either a Float32Array.
  20823. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20824. * 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).
  20825. * Note that a new underlying VertexBuffer object is created each call.
  20826. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20827. *
  20828. * Possible `kind` values :
  20829. * - BABYLON.VertexBuffer.PositionKind
  20830. * - BABYLON.VertexBuffer.UVKind
  20831. * - BABYLON.VertexBuffer.UV2Kind
  20832. * - BABYLON.VertexBuffer.UV3Kind
  20833. * - BABYLON.VertexBuffer.UV4Kind
  20834. * - BABYLON.VertexBuffer.UV5Kind
  20835. * - BABYLON.VertexBuffer.UV6Kind
  20836. * - BABYLON.VertexBuffer.ColorKind
  20837. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20838. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20839. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20840. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20841. *
  20842. * Returns the Mesh.
  20843. */
  20844. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20845. /**
  20846. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20847. * If the mesh has no geometry, it is simply returned as it is.
  20848. * The `data` are either a numeric array either a Float32Array.
  20849. * No new underlying VertexBuffer object is created.
  20850. * 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.
  20851. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20852. *
  20853. * Possible `kind` values :
  20854. * - BABYLON.VertexBuffer.PositionKind
  20855. * - BABYLON.VertexBuffer.UVKind
  20856. * - BABYLON.VertexBuffer.UV2Kind
  20857. * - BABYLON.VertexBuffer.UV3Kind
  20858. * - BABYLON.VertexBuffer.UV4Kind
  20859. * - BABYLON.VertexBuffer.UV5Kind
  20860. * - BABYLON.VertexBuffer.UV6Kind
  20861. * - BABYLON.VertexBuffer.ColorKind
  20862. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20863. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20864. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20865. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20866. *
  20867. * Returns the Mesh.
  20868. */
  20869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20870. /**
  20871. * Sets the mesh indices.
  20872. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20873. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20874. * This method creates a new index buffer each call.
  20875. * Returns the Mesh.
  20876. */
  20877. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20878. /**
  20879. * Boolean : True if the mesh owns the requested kind of data.
  20880. */
  20881. isVerticesDataPresent(kind: string): boolean;
  20882. /**
  20883. * Returns an array of indices (IndicesArray).
  20884. */
  20885. getIndices(): Nullable<IndicesArray>;
  20886. protected readonly _positions: Nullable<Vector3[]>;
  20887. /**
  20888. * Sets a new updated BoundingInfo to the mesh.
  20889. * Returns the mesh.
  20890. */
  20891. refreshBoundingInfo(): InstancedMesh;
  20892. /**
  20893. * Returns the current associated LOD AbstractMesh.
  20894. */
  20895. getLOD(camera: Camera): AbstractMesh;
  20896. /**
  20897. * Creates a new InstancedMesh from the current mesh.
  20898. * - name (string) : the cloned mesh name
  20899. * - newParent (optional Node) : the optional Node to parent the clone to.
  20900. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20901. *
  20902. * Returns the clone.
  20903. */
  20904. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20905. /**
  20906. * Disposes the InstancedMesh.
  20907. * Returns nothing.
  20908. */
  20909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20910. }
  20911. }
  20912. declare module BABYLON {
  20913. class LinesMesh extends Mesh {
  20914. useVertexColor: boolean | undefined;
  20915. useVertexAlpha: boolean | undefined;
  20916. color: Color3;
  20917. alpha: number;
  20918. /**
  20919. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20920. * This margin is expressed in world space coordinates, so its value may vary.
  20921. * Default value is 0.1
  20922. * @returns the intersection Threshold value.
  20923. */
  20924. /**
  20925. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20926. * This margin is expressed in world space coordinates, so its value may vary.
  20927. * @param value the new threshold to apply
  20928. */
  20929. intersectionThreshold: number;
  20930. private _intersectionThreshold;
  20931. private _colorShader;
  20932. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20933. /**
  20934. * Returns the string "LineMesh"
  20935. */
  20936. getClassName(): string;
  20937. material: Material;
  20938. readonly checkCollisions: boolean;
  20939. createInstance(name: string): InstancedMesh;
  20940. dispose(doNotRecurse?: boolean): void;
  20941. /**
  20942. * Returns a new LineMesh object cloned from the current one.
  20943. */
  20944. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20945. }
  20946. }
  20947. declare module BABYLON {
  20948. /**
  20949. * @hidden
  20950. **/
  20951. class _InstancesBatch {
  20952. mustReturn: boolean;
  20953. visibleInstances: Nullable<InstancedMesh[]>[];
  20954. renderSelf: boolean[];
  20955. }
  20956. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20957. private static _FRONTSIDE: number;
  20958. private static _BACKSIDE: number;
  20959. private static _DOUBLESIDE: number;
  20960. private static _DEFAULTSIDE: number;
  20961. private static _NO_CAP: number;
  20962. private static _CAP_START: number;
  20963. private static _CAP_END: number;
  20964. private static _CAP_ALL: number;
  20965. /**
  20966. * Mesh side orientation : usually the external or front surface
  20967. */
  20968. static readonly FRONTSIDE: number;
  20969. /**
  20970. * Mesh side orientation : usually the internal or back surface
  20971. */
  20972. static readonly BACKSIDE: number;
  20973. /**
  20974. * Mesh side orientation : both internal and external or front and back surfaces
  20975. */
  20976. static readonly DOUBLESIDE: number;
  20977. /**
  20978. * Mesh side orientation : by default, `FRONTSIDE`
  20979. */
  20980. static readonly DEFAULTSIDE: number;
  20981. /**
  20982. * Mesh cap setting : no cap
  20983. */
  20984. static readonly NO_CAP: number;
  20985. /**
  20986. * Mesh cap setting : one cap at the beginning of the mesh
  20987. */
  20988. static readonly CAP_START: number;
  20989. /**
  20990. * Mesh cap setting : one cap at the end of the mesh
  20991. */
  20992. static readonly CAP_END: number;
  20993. /**
  20994. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20995. */
  20996. static readonly CAP_ALL: number;
  20997. /**
  20998. * An event triggered before rendering the mesh
  20999. */
  21000. onBeforeRenderObservable: Observable<Mesh>;
  21001. /**
  21002. * An event triggered after rendering the mesh
  21003. */
  21004. onAfterRenderObservable: Observable<Mesh>;
  21005. /**
  21006. * An event triggered before drawing the mesh
  21007. */
  21008. onBeforeDrawObservable: Observable<Mesh>;
  21009. private _onBeforeDrawObserver;
  21010. onBeforeDraw: () => void;
  21011. delayLoadState: number;
  21012. instances: InstancedMesh[];
  21013. delayLoadingFile: string;
  21014. private _LODLevels;
  21015. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  21016. private _morphTargetManager;
  21017. morphTargetManager: Nullable<MorphTargetManager>;
  21018. private _renderIdForInstances;
  21019. private _batchCache;
  21020. private _instancesBufferSize;
  21021. private _instancesBuffer;
  21022. private _instancesData;
  21023. private _overridenInstanceCount;
  21024. private _effectiveMaterial;
  21025. private _preActivateId;
  21026. overrideMaterialSideOrientation: Nullable<number>;
  21027. private _areNormalsFrozen;
  21028. private _sourcePositions;
  21029. private _sourceNormals;
  21030. private _source;
  21031. readonly source: Nullable<Mesh>;
  21032. isUnIndexed: boolean;
  21033. /**
  21034. * @constructor
  21035. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21036. * @param {Scene} scene The scene to add this mesh to.
  21037. * @param {Node} parent The parent of this mesh, if it has one
  21038. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21039. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21040. * When false, achieved by calling a clone(), also passing False.
  21041. * This will make creation of children, recursive.
  21042. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21043. */
  21044. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21045. /**
  21046. * Returns the string "Mesh".
  21047. */
  21048. getClassName(): string;
  21049. /**
  21050. * Returns a string.
  21051. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21052. */
  21053. toString(fullDetails?: boolean): string;
  21054. /**
  21055. * True if the mesh has some Levels Of Details (LOD).
  21056. * Returns a boolean.
  21057. */
  21058. readonly hasLODLevels: boolean;
  21059. /**
  21060. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21061. * @returns an array of {BABYLON.MeshLODLevel}
  21062. */
  21063. getLODLevels(): MeshLODLevel[];
  21064. private _sortLODLevels();
  21065. /**
  21066. * Add a mesh as LOD level triggered at the given distance.
  21067. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21068. * @param {number} distance The distance from the center of the object to show this level
  21069. * @param {Mesh} mesh The mesh to be added as LOD level
  21070. * @return {Mesh} This mesh (for chaining)
  21071. */
  21072. addLODLevel(distance: number, mesh: Mesh): Mesh;
  21073. /**
  21074. * Returns the LOD level mesh at the passed distance or null if not found.
  21075. * It is related to the method `addLODLevel(distance, mesh)`.
  21076. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21077. * Returns an object Mesh or `null`.
  21078. */
  21079. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21080. /**
  21081. * Remove a mesh from the LOD array
  21082. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21083. * @param {Mesh} mesh The mesh to be removed.
  21084. * @return {Mesh} This mesh (for chaining)
  21085. */
  21086. removeLODLevel(mesh: Mesh): Mesh;
  21087. /**
  21088. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21089. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21090. */
  21091. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  21092. /**
  21093. * Returns the mesh internal Geometry object.
  21094. */
  21095. readonly geometry: Nullable<Geometry>;
  21096. /**
  21097. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21098. */
  21099. getTotalVertices(): number;
  21100. /**
  21101. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21102. * 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.
  21103. * You can force the copy with forceCopy === true
  21104. * Returns null if the mesh has no geometry or no vertex buffer.
  21105. * Possible `kind` values :
  21106. * - BABYLON.VertexBuffer.PositionKind
  21107. * - BABYLON.VertexBuffer.UVKind
  21108. * - BABYLON.VertexBuffer.UV2Kind
  21109. * - BABYLON.VertexBuffer.UV3Kind
  21110. * - BABYLON.VertexBuffer.UV4Kind
  21111. * - BABYLON.VertexBuffer.UV5Kind
  21112. * - BABYLON.VertexBuffer.UV6Kind
  21113. * - BABYLON.VertexBuffer.ColorKind
  21114. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21115. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21116. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21117. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21118. */
  21119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21120. /**
  21121. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21122. * Returns `null` if the mesh has no geometry.
  21123. * Possible `kind` values :
  21124. * - BABYLON.VertexBuffer.PositionKind
  21125. * - BABYLON.VertexBuffer.UVKind
  21126. * - BABYLON.VertexBuffer.UV2Kind
  21127. * - BABYLON.VertexBuffer.UV3Kind
  21128. * - BABYLON.VertexBuffer.UV4Kind
  21129. * - BABYLON.VertexBuffer.UV5Kind
  21130. * - BABYLON.VertexBuffer.UV6Kind
  21131. * - BABYLON.VertexBuffer.ColorKind
  21132. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21133. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21134. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21135. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21136. */
  21137. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21138. isVerticesDataPresent(kind: string): boolean;
  21139. /**
  21140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21141. * Possible `kind` values :
  21142. * - BABYLON.VertexBuffer.PositionKind
  21143. * - BABYLON.VertexBuffer.UVKind
  21144. * - BABYLON.VertexBuffer.UV2Kind
  21145. * - BABYLON.VertexBuffer.UV3Kind
  21146. * - BABYLON.VertexBuffer.UV4Kind
  21147. * - BABYLON.VertexBuffer.UV5Kind
  21148. * - BABYLON.VertexBuffer.UV6Kind
  21149. * - BABYLON.VertexBuffer.ColorKind
  21150. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21151. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21152. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21153. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21154. */
  21155. isVertexBufferUpdatable(kind: string): boolean;
  21156. /**
  21157. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21158. * Possible `kind` values :
  21159. * - BABYLON.VertexBuffer.PositionKind
  21160. * - BABYLON.VertexBuffer.UVKind
  21161. * - BABYLON.VertexBuffer.UV2Kind
  21162. * - BABYLON.VertexBuffer.UV3Kind
  21163. * - BABYLON.VertexBuffer.UV4Kind
  21164. * - BABYLON.VertexBuffer.UV5Kind
  21165. * - BABYLON.VertexBuffer.UV6Kind
  21166. * - BABYLON.VertexBuffer.ColorKind
  21167. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21168. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21169. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21170. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21171. */
  21172. getVerticesDataKinds(): string[];
  21173. /**
  21174. * Returns a positive integer : the total number of indices in this mesh geometry.
  21175. * Returns zero if the mesh has no geometry.
  21176. */
  21177. getTotalIndices(): number;
  21178. /**
  21179. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21180. * 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.
  21181. * Returns an empty array if the mesh has no geometry.
  21182. */
  21183. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21184. readonly isBlocked: boolean;
  21185. /**
  21186. * Determine if the current mesh is ready to be rendered
  21187. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21188. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21189. * @returns true if all associated assets are ready (material, textures, shaders)
  21190. */
  21191. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21192. /**
  21193. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21194. * This property is pertinent only for updatable parametric shapes.
  21195. */
  21196. readonly areNormalsFrozen: boolean;
  21197. /**
  21198. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21199. * It has no effect at all on other shapes.
  21200. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21201. * Returns the Mesh.
  21202. */
  21203. freezeNormals(): Mesh;
  21204. /**
  21205. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21206. * It has no effect at all on other shapes.
  21207. * It reactivates the mesh normals computation if it was previously frozen.
  21208. * Returns the Mesh.
  21209. */
  21210. unfreezeNormals(): Mesh;
  21211. /**
  21212. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21213. */
  21214. overridenInstanceCount: number;
  21215. /**
  21216. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21217. * This means the mesh underlying bounding box and sphere are recomputed.
  21218. * Returns the Mesh.
  21219. */
  21220. refreshBoundingInfo(): Mesh;
  21221. private _getPositionData(applySkeleton);
  21222. subdivide(count: number): void;
  21223. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21224. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21225. /**
  21226. * Sets the mesh VertexBuffer.
  21227. * Returns the Mesh.
  21228. */
  21229. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21231. /**
  21232. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21233. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21234. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21235. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21236. * Returns the Mesh.
  21237. */
  21238. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21239. /**
  21240. * Creates a un-shared specific occurence of the geometry for the mesh.
  21241. * Returns the Mesh.
  21242. */
  21243. makeGeometryUnique(): Mesh;
  21244. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21245. /**
  21246. * Update the current index buffer
  21247. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21248. * Returns the Mesh.
  21249. */
  21250. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21251. /**
  21252. * Invert the geometry to move from a right handed system to a left handed one.
  21253. * Returns the Mesh.
  21254. */
  21255. toLeftHanded(): Mesh;
  21256. /**
  21257. * Registers for this mesh a javascript function called just before the rendering process.
  21258. * This function is passed the current mesh.
  21259. * Return the Mesh.
  21260. */
  21261. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21262. /**
  21263. * Disposes a previously registered javascript function called before the rendering.
  21264. * This function is passed the current mesh.
  21265. * Returns the Mesh.
  21266. */
  21267. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21268. /**
  21269. * Registers for this mesh a javascript function called just after the rendering is complete.
  21270. * This function is passed the current mesh.
  21271. * Returns the Mesh.
  21272. */
  21273. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21274. /**
  21275. * Disposes a previously registered javascript function called after the rendering.
  21276. * This function is passed the current mesh.
  21277. * Return the Mesh.
  21278. */
  21279. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21280. /**
  21281. * Triggers the draw call for the mesh.
  21282. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21283. * Returns the Mesh.
  21284. */
  21285. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21286. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21287. /**
  21288. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21289. */
  21290. getEmittedParticleSystems(): IParticleSystem[];
  21291. /**
  21292. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21293. */
  21294. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21295. private _queueLoad(scene);
  21296. /**
  21297. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21298. */
  21299. isInFrustum(frustumPlanes: Plane[]): boolean;
  21300. /**
  21301. * Sets the mesh material by the material or multiMaterial `id` property.
  21302. * The material `id` is a string identifying the material or the multiMaterial.
  21303. * This method returns the Mesh.
  21304. */
  21305. setMaterialByID(id: string): Mesh;
  21306. /**
  21307. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21308. */
  21309. getAnimatables(): IAnimatable[];
  21310. /**
  21311. * Modifies the mesh geometry according to the passed transformation matrix.
  21312. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21313. * The mesh normals are modified accordingly the same transformation.
  21314. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21315. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21316. * Returns the Mesh.
  21317. */
  21318. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21319. /**
  21320. * Modifies the mesh geometry according to its own current World Matrix.
  21321. * The mesh World Matrix is then reset.
  21322. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21323. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21324. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21325. * Returns the Mesh.
  21326. */
  21327. bakeCurrentTransformIntoVertices(): Mesh;
  21328. protected readonly _positions: Nullable<Vector3[]>;
  21329. /**
  21330. * Returns a new Mesh object generated from the current mesh properties.
  21331. * This method must not get confused with createInstance().
  21332. * The parameter `name` is a string, the name given to the new mesh.
  21333. * The optional parameter `newParent` can be any Node object (default `null`).
  21334. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21335. * 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.
  21336. */
  21337. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21338. /**
  21339. * Releases resources associated with this mesh.
  21340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21342. */
  21343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21344. /**
  21345. * Modifies the mesh geometry according to a displacement map.
  21346. * 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.
  21347. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21348. * This method returns nothing.
  21349. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21350. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21351. * 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.
  21352. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21353. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21354. *
  21355. * Returns the Mesh.
  21356. */
  21357. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21358. /**
  21359. * Modifies the mesh geometry according to a displacementMap buffer.
  21360. * 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.
  21361. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21362. * This method returns nothing.
  21363. * 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.
  21364. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21365. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21366. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21367. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21368. *
  21369. * Returns the Mesh.
  21370. */
  21371. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21372. /**
  21373. * Modify the mesh to get a flat shading rendering.
  21374. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21375. * This method returns the Mesh.
  21376. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21377. */
  21378. convertToFlatShadedMesh(): Mesh;
  21379. /**
  21380. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21381. * In other words, more vertices, no more indices and a single bigger VBO.
  21382. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21383. * Returns the Mesh.
  21384. */
  21385. convertToUnIndexedMesh(): Mesh;
  21386. /**
  21387. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21388. * This method returns the Mesh.
  21389. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21390. */
  21391. flipFaces(flipNormals?: boolean): Mesh;
  21392. /**
  21393. * Creates a new InstancedMesh object from the mesh model.
  21394. * An instance shares the same properties and the same material than its model.
  21395. * Only these properties of each instance can then be set individually :
  21396. * - position
  21397. * - rotation
  21398. * - rotationQuaternion
  21399. * - setPivotMatrix
  21400. * - scaling
  21401. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21402. * Warning : this method is not supported for Line mesh and LineSystem
  21403. */
  21404. createInstance(name: string): InstancedMesh;
  21405. /**
  21406. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21407. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21408. * This method returns the Mesh.
  21409. */
  21410. synchronizeInstances(): Mesh;
  21411. /**
  21412. * Simplify the mesh according to the given array of settings.
  21413. * Function will return immediately and will simplify async. It returns the Mesh.
  21414. * @param settings a collection of simplification settings.
  21415. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21416. * @param type the type of simplification to run.
  21417. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21418. */
  21419. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21420. /**
  21421. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21422. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21423. * This should be used together with the simplification to avoid disappearing triangles.
  21424. * Returns the Mesh.
  21425. * @param successCallback an optional success callback to be called after the optimization finished.
  21426. */
  21427. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21428. serialize(serializationObject: any): void;
  21429. /**
  21430. * Returns a new Mesh object parsed from the source provided.
  21431. * The parameter `parsedMesh` is the source.
  21432. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21433. */
  21434. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21435. /**
  21436. * Creates a ribbon mesh.
  21437. * Please consider using the same method from the MeshBuilder class instead.
  21438. * 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.
  21439. *
  21440. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21441. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21442. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21443. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21444. * 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.
  21445. * 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.
  21446. * 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
  21447. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21448. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21449. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21450. */
  21451. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21452. /**
  21453. * Creates a plane polygonal mesh. By default, this is a disc.
  21454. * Please consider using the same method from the MeshBuilder class instead.
  21455. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21456. * 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.
  21457. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21458. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21459. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21460. */
  21461. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21462. /**
  21463. * Creates a box mesh.
  21464. * Please consider using the same method from the MeshBuilder class instead.
  21465. * The parameter `size` sets the size (float) of each box side (default 1).
  21466. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21467. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21468. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21469. */
  21470. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21471. /**
  21472. * Creates a sphere mesh.
  21473. * Please consider using the same method from the MeshBuilder class instead.
  21474. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21475. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21476. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21477. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21478. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21479. */
  21480. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21481. /**
  21482. * Creates a cylinder or a cone mesh.
  21483. * Please consider using the same method from the MeshBuilder class instead.
  21484. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21485. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21486. * 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.
  21487. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21488. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21489. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21490. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21491. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21492. */
  21493. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21494. /**
  21495. * Creates a torus mesh.
  21496. * Please consider using the same method from the MeshBuilder class instead.
  21497. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21498. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21499. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21500. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21501. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21502. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21503. */
  21504. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21505. /**
  21506. * Creates a torus knot mesh.
  21507. * Please consider using the same method from the MeshBuilder class instead.
  21508. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21509. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21510. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21511. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21512. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21513. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21514. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21515. */
  21516. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21517. /**
  21518. * Creates a line mesh.
  21519. * Please consider using the same method from the MeshBuilder class instead.
  21520. * 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.
  21521. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21522. * The parameter `points` is an array successive Vector3.
  21523. * 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
  21524. * When updating an instance, remember that only point positions can change, not the number of points.
  21525. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21526. */
  21527. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21528. /**
  21529. * Creates a dashed line mesh.
  21530. * Please consider using the same method from the MeshBuilder class instead.
  21531. * 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.
  21532. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21533. * The parameter `points` is an array successive Vector3.
  21534. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21535. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21536. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21537. * 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
  21538. * When updating an instance, remember that only point positions can change, not the number of points.
  21539. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21540. */
  21541. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21542. /**
  21543. * Creates a polygon mesh.
  21544. * Please consider using the same method from the MeshBuilder class instead.
  21545. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21546. * 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.
  21547. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21548. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21549. * Remember you can only change the shape positions, not their number when updating a polygon.
  21550. */
  21551. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21552. /**
  21553. * Creates an extruded polygon mesh, with depth in the Y direction.
  21554. * Please consider using the same method from the MeshBuilder class instead.
  21555. */
  21556. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21557. /**
  21558. * Creates an extruded shape mesh.
  21559. * 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.
  21560. * Please consider using the same method from the MeshBuilder class instead.
  21561. *
  21562. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21563. * 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
  21564. * extruded along the Z axis.
  21565. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21566. * 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.
  21567. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21568. * 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
  21569. * 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
  21570. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21571. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21572. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21573. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21574. */
  21575. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21576. /**
  21577. * Creates an custom extruded shape mesh.
  21578. * 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.
  21579. * Please consider using the same method from the MeshBuilder class instead.
  21580. *
  21581. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21582. * 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
  21583. * extruded along the Z axis.
  21584. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21585. * 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
  21586. * and the distance of this point from the begining of the path :
  21587. * ```javascript
  21588. * var rotationFunction = function(i, distance) {
  21589. * // do things
  21590. * return rotationValue; }
  21591. * ```
  21592. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21593. * 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
  21594. * and the distance of this point from the begining of the path :
  21595. * ```javascript
  21596. * var scaleFunction = function(i, distance) {
  21597. * // do things
  21598. * return scaleValue;}
  21599. * ```
  21600. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21601. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21602. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21603. * 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
  21604. * 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
  21605. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21606. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21607. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21608. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21609. */
  21610. 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;
  21611. /**
  21612. * Creates lathe mesh.
  21613. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21614. * Please consider using the same method from the MeshBuilder class instead.
  21615. * 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
  21616. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21617. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21618. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21619. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21620. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21622. */
  21623. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21624. /**
  21625. * Creates a plane mesh.
  21626. * Please consider using the same method from the MeshBuilder class instead.
  21627. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21628. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21629. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21630. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21631. */
  21632. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21633. /**
  21634. * Creates a ground mesh.
  21635. * Please consider using the same method from the MeshBuilder class instead.
  21636. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21637. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21638. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21639. */
  21640. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21641. /**
  21642. * Creates a tiled ground mesh.
  21643. * Please consider using the same method from the MeshBuilder class instead.
  21644. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21645. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21646. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21647. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21648. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21649. * numbers of subdivisions on the ground width and height of each tile.
  21650. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21651. */
  21652. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21653. w: number;
  21654. h: number;
  21655. }, precision: {
  21656. w: number;
  21657. h: number;
  21658. }, scene: Scene, updatable?: boolean): Mesh;
  21659. /**
  21660. * Creates a ground mesh from a height map.
  21661. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21662. * Please consider using the same method from the MeshBuilder class instead.
  21663. * The parameter `url` sets the URL of the height map image resource.
  21664. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21665. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21666. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21667. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21668. * 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).
  21669. * This function is passed the newly built mesh :
  21670. * ```javascript
  21671. * function(mesh) { // do things
  21672. * return; }
  21673. * ```
  21674. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21675. */
  21676. 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;
  21677. /**
  21678. * Creates a tube mesh.
  21679. * 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.
  21680. * Please consider using the same method from the MeshBuilder class instead.
  21681. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21682. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21683. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21684. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21685. * 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.
  21686. * It must return a radius value (positive float) :
  21687. * ```javascript
  21688. * var radiusFunction = function(i, distance) {
  21689. * // do things
  21690. * return radius; }
  21691. * ```
  21692. * 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
  21693. * 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
  21694. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21695. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21696. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21697. */
  21698. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21699. (i: number, distance: number): number;
  21700. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21701. /**
  21702. * Creates a polyhedron mesh.
  21703. * Please consider using the same method from the MeshBuilder class instead.
  21704. * 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
  21705. * to choose the wanted type.
  21706. * The parameter `size` (positive float, default 1) sets the polygon size.
  21707. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21708. * 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`.
  21709. * 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
  21710. * 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)`).
  21711. * 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
  21712. * 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.
  21713. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21714. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21715. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21716. */
  21717. static CreatePolyhedron(name: string, options: {
  21718. type?: number;
  21719. size?: number;
  21720. sizeX?: number;
  21721. sizeY?: number;
  21722. sizeZ?: number;
  21723. custom?: any;
  21724. faceUV?: Vector4[];
  21725. faceColors?: Color4[];
  21726. updatable?: boolean;
  21727. sideOrientation?: number;
  21728. }, scene: Scene): Mesh;
  21729. /**
  21730. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21731. * Please consider using the same method from the MeshBuilder class instead.
  21732. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21733. * 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`).
  21734. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21735. * 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.
  21736. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21737. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21738. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21739. */
  21740. static CreateIcoSphere(name: string, options: {
  21741. radius?: number;
  21742. flat?: boolean;
  21743. subdivisions?: number;
  21744. sideOrientation?: number;
  21745. updatable?: boolean;
  21746. }, scene: Scene): Mesh;
  21747. /**
  21748. * Creates a decal mesh.
  21749. * Please consider using the same method from the MeshBuilder class instead.
  21750. * 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.
  21751. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21752. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21753. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21754. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21755. */
  21756. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21757. /**
  21758. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21759. */
  21760. setPositionsForCPUSkinning(): Float32Array;
  21761. /**
  21762. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21763. */
  21764. setNormalsForCPUSkinning(): Float32Array;
  21765. /**
  21766. * Updates the vertex buffer by applying transformation from the bones.
  21767. * Returns the Mesh.
  21768. *
  21769. * @param {skeleton} skeleton to apply
  21770. */
  21771. applySkeleton(skeleton: Skeleton): Mesh;
  21772. /**
  21773. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21774. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21775. */
  21776. static MinMax(meshes: AbstractMesh[]): {
  21777. min: Vector3;
  21778. max: Vector3;
  21779. };
  21780. /**
  21781. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21782. */
  21783. static Center(meshesOrMinMaxVector: {
  21784. min: Vector3;
  21785. max: Vector3;
  21786. } | AbstractMesh[]): Vector3;
  21787. /**
  21788. * Merge the array of meshes into a single mesh for performance reasons.
  21789. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21790. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21791. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21792. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21793. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21794. */
  21795. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21796. }
  21797. }
  21798. declare module BABYLON {
  21799. /**
  21800. * Define an interface for all classes that will get and set the data on vertices
  21801. */
  21802. interface IGetSetVerticesData {
  21803. isVerticesDataPresent(kind: string): boolean;
  21804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21805. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21806. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21808. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21809. }
  21810. /**
  21811. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21812. */
  21813. class VertexData {
  21814. /**
  21815. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21816. */
  21817. positions: Nullable<FloatArray>;
  21818. /**
  21819. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21820. */
  21821. normals: Nullable<FloatArray>;
  21822. /**
  21823. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21824. */
  21825. tangents: Nullable<FloatArray>;
  21826. /**
  21827. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21828. */
  21829. uvs: Nullable<FloatArray>;
  21830. /**
  21831. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21832. */
  21833. uvs2: Nullable<FloatArray>;
  21834. /**
  21835. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21836. */
  21837. uvs3: Nullable<FloatArray>;
  21838. /**
  21839. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21840. */
  21841. uvs4: Nullable<FloatArray>;
  21842. /**
  21843. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21844. */
  21845. uvs5: Nullable<FloatArray>;
  21846. /**
  21847. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21848. */
  21849. uvs6: Nullable<FloatArray>;
  21850. /**
  21851. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21852. */
  21853. colors: Nullable<FloatArray>;
  21854. /**
  21855. * 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).
  21856. */
  21857. matricesIndices: Nullable<FloatArray>;
  21858. /**
  21859. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21860. */
  21861. matricesWeights: Nullable<FloatArray>;
  21862. /**
  21863. * An array extending the number of possible indices
  21864. */
  21865. matricesIndicesExtra: Nullable<FloatArray>;
  21866. /**
  21867. * An array extending the number of possible weights when the number of indices is extended
  21868. */
  21869. matricesWeightsExtra: Nullable<FloatArray>;
  21870. /**
  21871. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21872. */
  21873. indices: Nullable<IndicesArray>;
  21874. /**
  21875. * Uses the passed data array to set the set the values for the specified kind of data
  21876. * @param data a linear array of floating numbers
  21877. * @param kind the type of data that is being set, eg positions, colors etc
  21878. */
  21879. set(data: FloatArray, kind: string): void;
  21880. /**
  21881. * Associates the vertexData to the passed Mesh.
  21882. * Sets it as updatable or not (default `false`)
  21883. * @param mesh the mesh the vertexData is applied to
  21884. * @param updatable when used and having the value true allows new data to update the vertexData
  21885. * @returns the VertexData
  21886. */
  21887. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21888. /**
  21889. * Associates the vertexData to the passed Geometry.
  21890. * Sets it as updatable or not (default `false`)
  21891. * @param geometry the geometry the vertexData is applied to
  21892. * @param updatable when used and having the value true allows new data to update the vertexData
  21893. * @returns VertexData
  21894. */
  21895. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21896. /**
  21897. * Updates the associated mesh
  21898. * @param mesh the mesh to be updated
  21899. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21900. * @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
  21901. * @returns VertexData
  21902. */
  21903. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21904. /**
  21905. * Updates the associated geometry
  21906. * @param geometry the geometry to be updated
  21907. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21908. * @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
  21909. * @returns VertexData.
  21910. */
  21911. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21912. private _applyTo(meshOrGeometry, updatable?);
  21913. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21914. /**
  21915. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21916. * @param matrix the transforming matrix
  21917. * @returns the VertexData
  21918. */
  21919. transform(matrix: Matrix): VertexData;
  21920. /**
  21921. * Merges the passed VertexData into the current one
  21922. * @param other the VertexData to be merged into the current one
  21923. * @returns the modified VertexData
  21924. */
  21925. merge(other: VertexData): VertexData;
  21926. private _mergeElement(source, other);
  21927. private _validate();
  21928. /**
  21929. * Serializes the VertexData
  21930. * @returns a serialized object
  21931. */
  21932. serialize(): any;
  21933. /**
  21934. * Extracts the vertexData from a mesh
  21935. * @param mesh the mesh from which to extract the VertexData
  21936. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21937. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21938. * @returns the object VertexData associated to the passed mesh
  21939. */
  21940. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21941. /**
  21942. * Extracts the vertexData from the geometry
  21943. * @param geometry the geometry from which to extract the VertexData
  21944. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21945. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21946. * @returns the object VertexData associated to the passed mesh
  21947. */
  21948. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21949. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21950. /**
  21951. * Creates the VertexData for a Ribbon
  21952. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21953. * * pathArray array of paths, each of which an array of successive Vector3
  21954. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21955. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21956. * * 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
  21957. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21958. * * 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)
  21959. * * 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)
  21960. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21961. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21962. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21963. * @returns the VertexData of the ribbon
  21964. */
  21965. static CreateRibbon(options: {
  21966. pathArray: Vector3[][];
  21967. closeArray?: boolean;
  21968. closePath?: boolean;
  21969. offset?: number;
  21970. sideOrientation?: number;
  21971. frontUVs?: Vector4;
  21972. backUVs?: Vector4;
  21973. invertUV?: boolean;
  21974. uvs?: Vector2[];
  21975. colors?: Color4[];
  21976. }): VertexData;
  21977. /**
  21978. * Creates the VertexData for a box
  21979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21980. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21981. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21982. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21983. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21984. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21985. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21986. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21987. * * 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)
  21988. * * 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)
  21989. * @returns the VertexData of the box
  21990. */
  21991. static CreateBox(options: {
  21992. size?: number;
  21993. width?: number;
  21994. height?: number;
  21995. depth?: number;
  21996. faceUV?: Vector4[];
  21997. faceColors?: Color4[];
  21998. sideOrientation?: number;
  21999. frontUVs?: Vector4;
  22000. backUVs?: Vector4;
  22001. }): VertexData;
  22002. /**
  22003. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22005. * * segments sets the number of horizontal strips optional, default 32
  22006. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22007. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22008. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22009. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22010. * * 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
  22011. * * 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
  22012. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22013. * * 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)
  22014. * * 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)
  22015. * @returns the VertexData of the ellipsoid
  22016. */
  22017. static CreateSphere(options: {
  22018. segments?: number;
  22019. diameter?: number;
  22020. diameterX?: number;
  22021. diameterY?: number;
  22022. diameterZ?: number;
  22023. arc?: number;
  22024. slice?: number;
  22025. sideOrientation?: number;
  22026. frontUVs?: Vector4;
  22027. backUVs?: Vector4;
  22028. }): VertexData;
  22029. /**
  22030. * Creates the VertexData for a cylinder, cone or prism
  22031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22032. * * height sets the height (y direction) of the cylinder, optional, default 2
  22033. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22034. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22035. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22036. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22037. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22038. * * 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
  22039. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22041. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22042. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22043. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22044. * * 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)
  22045. * * 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)
  22046. * @returns the VertexData of the cylinder, cone or prism
  22047. */
  22048. static CreateCylinder(options: {
  22049. height?: number;
  22050. diameterTop?: number;
  22051. diameterBottom?: number;
  22052. diameter?: number;
  22053. tessellation?: number;
  22054. subdivisions?: number;
  22055. arc?: number;
  22056. faceColors?: Color4[];
  22057. faceUV?: Vector4[];
  22058. hasRings?: boolean;
  22059. enclose?: boolean;
  22060. sideOrientation?: number;
  22061. frontUVs?: Vector4;
  22062. backUVs?: Vector4;
  22063. }): VertexData;
  22064. /**
  22065. * Creates the VertexData for a torus
  22066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22067. * * diameter the diameter of the torus, optional default 1
  22068. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22070. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22071. * * 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)
  22072. * * 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)
  22073. * @returns the VertexData of the torus
  22074. */
  22075. static CreateTorus(options: {
  22076. diameter?: number;
  22077. thickness?: number;
  22078. tessellation?: number;
  22079. sideOrientation?: number;
  22080. frontUVs?: Vector4;
  22081. backUVs?: Vector4;
  22082. }): VertexData;
  22083. /**
  22084. * Creates the VertexData of the LineSystem
  22085. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22086. * - lines an array of lines, each line being an array of successive Vector3
  22087. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22088. * @returns the VertexData of the LineSystem
  22089. */
  22090. static CreateLineSystem(options: {
  22091. lines: Vector3[][];
  22092. colors?: Nullable<Color4[][]>;
  22093. }): VertexData;
  22094. /**
  22095. * Create the VertexData for a DashedLines
  22096. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22097. * - points an array successive Vector3
  22098. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22099. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22100. * - dashNb the intended total number of dashes, optional, default 200
  22101. * @returns the VertexData for the DashedLines
  22102. */
  22103. static CreateDashedLines(options: {
  22104. points: Vector3[];
  22105. dashSize?: number;
  22106. gapSize?: number;
  22107. dashNb?: number;
  22108. }): VertexData;
  22109. /**
  22110. * Creates the VertexData for a Ground
  22111. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22112. * - width the width (x direction) of the ground, optional, default 1
  22113. * - height the height (z direction) of the ground, optional, default 1
  22114. * - subdivisions the number of subdivisions per side, optional, default 1
  22115. * @returns the VertexData of the Ground
  22116. */
  22117. static CreateGround(options: {
  22118. width?: number;
  22119. height?: number;
  22120. subdivisions?: number;
  22121. subdivisionsX?: number;
  22122. subdivisionsY?: number;
  22123. }): VertexData;
  22124. /**
  22125. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22126. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22127. * * xmin the ground minimum X coordinate, optional, default -1
  22128. * * zmin the ground minimum Z coordinate, optional, default -1
  22129. * * xmax the ground maximum X coordinate, optional, default 1
  22130. * * zmax the ground maximum Z coordinate, optional, default 1
  22131. * * 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}
  22132. * * 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}
  22133. * @returns the VertexData of the TiledGround
  22134. */
  22135. static CreateTiledGround(options: {
  22136. xmin: number;
  22137. zmin: number;
  22138. xmax: number;
  22139. zmax: number;
  22140. subdivisions?: {
  22141. w: number;
  22142. h: number;
  22143. };
  22144. precision?: {
  22145. w: number;
  22146. h: number;
  22147. };
  22148. }): VertexData;
  22149. /**
  22150. * Creates the VertexData of the Ground designed from a heightmap
  22151. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22152. * * width the width (x direction) of the ground
  22153. * * height the height (z direction) of the ground
  22154. * * subdivisions the number of subdivisions per side
  22155. * * minHeight the minimum altitude on the ground, optional, default 0
  22156. * * maxHeight the maximum altitude on the ground, optional default 1
  22157. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22158. * * buffer the array holding the image color data
  22159. * * bufferWidth the width of image
  22160. * * bufferHeight the height of image
  22161. * @returns the VertexData of the Ground designed from a heightmap
  22162. */
  22163. static CreateGroundFromHeightMap(options: {
  22164. width: number;
  22165. height: number;
  22166. subdivisions: number;
  22167. minHeight: number;
  22168. maxHeight: number;
  22169. colorFilter: Color3;
  22170. buffer: Uint8Array;
  22171. bufferWidth: number;
  22172. bufferHeight: number;
  22173. }): VertexData;
  22174. /**
  22175. * Creates the VertexData for a Plane
  22176. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22177. * * size sets the width and height of the plane to the value of size, optional default 1
  22178. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22179. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22180. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22181. * * 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)
  22182. * * 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)
  22183. * @returns the VertexData of the box
  22184. */
  22185. static CreatePlane(options: {
  22186. size?: number;
  22187. width?: number;
  22188. height?: number;
  22189. sideOrientation?: number;
  22190. frontUVs?: Vector4;
  22191. backUVs?: Vector4;
  22192. }): VertexData;
  22193. /**
  22194. * Creates the VertexData of the Disc or regular Polygon
  22195. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22196. * * radius the radius of the disc, optional default 0.5
  22197. * * tessellation the number of polygon sides, optional, default 64
  22198. * * 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
  22199. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22200. * * 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)
  22201. * * 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)
  22202. * @returns the VertexData of the box
  22203. */
  22204. static CreateDisc(options: {
  22205. radius?: number;
  22206. tessellation?: number;
  22207. arc?: number;
  22208. sideOrientation?: number;
  22209. frontUVs?: Vector4;
  22210. backUVs?: Vector4;
  22211. }): VertexData;
  22212. /**
  22213. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22214. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22215. * @param polygon a mesh built from polygonTriangulation.build()
  22216. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22217. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22218. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22219. * @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)
  22220. * @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)
  22221. * @returns the VertexData of the Polygon
  22222. */
  22223. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22224. /**
  22225. * Creates the VertexData of the IcoSphere
  22226. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22227. * * radius the radius of the IcoSphere, optional default 1
  22228. * * radiusX allows stretching in the x direction, optional, default radius
  22229. * * radiusY allows stretching in the y direction, optional, default radius
  22230. * * radiusZ allows stretching in the z direction, optional, default radius
  22231. * * flat when true creates a flat shaded mesh, optional, default true
  22232. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22233. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22234. * * 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)
  22235. * * 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)
  22236. * @returns the VertexData of the IcoSphere
  22237. */
  22238. static CreateIcoSphere(options: {
  22239. radius?: number;
  22240. radiusX?: number;
  22241. radiusY?: number;
  22242. radiusZ?: number;
  22243. flat?: boolean;
  22244. subdivisions?: number;
  22245. sideOrientation?: number;
  22246. frontUVs?: Vector4;
  22247. backUVs?: Vector4;
  22248. }): VertexData;
  22249. /**
  22250. * Creates the VertexData for a Polyhedron
  22251. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22252. * * type provided types are:
  22253. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22254. * * 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)
  22255. * * size the size of the IcoSphere, optional default 1
  22256. * * sizeX allows stretching in the x direction, optional, default size
  22257. * * sizeY allows stretching in the y direction, optional, default size
  22258. * * sizeZ allows stretching in the z direction, optional, default size
  22259. * * 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
  22260. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22261. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22262. * * flat when true creates a flat shaded mesh, optional, default true
  22263. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22264. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22265. * * 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)
  22266. * * 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)
  22267. * @returns the VertexData of the Polyhedron
  22268. */
  22269. static CreatePolyhedron(options: {
  22270. type?: number;
  22271. size?: number;
  22272. sizeX?: number;
  22273. sizeY?: number;
  22274. sizeZ?: number;
  22275. custom?: any;
  22276. faceUV?: Vector4[];
  22277. faceColors?: Color4[];
  22278. flat?: boolean;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. }): VertexData;
  22283. /**
  22284. * Creates the VertexData for a TorusKnot
  22285. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22286. * * radius the radius of the torus knot, optional, default 2
  22287. * * tube the thickness of the tube, optional, default 0.5
  22288. * * radialSegments the number of sides on each tube segments, optional, default 32
  22289. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22290. * * p the number of windings around the z axis, optional, default 2
  22291. * * q the number of windings around the x axis, optional, default 3
  22292. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22293. * * 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)
  22294. * * 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)
  22295. * @returns the VertexData of the Torus Knot
  22296. */
  22297. static CreateTorusKnot(options: {
  22298. radius?: number;
  22299. tube?: number;
  22300. radialSegments?: number;
  22301. tubularSegments?: number;
  22302. p?: number;
  22303. q?: number;
  22304. sideOrientation?: number;
  22305. frontUVs?: Vector4;
  22306. backUVs?: Vector4;
  22307. }): VertexData;
  22308. /**
  22309. * Compute normals for given positions and indices
  22310. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22311. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22312. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22313. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22314. * * facetNormals : optional array of facet normals (vector3)
  22315. * * facetPositions : optional array of facet positions (vector3)
  22316. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22317. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22318. * * bInfo : optional bounding info, required for facetPartitioning computation
  22319. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22320. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22321. * * useRightHandedSystem: optional boolean to for right handed system computation
  22322. * * depthSort : optional boolean to enable the facet depth sort computation
  22323. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22324. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22325. */
  22326. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22327. facetNormals?: any;
  22328. facetPositions?: any;
  22329. facetPartitioning?: any;
  22330. ratio?: number;
  22331. bInfo?: any;
  22332. bbSize?: Vector3;
  22333. subDiv?: any;
  22334. useRightHandedSystem?: boolean;
  22335. depthSort?: boolean;
  22336. distanceTo?: Vector3;
  22337. depthSortedFacets?: any;
  22338. }): void;
  22339. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22340. /**
  22341. * Applies VertexData created from the imported parameters to the geometry
  22342. * @param parsedVertexData the parsed data from an imported file
  22343. * @param geometry the geometry to apply the VertexData to
  22344. */
  22345. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22346. }
  22347. }
  22348. declare module BABYLON {
  22349. /**
  22350. * Class containing static functions to help procedurally build meshes
  22351. */
  22352. class MeshBuilder {
  22353. private static updateSideOrientation(orientation?);
  22354. /**
  22355. * Creates a box mesh
  22356. * * The parameter `size` sets the size (float) of each box side (default 1)
  22357. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22358. * * 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)
  22359. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22361. * * 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
  22362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22363. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22364. * @param name defines the name of the mesh
  22365. * @param options defines the options used to create the mesh
  22366. * @param scene defines the hosting scene
  22367. * @returns the box mesh
  22368. */
  22369. static CreateBox(name: string, options: {
  22370. size?: number;
  22371. width?: number;
  22372. height?: number;
  22373. depth?: number;
  22374. faceUV?: Vector4[];
  22375. faceColors?: Color4[];
  22376. sideOrientation?: number;
  22377. frontUVs?: Vector4;
  22378. backUVs?: Vector4;
  22379. updatable?: boolean;
  22380. }, scene?: Nullable<Scene>): Mesh;
  22381. /**
  22382. * Creates a sphere mesh
  22383. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22384. * * 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`)
  22385. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22386. * * 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
  22387. * * 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)
  22388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22389. * * 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
  22390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22391. * @param name defines the name of the mesh
  22392. * @param options defines the options used to create the mesh
  22393. * @param scene defines the hosting scene
  22394. * @returns the sphere mesh
  22395. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22396. */
  22397. static CreateSphere(name: string, options: {
  22398. segments?: number;
  22399. diameter?: number;
  22400. diameterX?: number;
  22401. diameterY?: number;
  22402. diameterZ?: number;
  22403. arc?: number;
  22404. slice?: number;
  22405. sideOrientation?: number;
  22406. frontUVs?: Vector4;
  22407. backUVs?: Vector4;
  22408. updatable?: boolean;
  22409. }, scene: any): Mesh;
  22410. /**
  22411. * Creates a plane polygonal mesh. By default, this is a disc
  22412. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22413. * * 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
  22414. * * 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
  22415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22416. * * 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
  22417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22418. * @param name defines the name of the mesh
  22419. * @param options defines the options used to create the mesh
  22420. * @param scene defines the hosting scene
  22421. * @returns the plane polygonal mesh
  22422. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22423. */
  22424. static CreateDisc(name: string, options: {
  22425. radius?: number;
  22426. tessellation?: number;
  22427. arc?: number;
  22428. updatable?: boolean;
  22429. sideOrientation?: number;
  22430. frontUVs?: Vector4;
  22431. backUVs?: Vector4;
  22432. }, scene?: Nullable<Scene>): Mesh;
  22433. /**
  22434. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22435. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22436. * * 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`)
  22437. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22438. * * 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
  22439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22440. * * 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
  22441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22442. * @param name defines the name of the mesh
  22443. * @param options defines the options used to create the mesh
  22444. * @param scene defines the hosting scene
  22445. * @returns the icosahedron mesh
  22446. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22447. */
  22448. static CreateIcoSphere(name: string, options: {
  22449. radius?: number;
  22450. radiusX?: number;
  22451. radiusY?: number;
  22452. radiusZ?: number;
  22453. flat?: boolean;
  22454. subdivisions?: number;
  22455. sideOrientation?: number;
  22456. frontUVs?: Vector4;
  22457. backUVs?: Vector4;
  22458. updatable?: boolean;
  22459. }, scene: Scene): Mesh;
  22460. /**
  22461. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22462. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22463. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22464. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22465. * * 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
  22466. * * 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
  22467. * * 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
  22468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22469. * * 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
  22470. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22471. * * 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
  22472. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22473. * * 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
  22474. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22476. * @param name defines the name of the mesh
  22477. * @param options defines the options used to create the mesh
  22478. * @param scene defines the hosting scene
  22479. * @returns the ribbon mesh
  22480. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22481. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22482. */
  22483. static CreateRibbon(name: string, options: {
  22484. pathArray: Vector3[][];
  22485. closeArray?: boolean;
  22486. closePath?: boolean;
  22487. offset?: number;
  22488. updatable?: boolean;
  22489. sideOrientation?: number;
  22490. frontUVs?: Vector4;
  22491. backUVs?: Vector4;
  22492. instance?: Mesh;
  22493. invertUV?: boolean;
  22494. uvs?: Vector2[];
  22495. colors?: Color4[];
  22496. }, scene?: Nullable<Scene>): Mesh;
  22497. /**
  22498. * Creates a cylinder or a cone mesh
  22499. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22500. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22501. * * 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.
  22502. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22503. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22504. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22505. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22506. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22507. * * 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).
  22508. * * 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
  22509. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22510. * * 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
  22511. * * 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.
  22512. * * If `enclose` is false, a ring surface is one element.
  22513. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22514. * * 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
  22515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22516. * * 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
  22517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22518. * @param name defines the name of the mesh
  22519. * @param options defines the options used to create the mesh
  22520. * @param scene defines the hosting scene
  22521. * @returns the cylinder mesh
  22522. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22523. */
  22524. static CreateCylinder(name: string, options: {
  22525. height?: number;
  22526. diameterTop?: number;
  22527. diameterBottom?: number;
  22528. diameter?: number;
  22529. tessellation?: number;
  22530. subdivisions?: number;
  22531. arc?: number;
  22532. faceColors?: Color4[];
  22533. faceUV?: Vector4[];
  22534. updatable?: boolean;
  22535. hasRings?: boolean;
  22536. enclose?: boolean;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }, scene: any): Mesh;
  22541. /**
  22542. * Creates a torus mesh
  22543. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22544. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22545. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22547. * * 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
  22548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22549. * @param name defines the name of the mesh
  22550. * @param options defines the options used to create the mesh
  22551. * @param scene defines the hosting scene
  22552. * @returns the torus mesh
  22553. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22554. */
  22555. static CreateTorus(name: string, options: {
  22556. diameter?: number;
  22557. thickness?: number;
  22558. tessellation?: number;
  22559. updatable?: boolean;
  22560. sideOrientation?: number;
  22561. frontUVs?: Vector4;
  22562. backUVs?: Vector4;
  22563. }, scene: any): Mesh;
  22564. /**
  22565. * Creates a torus knot mesh
  22566. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22567. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22568. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22569. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22571. * * 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
  22572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22573. * @param name defines the name of the mesh
  22574. * @param options defines the options used to create the mesh
  22575. * @param scene defines the hosting scene
  22576. * @returns the torus knot mesh
  22577. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22578. */
  22579. static CreateTorusKnot(name: string, options: {
  22580. radius?: number;
  22581. tube?: number;
  22582. radialSegments?: number;
  22583. tubularSegments?: number;
  22584. p?: number;
  22585. q?: number;
  22586. updatable?: boolean;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. }, scene: any): Mesh;
  22591. /**
  22592. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22593. * * 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
  22594. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22595. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22596. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22597. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22598. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22599. * * 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
  22600. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22602. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22603. * @param name defines the name of the new line system
  22604. * @param options defines the options used to create the line system
  22605. * @param scene defines the hosting scene
  22606. * @returns a new line system mesh
  22607. */
  22608. static CreateLineSystem(name: string, options: {
  22609. lines: Vector3[][];
  22610. updatable?: boolean;
  22611. instance?: Nullable<LinesMesh>;
  22612. colors?: Nullable<Color4[][]>;
  22613. useVertexAlpha?: boolean;
  22614. }, scene: Nullable<Scene>): LinesMesh;
  22615. /**
  22616. * Creates a line mesh
  22617. * 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
  22618. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22619. * * The parameter `points` is an array successive Vector3
  22620. * * 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
  22621. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22622. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22623. * * When updating an instance, remember that only point positions can change, not the number of points
  22624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22625. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22626. * @param name defines the name of the new line system
  22627. * @param options defines the options used to create the line system
  22628. * @param scene defines the hosting scene
  22629. * @returns a new line mesh
  22630. */
  22631. static CreateLines(name: string, options: {
  22632. points: Vector3[];
  22633. updatable?: boolean;
  22634. instance?: Nullable<LinesMesh>;
  22635. colors?: Color4[];
  22636. useVertexAlpha?: boolean;
  22637. }, scene?: Nullable<Scene>): LinesMesh;
  22638. /**
  22639. * Creates a dashed line mesh
  22640. * * 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
  22641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22642. * * The parameter `points` is an array successive Vector3
  22643. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22644. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22645. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22646. * * 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
  22647. * * When updating an instance, remember that only point positions can change, not the number of points
  22648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22649. * @param name defines the name of the mesh
  22650. * @param options defines the options used to create the mesh
  22651. * @param scene defines the hosting scene
  22652. * @returns the dashed line mesh
  22653. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22654. */
  22655. static CreateDashedLines(name: string, options: {
  22656. points: Vector3[];
  22657. dashSize?: number;
  22658. gapSize?: number;
  22659. dashNb?: number;
  22660. updatable?: boolean;
  22661. instance?: LinesMesh;
  22662. }, scene?: Nullable<Scene>): LinesMesh;
  22663. /**
  22664. * 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.
  22665. * * 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.
  22666. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22667. * * 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.
  22668. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22669. * * 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
  22670. * * 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
  22671. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22673. * * 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
  22674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22676. * @param name defines the name of the mesh
  22677. * @param options defines the options used to create the mesh
  22678. * @param scene defines the hosting scene
  22679. * @returns the extruded shape mesh
  22680. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22681. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22682. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22683. */
  22684. static ExtrudeShape(name: string, options: {
  22685. shape: Vector3[];
  22686. path: Vector3[];
  22687. scale?: number;
  22688. rotation?: number;
  22689. cap?: number;
  22690. updatable?: boolean;
  22691. sideOrientation?: number;
  22692. frontUVs?: Vector4;
  22693. backUVs?: Vector4;
  22694. instance?: Mesh;
  22695. invertUV?: boolean;
  22696. }, scene?: Nullable<Scene>): Mesh;
  22697. /**
  22698. * Creates an custom extruded shape mesh.
  22699. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22700. * * 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.
  22701. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22702. * * 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
  22703. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22704. * * 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
  22705. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22706. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22707. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22708. * * 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
  22709. * * 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
  22710. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22712. * * 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
  22713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22715. * @param name defines the name of the mesh
  22716. * @param options defines the options used to create the mesh
  22717. * @param scene defines the hosting scene
  22718. * @returns the custom extruded shape mesh
  22719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22720. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22721. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22722. */
  22723. static ExtrudeShapeCustom(name: string, options: {
  22724. shape: Vector3[];
  22725. path: Vector3[];
  22726. scaleFunction?: any;
  22727. rotationFunction?: any;
  22728. ribbonCloseArray?: boolean;
  22729. ribbonClosePath?: boolean;
  22730. cap?: number;
  22731. updatable?: boolean;
  22732. sideOrientation?: number;
  22733. frontUVs?: Vector4;
  22734. backUVs?: Vector4;
  22735. instance?: Mesh;
  22736. invertUV?: boolean;
  22737. }, scene: Scene): Mesh;
  22738. /**
  22739. * Creates lathe mesh.
  22740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22741. * * 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
  22742. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22743. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22744. * * 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
  22745. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22746. * * 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
  22747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22748. * * 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
  22749. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22751. * @param name defines the name of the mesh
  22752. * @param options defines the options used to create the mesh
  22753. * @param scene defines the hosting scene
  22754. * @returns the lathe mesh
  22755. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22756. */
  22757. static CreateLathe(name: string, options: {
  22758. shape: Vector3[];
  22759. radius?: number;
  22760. tessellation?: number;
  22761. arc?: number;
  22762. closed?: boolean;
  22763. updatable?: boolean;
  22764. sideOrientation?: number;
  22765. frontUVs?: Vector4;
  22766. backUVs?: Vector4;
  22767. cap?: number;
  22768. invertUV?: boolean;
  22769. }, scene: Scene): Mesh;
  22770. /**
  22771. * Creates a plane mesh
  22772. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22773. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22774. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22776. * * 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
  22777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22778. * @param name defines the name of the mesh
  22779. * @param options defines the options used to create the mesh
  22780. * @param scene defines the hosting scene
  22781. * @returns the plane mesh
  22782. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22783. */
  22784. static CreatePlane(name: string, options: {
  22785. size?: number;
  22786. width?: number;
  22787. height?: number;
  22788. sideOrientation?: number;
  22789. frontUVs?: Vector4;
  22790. backUVs?: Vector4;
  22791. updatable?: boolean;
  22792. sourcePlane?: Plane;
  22793. }, scene: Scene): Mesh;
  22794. /**
  22795. * Creates a ground mesh
  22796. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22797. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22799. * @param name defines the name of the mesh
  22800. * @param options defines the options used to create the mesh
  22801. * @param scene defines the hosting scene
  22802. * @returns the ground mesh
  22803. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22804. */
  22805. static CreateGround(name: string, options: {
  22806. width?: number;
  22807. height?: number;
  22808. subdivisions?: number;
  22809. subdivisionsX?: number;
  22810. subdivisionsY?: number;
  22811. updatable?: boolean;
  22812. }, scene: any): Mesh;
  22813. /**
  22814. * Creates a tiled ground mesh
  22815. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22816. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22817. * * 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
  22818. * * 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
  22819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22820. * @param name defines the name of the mesh
  22821. * @param options defines the options used to create the mesh
  22822. * @param scene defines the hosting scene
  22823. * @returns the tiled ground mesh
  22824. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22825. */
  22826. static CreateTiledGround(name: string, options: {
  22827. xmin: number;
  22828. zmin: number;
  22829. xmax: number;
  22830. zmax: number;
  22831. subdivisions?: {
  22832. w: number;
  22833. h: number;
  22834. };
  22835. precision?: {
  22836. w: number;
  22837. h: number;
  22838. };
  22839. updatable?: boolean;
  22840. }, scene: Scene): Mesh;
  22841. /**
  22842. * Creates a ground mesh from a height map
  22843. * * The parameter `url` sets the URL of the height map image resource.
  22844. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22845. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22846. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22847. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22848. * * 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.
  22849. * * 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).
  22850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22851. * @param name defines the name of the mesh
  22852. * @param url defines the url to the height map
  22853. * @param options defines the options used to create the mesh
  22854. * @param scene defines the hosting scene
  22855. * @returns the ground mesh
  22856. * @see http://doc.babylonjs.com/babylon101/height_map
  22857. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22858. */
  22859. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22860. width?: number;
  22861. height?: number;
  22862. subdivisions?: number;
  22863. minHeight?: number;
  22864. maxHeight?: number;
  22865. colorFilter?: Color3;
  22866. updatable?: boolean;
  22867. onReady?: (mesh: GroundMesh) => void;
  22868. }, scene: Scene): GroundMesh;
  22869. /**
  22870. * Creates a polygon mesh
  22871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22872. * * 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
  22873. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22875. * * 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)
  22876. * * Remember you can only change the shape positions, not their number when updating a polygon
  22877. * @param name defines the name of the mesh
  22878. * @param options defines the options used to create the mesh
  22879. * @param scene defines the hosting scene
  22880. * @returns the polygon mesh
  22881. */
  22882. static CreatePolygon(name: string, options: {
  22883. shape: Vector3[];
  22884. holes?: Vector3[][];
  22885. depth?: number;
  22886. faceUV?: Vector4[];
  22887. faceColors?: Color4[];
  22888. updatable?: boolean;
  22889. sideOrientation?: number;
  22890. frontUVs?: Vector4;
  22891. backUVs?: Vector4;
  22892. }, scene: Scene): Mesh;
  22893. /**
  22894. * Creates an extruded polygon mesh, with depth in the Y direction.
  22895. * * 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)
  22896. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22897. * @param name defines the name of the mesh
  22898. * @param options defines the options used to create the mesh
  22899. * @param scene defines the hosting scene
  22900. * @returns the polygon mesh
  22901. */
  22902. static ExtrudePolygon(name: string, options: {
  22903. shape: Vector3[];
  22904. holes?: Vector3[][];
  22905. depth?: number;
  22906. faceUV?: Vector4[];
  22907. faceColors?: Color4[];
  22908. updatable?: boolean;
  22909. sideOrientation?: number;
  22910. frontUVs?: Vector4;
  22911. backUVs?: Vector4;
  22912. }, scene: Scene): Mesh;
  22913. /**
  22914. * Creates a tube mesh.
  22915. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22916. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22917. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22918. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22919. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22920. * * 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)
  22921. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22922. * * 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
  22923. * * 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
  22924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22925. * * 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
  22926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22928. * @param name defines the name of the mesh
  22929. * @param options defines the options used to create the mesh
  22930. * @param scene defines the hosting scene
  22931. * @returns the tube mesh
  22932. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22933. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22934. */
  22935. static CreateTube(name: string, options: {
  22936. path: Vector3[];
  22937. radius?: number;
  22938. tessellation?: number;
  22939. radiusFunction?: {
  22940. (i: number, distance: number): number;
  22941. };
  22942. cap?: number;
  22943. arc?: number;
  22944. updatable?: boolean;
  22945. sideOrientation?: number;
  22946. frontUVs?: Vector4;
  22947. backUVs?: Vector4;
  22948. instance?: Mesh;
  22949. invertUV?: boolean;
  22950. }, scene: Scene): Mesh;
  22951. /**
  22952. * Creates a polyhedron mesh
  22953. * * 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
  22954. * * The parameter `size` (positive float, default 1) sets the polygon size
  22955. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22956. * * 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`
  22957. * * 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
  22958. * * 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)`)
  22959. * * 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
  22960. * * 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
  22961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22962. * * 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
  22963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22964. * @param name defines the name of the mesh
  22965. * @param options defines the options used to create the mesh
  22966. * @param scene defines the hosting scene
  22967. * @returns the polyhedron mesh
  22968. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22969. */
  22970. static CreatePolyhedron(name: string, options: {
  22971. type?: number;
  22972. size?: number;
  22973. sizeX?: number;
  22974. sizeY?: number;
  22975. sizeZ?: number;
  22976. custom?: any;
  22977. faceUV?: Vector4[];
  22978. faceColors?: Color4[];
  22979. flat?: boolean;
  22980. updatable?: boolean;
  22981. sideOrientation?: number;
  22982. frontUVs?: Vector4;
  22983. backUVs?: Vector4;
  22984. }, scene: Scene): Mesh;
  22985. /**
  22986. * Creates a decal mesh.
  22987. * 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
  22988. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22989. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22990. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22991. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22992. * @param name defines the name of the mesh
  22993. * @param sourceMesh defines the mesh where the decal must be applied
  22994. * @param options defines the options used to create the mesh
  22995. * @param scene defines the hosting scene
  22996. * @returns the decal mesh
  22997. * @see http://doc.babylonjs.com/how_to/decals
  22998. */
  22999. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23000. position?: Vector3;
  23001. normal?: Vector3;
  23002. size?: Vector3;
  23003. angle?: number;
  23004. }): Mesh;
  23005. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  23006. }
  23007. }
  23008. declare module BABYLON {
  23009. class MeshLODLevel {
  23010. distance: number;
  23011. mesh: Mesh;
  23012. constructor(distance: number, mesh: Mesh);
  23013. }
  23014. }
  23015. declare module BABYLON {
  23016. /**
  23017. * A simplifier interface for future simplification implementations.
  23018. */
  23019. interface ISimplifier {
  23020. /**
  23021. * Simplification of a given mesh according to the given settings.
  23022. * Since this requires computation, it is assumed that the function runs async.
  23023. * @param settings The settings of the simplification, including quality and distance
  23024. * @param successCallback A callback that will be called after the mesh was simplified.
  23025. * @param errorCallback in case of an error, this callback will be called. optional.
  23026. */
  23027. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23028. }
  23029. /**
  23030. * Expected simplification settings.
  23031. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23032. */
  23033. interface ISimplificationSettings {
  23034. quality: number;
  23035. distance: number;
  23036. optimizeMesh?: boolean;
  23037. }
  23038. class SimplificationSettings implements ISimplificationSettings {
  23039. quality: number;
  23040. distance: number;
  23041. optimizeMesh: boolean | undefined;
  23042. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23043. }
  23044. interface ISimplificationTask {
  23045. settings: Array<ISimplificationSettings>;
  23046. simplificationType: SimplificationType;
  23047. mesh: Mesh;
  23048. successCallback?: () => void;
  23049. parallelProcessing: boolean;
  23050. }
  23051. class SimplificationQueue {
  23052. private _simplificationArray;
  23053. running: boolean;
  23054. constructor();
  23055. addTask(task: ISimplificationTask): void;
  23056. executeNext(): void;
  23057. runSimplification(task: ISimplificationTask): void;
  23058. private getSimplifier(task);
  23059. }
  23060. /**
  23061. * The implemented types of simplification
  23062. * At the moment only Quadratic Error Decimation is implemented
  23063. */
  23064. enum SimplificationType {
  23065. /** Quadratic error decimation */
  23066. QUADRATIC = 0,
  23067. }
  23068. class DecimationTriangle {
  23069. vertices: Array<DecimationVertex>;
  23070. normal: Vector3;
  23071. error: Array<number>;
  23072. deleted: boolean;
  23073. isDirty: boolean;
  23074. borderFactor: number;
  23075. deletePending: boolean;
  23076. originalOffset: number;
  23077. constructor(vertices: Array<DecimationVertex>);
  23078. }
  23079. class DecimationVertex {
  23080. position: Vector3;
  23081. id: number;
  23082. q: QuadraticMatrix;
  23083. isBorder: boolean;
  23084. triangleStart: number;
  23085. triangleCount: number;
  23086. originalOffsets: Array<number>;
  23087. constructor(position: Vector3, id: number);
  23088. updatePosition(newPosition: Vector3): void;
  23089. }
  23090. class QuadraticMatrix {
  23091. data: Array<number>;
  23092. constructor(data?: Array<number>);
  23093. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23094. addInPlace(matrix: QuadraticMatrix): void;
  23095. addArrayInPlace(data: Array<number>): void;
  23096. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23097. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23098. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23099. }
  23100. class Reference {
  23101. vertexId: number;
  23102. triangleId: number;
  23103. constructor(vertexId: number, triangleId: number);
  23104. }
  23105. /**
  23106. * An implementation of the Quadratic Error simplification algorithm.
  23107. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23108. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23109. * @author RaananW
  23110. */
  23111. class QuadraticErrorSimplification implements ISimplifier {
  23112. private _mesh;
  23113. private triangles;
  23114. private vertices;
  23115. private references;
  23116. private _reconstructedMesh;
  23117. syncIterations: number;
  23118. aggressiveness: number;
  23119. decimationIterations: number;
  23120. boundingBoxEpsilon: number;
  23121. constructor(_mesh: Mesh);
  23122. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23123. private runDecimation(settings, submeshIndex, successCallback);
  23124. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23125. private init(callback);
  23126. private reconstructMesh(submeshIndex);
  23127. private initDecimatedMesh();
  23128. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23129. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23130. private identifyBorder();
  23131. private updateMesh(identifyBorders?);
  23132. private vertexError(q, point);
  23133. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23134. }
  23135. }
  23136. declare module BABYLON {
  23137. class Polygon {
  23138. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23139. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23140. static Parse(input: string): Vector2[];
  23141. static StartingAt(x: number, y: number): Path2;
  23142. }
  23143. class PolygonMeshBuilder {
  23144. private _points;
  23145. private _outlinepoints;
  23146. private _holes;
  23147. private _name;
  23148. private _scene;
  23149. private _epoints;
  23150. private _eholes;
  23151. private _addToepoint(points);
  23152. constructor(name: string, contours: Path2, scene: Scene);
  23153. constructor(name: string, contours: Vector2[], scene: Scene);
  23154. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23155. build(updatable?: boolean, depth?: number): Mesh;
  23156. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23157. }
  23158. }
  23159. declare module BABYLON {
  23160. class BaseSubMesh {
  23161. readonly effect: Nullable<Effect>;
  23162. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23163. }
  23164. class SubMesh extends BaseSubMesh implements ICullable {
  23165. materialIndex: number;
  23166. verticesStart: number;
  23167. verticesCount: number;
  23168. indexStart: number;
  23169. indexCount: number;
  23170. linesIndexCount: number;
  23171. private _mesh;
  23172. private _renderingMesh;
  23173. private _boundingInfo;
  23174. private _linesIndexBuffer;
  23175. private _currentMaterial;
  23176. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23177. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23178. readonly IsGlobal: boolean;
  23179. /**
  23180. * Returns the submesh BoudingInfo object.
  23181. */
  23182. getBoundingInfo(): BoundingInfo;
  23183. /**
  23184. * Sets the submesh BoundingInfo.
  23185. * Return the SubMesh.
  23186. */
  23187. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23188. /**
  23189. * Returns the mesh of the current submesh.
  23190. */
  23191. getMesh(): AbstractMesh;
  23192. /**
  23193. * Returns the rendering mesh of the submesh.
  23194. */
  23195. getRenderingMesh(): Mesh;
  23196. /**
  23197. * Returns the submesh material.
  23198. */
  23199. getMaterial(): Nullable<Material>;
  23200. /**
  23201. * Sets a new updated BoundingInfo object to the submesh.
  23202. * Returns the SubMesh.
  23203. */
  23204. refreshBoundingInfo(): SubMesh;
  23205. /**
  23206. * Updates the submesh BoundingInfo.
  23207. * Returns the Submesh.
  23208. */
  23209. updateBoundingInfo(world: Matrix): SubMesh;
  23210. /**
  23211. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23212. * Boolean returned.
  23213. */
  23214. isInFrustum(frustumPlanes: Plane[]): boolean;
  23215. /**
  23216. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23217. * Boolean returned.
  23218. */
  23219. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23220. /**
  23221. * Renders the submesh.
  23222. * Returns it.
  23223. */
  23224. render(enableAlphaMode: boolean): SubMesh;
  23225. /**
  23226. * Returns a new Index Buffer.
  23227. * Type returned : WebGLBuffer.
  23228. */
  23229. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23230. /**
  23231. * True is the passed Ray intersects the submesh bounding box.
  23232. * Boolean returned.
  23233. */
  23234. canIntersects(ray: Ray): boolean;
  23235. /**
  23236. * Returns an object IntersectionInfo.
  23237. */
  23238. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23239. /**
  23240. * Creates a new Submesh from the passed Mesh.
  23241. */
  23242. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23243. /**
  23244. * Disposes the Submesh.
  23245. * Returns nothing.
  23246. */
  23247. dispose(): void;
  23248. /**
  23249. * Creates a new Submesh from the passed parameters :
  23250. * - materialIndex (integer) : the index of the main mesh material.
  23251. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23252. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23253. * - mesh (Mesh) : the main mesh to create the submesh from.
  23254. * - renderingMesh (optional Mesh) : rendering mesh.
  23255. */
  23256. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23257. }
  23258. }
  23259. declare module BABYLON {
  23260. class TransformNode extends Node {
  23261. static BILLBOARDMODE_NONE: number;
  23262. static BILLBOARDMODE_X: number;
  23263. static BILLBOARDMODE_Y: number;
  23264. static BILLBOARDMODE_Z: number;
  23265. static BILLBOARDMODE_ALL: number;
  23266. private _forward;
  23267. private _forwardInverted;
  23268. private _up;
  23269. private _right;
  23270. private _rightInverted;
  23271. private _rotation;
  23272. private _rotationQuaternion;
  23273. protected _scaling: Vector3;
  23274. protected _isDirty: boolean;
  23275. private _transformToBoneReferal;
  23276. billboardMode: number;
  23277. scalingDeterminant: number;
  23278. infiniteDistance: boolean;
  23279. position: Vector3;
  23280. private _localWorld;
  23281. private _absolutePosition;
  23282. private _pivotMatrix;
  23283. private _pivotMatrixInverse;
  23284. private _postMultiplyPivotMatrix;
  23285. protected _isWorldMatrixFrozen: boolean;
  23286. /**
  23287. * An event triggered after the world matrix is updated
  23288. */
  23289. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23290. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23291. /**
  23292. * Gets a string idenfifying the name of the class
  23293. * @returns "TransformNode" string
  23294. */
  23295. getClassName(): string;
  23296. /**
  23297. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23298. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23299. * Default : (0.0, 0.0, 0.0)
  23300. */
  23301. rotation: Vector3;
  23302. /**
  23303. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23304. * Default : (1.0, 1.0, 1.0)
  23305. */
  23306. /**
  23307. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23308. * Default : (1.0, 1.0, 1.0)
  23309. */
  23310. scaling: Vector3;
  23311. /**
  23312. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23313. * It's null by default.
  23314. * 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)
  23315. */
  23316. rotationQuaternion: Nullable<Quaternion>;
  23317. /**
  23318. * The forward direction of that transform in world space.
  23319. */
  23320. readonly forward: Vector3;
  23321. /**
  23322. * The up direction of that transform in world space.
  23323. */
  23324. readonly up: Vector3;
  23325. /**
  23326. * The right direction of that transform in world space.
  23327. */
  23328. readonly right: Vector3;
  23329. /**
  23330. * Returns the latest update of the World matrix
  23331. * Returns a Matrix.
  23332. */
  23333. getWorldMatrix(): Matrix;
  23334. /** @hidden */
  23335. /**
  23336. * Returns directly the latest state of the mesh World matrix.
  23337. * A Matrix is returned.
  23338. */
  23339. readonly worldMatrixFromCache: Matrix;
  23340. /**
  23341. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23342. * Returns the TransformNode.
  23343. */
  23344. updatePoseMatrix(matrix: Matrix): TransformNode;
  23345. /**
  23346. * Returns the mesh Pose matrix.
  23347. * Returned object : Matrix
  23348. */
  23349. getPoseMatrix(): Matrix;
  23350. markAsDirty(property: string): TransformNode;
  23351. /**
  23352. * Returns the current mesh absolute position.
  23353. * Retuns a Vector3.
  23354. */
  23355. readonly absolutePosition: Vector3;
  23356. /**
  23357. * Sets a new matrix to apply before all other transformation
  23358. * @param matrix defines the transform matrix
  23359. * @returns the current TransformNode
  23360. */
  23361. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23362. /**
  23363. * Sets a new pivot matrix to the current node
  23364. * @param matrix defines the new pivot matrix to use
  23365. * @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
  23366. * @returns the current TransformNode
  23367. */
  23368. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23369. /**
  23370. * Returns the mesh pivot matrix.
  23371. * Default : Identity.
  23372. * A Matrix is returned.
  23373. */
  23374. getPivotMatrix(): Matrix;
  23375. /**
  23376. * Prevents the World matrix to be computed any longer.
  23377. * Returns the TransformNode.
  23378. */
  23379. freezeWorldMatrix(): TransformNode;
  23380. /**
  23381. * Allows back the World matrix computation.
  23382. * Returns the TransformNode.
  23383. */
  23384. unfreezeWorldMatrix(): this;
  23385. /**
  23386. * True if the World matrix has been frozen.
  23387. * Returns a boolean.
  23388. */
  23389. readonly isWorldMatrixFrozen: boolean;
  23390. /**
  23391. * Retuns the mesh absolute position in the World.
  23392. * Returns a Vector3.
  23393. */
  23394. getAbsolutePosition(): Vector3;
  23395. /**
  23396. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23397. * Returns the TransformNode.
  23398. */
  23399. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23400. /**
  23401. * Sets the mesh position in its local space.
  23402. * Returns the TransformNode.
  23403. */
  23404. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23405. /**
  23406. * Returns the mesh position in the local space from the current World matrix values.
  23407. * Returns a new Vector3.
  23408. */
  23409. getPositionExpressedInLocalSpace(): Vector3;
  23410. /**
  23411. * Translates the mesh along the passed Vector3 in its local space.
  23412. * Returns the TransformNode.
  23413. */
  23414. locallyTranslate(vector3: Vector3): TransformNode;
  23415. private static _lookAtVectorCache;
  23416. /**
  23417. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23418. * @param targetPoint the position (must be in same space as current mesh) to look at
  23419. * @param yawCor optional yaw (y-axis) correction in radians
  23420. * @param pitchCor optional pitch (x-axis) correction in radians
  23421. * @param rollCor optional roll (z-axis) correction in radians
  23422. * @param space the choosen space of the target
  23423. * @returns the TransformNode.
  23424. */
  23425. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23426. /**
  23427. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23428. * This Vector3 is expressed in the World space.
  23429. */
  23430. getDirection(localAxis: Vector3): Vector3;
  23431. /**
  23432. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23433. * localAxis is expressed in the mesh local space.
  23434. * result is computed in the Wordl space from the mesh World matrix.
  23435. * Returns the TransformNode.
  23436. */
  23437. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23438. /**
  23439. * Sets a new pivot point to the current node
  23440. * @param point defines the new pivot point to use
  23441. * @param space defines if the point is in world or local space (local by default)
  23442. * @returns the current TransformNode
  23443. */
  23444. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23445. /**
  23446. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23447. */
  23448. getPivotPoint(): Vector3;
  23449. /**
  23450. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23451. * Returns the TransformNode.
  23452. */
  23453. getPivotPointToRef(result: Vector3): TransformNode;
  23454. /**
  23455. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23456. */
  23457. getAbsolutePivotPoint(): Vector3;
  23458. /**
  23459. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23460. * Returns the TransformNode.
  23461. */
  23462. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23463. /**
  23464. * Defines the passed node as the parent of the current node.
  23465. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23466. * Returns the TransformNode.
  23467. */
  23468. setParent(node: Nullable<Node>): TransformNode;
  23469. private _nonUniformScaling;
  23470. readonly nonUniformScaling: boolean;
  23471. /**
  23472. * Attach the current TransformNode to another TransformNode associated with a bone
  23473. * @param bone Bone affecting the TransformNode
  23474. * @param affectedTransformNode TransformNode associated with the bone
  23475. */
  23476. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23477. detachFromBone(): TransformNode;
  23478. private static _rotationAxisCache;
  23479. /**
  23480. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23481. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23482. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23483. * The passed axis is also normalized.
  23484. * Returns the TransformNode.
  23485. */
  23486. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23487. /**
  23488. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23489. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23490. * The passed axis is also normalized.
  23491. * Returns the TransformNode.
  23492. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23493. */
  23494. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23495. /**
  23496. * Translates the mesh along the axis vector for the passed distance in the given space.
  23497. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23498. * Returns the TransformNode.
  23499. */
  23500. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23501. /**
  23502. * Adds a rotation step to the mesh current rotation.
  23503. * x, y, z are Euler angles expressed in radians.
  23504. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23505. * This means this rotation is made in the mesh local space only.
  23506. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23507. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23508. * ```javascript
  23509. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23510. * ```
  23511. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23512. * 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.
  23513. * Returns the TransformNode.
  23514. */
  23515. addRotation(x: number, y: number, z: number): TransformNode;
  23516. /**
  23517. * Computes the mesh World matrix and returns it.
  23518. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23519. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23520. * If the parameter `force`is set to `true`, the actual computation is done.
  23521. * Returns the mesh World Matrix.
  23522. */
  23523. computeWorldMatrix(force?: boolean): Matrix;
  23524. protected _afterComputeWorldMatrix(): void;
  23525. /**
  23526. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23527. * @param func: callback function to add
  23528. *
  23529. * Returns the TransformNode.
  23530. */
  23531. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23532. /**
  23533. * Removes a registered callback function.
  23534. * Returns the TransformNode.
  23535. */
  23536. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23537. /**
  23538. * Clone the current transform node
  23539. * Returns the new transform node
  23540. * @param name Name of the new clone
  23541. * @param newParent New parent for the clone
  23542. * @param doNotCloneChildren Do not clone children hierarchy
  23543. */
  23544. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23545. serialize(currentSerializationObject?: any): any;
  23546. /**
  23547. * Returns a new TransformNode object parsed from the source provided.
  23548. * The parameter `parsedMesh` is the source.
  23549. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23550. */
  23551. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23552. /**
  23553. * Releases resources associated with this transform node.
  23554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23556. */
  23557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23558. }
  23559. }
  23560. declare module BABYLON {
  23561. class VertexBuffer {
  23562. private _buffer;
  23563. private _kind;
  23564. private _size;
  23565. private _ownsBuffer;
  23566. private _instanced;
  23567. private _instanceDivisor;
  23568. /**
  23569. * The byte type.
  23570. */
  23571. static readonly BYTE: number;
  23572. /**
  23573. * The unsigned byte type.
  23574. */
  23575. static readonly UNSIGNED_BYTE: number;
  23576. /**
  23577. * The short type.
  23578. */
  23579. static readonly SHORT: number;
  23580. /**
  23581. * The unsigned short type.
  23582. */
  23583. static readonly UNSIGNED_SHORT: number;
  23584. /**
  23585. * The integer type.
  23586. */
  23587. static readonly INT: number;
  23588. /**
  23589. * The unsigned integer type.
  23590. */
  23591. static readonly UNSIGNED_INT: number;
  23592. /**
  23593. * The float type.
  23594. */
  23595. static readonly FLOAT: number;
  23596. /**
  23597. * Gets or sets the instance divisor when in instanced mode
  23598. */
  23599. instanceDivisor: number;
  23600. /**
  23601. * Gets the byte stride.
  23602. */
  23603. readonly byteStride: number;
  23604. /**
  23605. * Gets the byte offset.
  23606. */
  23607. readonly byteOffset: number;
  23608. /**
  23609. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23610. */
  23611. readonly normalized: boolean;
  23612. /**
  23613. * Gets the data type of each component in the array.
  23614. */
  23615. readonly type: number;
  23616. /**
  23617. * Constructor
  23618. * @param engine the engine
  23619. * @param data the data to use for this vertex buffer
  23620. * @param kind the vertex buffer kind
  23621. * @param updatable whether the data is updatable
  23622. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23623. * @param stride the stride (optional)
  23624. * @param instanced whether the buffer is instanced (optional)
  23625. * @param offset the offset of the data (optional)
  23626. * @param size the number of components (optional)
  23627. * @param type the type of the component (optional)
  23628. * @param normalized whether the data contains normalized data (optional)
  23629. * @param useBytes set to true if stride and offset are in bytes (optional)
  23630. */
  23631. 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);
  23632. /**
  23633. * Returns the kind of the VertexBuffer (string).
  23634. */
  23635. getKind(): string;
  23636. /**
  23637. * Boolean : is the VertexBuffer updatable ?
  23638. */
  23639. isUpdatable(): boolean;
  23640. /**
  23641. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23642. */
  23643. getData(): Nullable<DataArray>;
  23644. /**
  23645. * Returns the WebGLBuffer associated to the VertexBuffer.
  23646. */
  23647. getBuffer(): Nullable<WebGLBuffer>;
  23648. /**
  23649. * Returns the stride as a multiple of the type byte length.
  23650. * DEPRECATED. Use byteStride instead.
  23651. */
  23652. getStrideSize(): number;
  23653. /**
  23654. * Returns the offset as a multiple of the type byte length.
  23655. * DEPRECATED. Use byteOffset instead.
  23656. */
  23657. getOffset(): number;
  23658. /**
  23659. * Returns the number of components per vertex attribute (integer).
  23660. */
  23661. getSize(): number;
  23662. /**
  23663. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23664. */
  23665. getIsInstanced(): boolean;
  23666. /**
  23667. * Returns the instancing divisor, zero for non-instanced (integer).
  23668. */
  23669. getInstanceDivisor(): number;
  23670. /**
  23671. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23672. * Returns the created WebGLBuffer.
  23673. */
  23674. create(data?: DataArray): void;
  23675. /**
  23676. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23677. * This function will create a new buffer if the current one is not updatable
  23678. * Returns the updated WebGLBuffer.
  23679. */
  23680. update(data: DataArray): void;
  23681. /**
  23682. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23683. * Returns the directly updated WebGLBuffer.
  23684. * @param data the new data
  23685. * @param offset the new offset
  23686. * @param useBytes set to true if the offset is in bytes
  23687. */
  23688. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23689. /**
  23690. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23691. */
  23692. dispose(): void;
  23693. /**
  23694. * Enumerates each value of this vertex buffer as numbers.
  23695. * @param count the number of values to enumerate
  23696. * @param callback the callback function called for each value
  23697. */
  23698. forEach(count: number, callback: (value: number, index: number) => void): void;
  23699. private static _PositionKind;
  23700. private static _NormalKind;
  23701. private static _TangentKind;
  23702. private static _UVKind;
  23703. private static _UV2Kind;
  23704. private static _UV3Kind;
  23705. private static _UV4Kind;
  23706. private static _UV5Kind;
  23707. private static _UV6Kind;
  23708. private static _ColorKind;
  23709. private static _MatricesIndicesKind;
  23710. private static _MatricesWeightsKind;
  23711. private static _MatricesIndicesExtraKind;
  23712. private static _MatricesWeightsExtraKind;
  23713. static readonly PositionKind: string;
  23714. static readonly NormalKind: string;
  23715. static readonly TangentKind: string;
  23716. static readonly UVKind: string;
  23717. static readonly UV2Kind: string;
  23718. static readonly UV3Kind: string;
  23719. static readonly UV4Kind: string;
  23720. static readonly UV5Kind: string;
  23721. static readonly UV6Kind: string;
  23722. static readonly ColorKind: string;
  23723. static readonly MatricesIndicesKind: string;
  23724. static readonly MatricesWeightsKind: string;
  23725. static readonly MatricesIndicesExtraKind: string;
  23726. static readonly MatricesWeightsExtraKind: string;
  23727. /**
  23728. * Deduces the stride given a kind.
  23729. * @param kind The kind string to deduce
  23730. * @returns The deduced stride
  23731. */
  23732. static DeduceStride(kind: string): number;
  23733. /**
  23734. * Gets the byte length of the given type.
  23735. * @param type the type
  23736. * @returns the number of bytes
  23737. */
  23738. static GetTypeByteLength(type: number): number;
  23739. /**
  23740. * Enumerates each value of the given parameters as numbers.
  23741. * @param data the data to enumerate
  23742. * @param byteOffset the byte offset of the data
  23743. * @param byteStride the byte stride of the data
  23744. * @param componentCount the number of components per element
  23745. * @param componentType the type of the component
  23746. * @param count the total number of components
  23747. * @param normalized whether the data is normalized
  23748. * @param callback the callback function called for each value
  23749. */
  23750. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23751. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23752. }
  23753. }
  23754. declare module BABYLON {
  23755. interface PhysicsImpostorJoint {
  23756. mainImpostor: PhysicsImpostor;
  23757. connectedImpostor: PhysicsImpostor;
  23758. joint: PhysicsJoint;
  23759. }
  23760. class PhysicsEngine {
  23761. private _physicsPlugin;
  23762. gravity: Vector3;
  23763. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  23764. setGravity(gravity: Vector3): void;
  23765. /**
  23766. * Set the time step of the physics engine.
  23767. * default is 1/60.
  23768. * To slow it down, enter 1/600 for example.
  23769. * To speed it up, 1/30
  23770. * @param {number} newTimeStep the new timestep to apply to this world.
  23771. */
  23772. setTimeStep(newTimeStep?: number): void;
  23773. /**
  23774. * Get the time step of the physics engine.
  23775. */
  23776. getTimeStep(): number;
  23777. dispose(): void;
  23778. getPhysicsPluginName(): string;
  23779. static Epsilon: number;
  23780. private _impostors;
  23781. private _joints;
  23782. /**
  23783. * Adding a new impostor for the impostor tracking.
  23784. * This will be done by the impostor itself.
  23785. * @param {PhysicsImpostor} impostor the impostor to add
  23786. */
  23787. addImpostor(impostor: PhysicsImpostor): void;
  23788. /**
  23789. * Remove an impostor from the engine.
  23790. * This impostor and its mesh will not longer be updated by the physics engine.
  23791. * @param {PhysicsImpostor} impostor the impostor to remove
  23792. */
  23793. removeImpostor(impostor: PhysicsImpostor): void;
  23794. /**
  23795. * Add a joint to the physics engine
  23796. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  23797. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  23798. * @param {PhysicsJoint} the joint that will connect both impostors.
  23799. */
  23800. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23801. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23802. /**
  23803. * Called by the scene. no need to call it.
  23804. */
  23805. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23806. getImpostors(): Array<PhysicsImpostor>;
  23807. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23808. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23809. }
  23810. interface IPhysicsEnginePlugin {
  23811. world: any;
  23812. name: string;
  23813. setGravity(gravity: Vector3): void;
  23814. setTimeStep(timeStep: number): void;
  23815. getTimeStep(): number;
  23816. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23817. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23818. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23819. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23820. removePhysicsBody(impostor: PhysicsImpostor): void;
  23821. generateJoint(joint: PhysicsImpostorJoint): void;
  23822. removeJoint(joint: PhysicsImpostorJoint): void;
  23823. isSupported(): boolean;
  23824. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23825. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23826. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23827. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23828. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23829. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23830. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23831. getBodyMass(impostor: PhysicsImpostor): number;
  23832. getBodyFriction(impostor: PhysicsImpostor): number;
  23833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23834. getBodyRestitution(impostor: PhysicsImpostor): number;
  23835. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23836. sleepBody(impostor: PhysicsImpostor): void;
  23837. wakeUpBody(impostor: PhysicsImpostor): void;
  23838. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23839. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23840. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23841. getRadius(impostor: PhysicsImpostor): number;
  23842. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23843. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23844. dispose(): void;
  23845. }
  23846. }
  23847. declare module BABYLON {
  23848. class PhysicsHelper {
  23849. private _scene;
  23850. private _physicsEngine;
  23851. constructor(scene: Scene);
  23852. /**
  23853. * @param {Vector3} origin the origin of the explosion
  23854. * @param {number} radius the explosion radius
  23855. * @param {number} strength the explosion strength
  23856. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23857. */
  23858. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23859. /**
  23860. * @param {Vector3} origin the origin of the explosion
  23861. * @param {number} radius the explosion radius
  23862. * @param {number} strength the explosion strength
  23863. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23864. */
  23865. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23866. /**
  23867. * @param {Vector3} origin the origin of the explosion
  23868. * @param {number} radius the explosion radius
  23869. * @param {number} strength the explosion strength
  23870. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23871. */
  23872. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  23873. /**
  23874. * @param {Vector3} origin the origin of the updraft
  23875. * @param {number} radius the radius of the updraft
  23876. * @param {number} strength the strength of the updraft
  23877. * @param {number} height the height of the updraft
  23878. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  23879. */
  23880. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  23881. /**
  23882. * @param {Vector3} origin the of the vortex
  23883. * @param {number} radius the radius of the vortex
  23884. * @param {number} strength the strength of the vortex
  23885. * @param {number} height the height of the vortex
  23886. */
  23887. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  23888. }
  23889. /***** Radial explosion *****/
  23890. class PhysicsRadialExplosionEvent {
  23891. private _scene;
  23892. private _sphere;
  23893. private _sphereOptions;
  23894. private _rays;
  23895. private _dataFetched;
  23896. constructor(scene: Scene);
  23897. /**
  23898. * Returns the data related to the radial explosion event (sphere & rays).
  23899. * @returns {PhysicsRadialExplosionEventData}
  23900. */
  23901. getData(): PhysicsRadialExplosionEventData;
  23902. /**
  23903. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  23904. * @param impostor
  23905. * @param {Vector3} origin the origin of the explosion
  23906. * @param {number} radius the explosion radius
  23907. * @param {number} strength the explosion strength
  23908. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  23909. * @returns {Nullable<PhysicsForceAndContactPoint>}
  23910. */
  23911. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  23912. /**
  23913. * Disposes the sphere.
  23914. * @param {bolean} force
  23915. */
  23916. dispose(force?: boolean): void;
  23917. /*** Helpers ***/
  23918. private _prepareSphere();
  23919. private _intersectsWithSphere(impostor, origin, radius);
  23920. }
  23921. /***** Gravitational Field *****/
  23922. class PhysicsGravitationalFieldEvent {
  23923. private _physicsHelper;
  23924. private _scene;
  23925. private _origin;
  23926. private _radius;
  23927. private _strength;
  23928. private _falloff;
  23929. private _tickCallback;
  23930. private _sphere;
  23931. private _dataFetched;
  23932. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  23933. /**
  23934. * Returns the data related to the gravitational field event (sphere).
  23935. * @returns {PhysicsGravitationalFieldEventData}
  23936. */
  23937. getData(): PhysicsGravitationalFieldEventData;
  23938. /**
  23939. * Enables the gravitational field.
  23940. */
  23941. enable(): void;
  23942. /**
  23943. * Disables the gravitational field.
  23944. */
  23945. disable(): void;
  23946. /**
  23947. * Disposes the sphere.
  23948. * @param {bolean} force
  23949. */
  23950. dispose(force?: boolean): void;
  23951. private _tick();
  23952. }
  23953. /***** Updraft *****/
  23954. class PhysicsUpdraftEvent {
  23955. private _scene;
  23956. private _origin;
  23957. private _radius;
  23958. private _strength;
  23959. private _height;
  23960. private _updraftMode;
  23961. private _physicsEngine;
  23962. private _originTop;
  23963. private _originDirection;
  23964. private _tickCallback;
  23965. private _cylinder;
  23966. private _cylinderPosition;
  23967. private _dataFetched;
  23968. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  23969. /**
  23970. * Returns the data related to the updraft event (cylinder).
  23971. * @returns {PhysicsUpdraftEventData}
  23972. */
  23973. getData(): PhysicsUpdraftEventData;
  23974. /**
  23975. * Enables the updraft.
  23976. */
  23977. enable(): void;
  23978. /**
  23979. * Disables the cortex.
  23980. */
  23981. disable(): void;
  23982. /**
  23983. * Disposes the sphere.
  23984. * @param {bolean} force
  23985. */
  23986. dispose(force?: boolean): void;
  23987. private getImpostorForceAndContactPoint(impostor);
  23988. private _tick();
  23989. /*** Helpers ***/
  23990. private _prepareCylinder();
  23991. private _intersectsWithCylinder(impostor);
  23992. }
  23993. /***** Vortex *****/
  23994. class PhysicsVortexEvent {
  23995. private _scene;
  23996. private _origin;
  23997. private _radius;
  23998. private _strength;
  23999. private _height;
  24000. private _physicsEngine;
  24001. private _originTop;
  24002. private _centripetalForceThreshold;
  24003. private _updraftMultiplier;
  24004. private _tickCallback;
  24005. private _cylinder;
  24006. private _cylinderPosition;
  24007. private _dataFetched;
  24008. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24009. /**
  24010. * Returns the data related to the vortex event (cylinder).
  24011. * @returns {PhysicsVortexEventData}
  24012. */
  24013. getData(): PhysicsVortexEventData;
  24014. /**
  24015. * Enables the vortex.
  24016. */
  24017. enable(): void;
  24018. /**
  24019. * Disables the cortex.
  24020. */
  24021. disable(): void;
  24022. /**
  24023. * Disposes the sphere.
  24024. * @param {bolean} force
  24025. */
  24026. dispose(force?: boolean): void;
  24027. private getImpostorForceAndContactPoint(impostor);
  24028. private _tick();
  24029. /*** Helpers ***/
  24030. private _prepareCylinder();
  24031. private _intersectsWithCylinder(impostor);
  24032. }
  24033. /***** Enums *****/
  24034. /**
  24035. * The strenght of the force in correspondence to the distance of the affected object
  24036. */
  24037. enum PhysicsRadialImpulseFalloff {
  24038. /** Defines that impulse is constant in strength across it's whole radius */
  24039. Constant = 0,
  24040. /** DEfines that impulse gets weaker if it's further from the origin */
  24041. Linear = 1,
  24042. }
  24043. /**
  24044. * The strenght of the force in correspondence to the distance of the affected object
  24045. */
  24046. enum PhysicsUpdraftMode {
  24047. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24048. Center = 0,
  24049. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24050. Perpendicular = 1,
  24051. }
  24052. /***** Data interfaces *****/
  24053. interface PhysicsForceAndContactPoint {
  24054. force: Vector3;
  24055. contactPoint: Vector3;
  24056. }
  24057. interface PhysicsRadialExplosionEventData {
  24058. sphere: Mesh;
  24059. rays: Array<Ray>;
  24060. }
  24061. interface PhysicsGravitationalFieldEventData {
  24062. sphere: Mesh;
  24063. }
  24064. interface PhysicsUpdraftEventData {
  24065. cylinder: Mesh;
  24066. }
  24067. interface PhysicsVortexEventData {
  24068. cylinder: Mesh;
  24069. }
  24070. }
  24071. declare module BABYLON {
  24072. interface PhysicsImpostorParameters {
  24073. mass: number;
  24074. friction?: number;
  24075. restitution?: number;
  24076. nativeOptions?: any;
  24077. ignoreParent?: boolean;
  24078. disableBidirectionalTransformation?: boolean;
  24079. }
  24080. interface IPhysicsEnabledObject {
  24081. position: Vector3;
  24082. rotationQuaternion: Nullable<Quaternion>;
  24083. scaling: Vector3;
  24084. rotation?: Vector3;
  24085. parent?: any;
  24086. getBoundingInfo(): BoundingInfo;
  24087. computeWorldMatrix(force: boolean): Matrix;
  24088. getWorldMatrix?(): Matrix;
  24089. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24090. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24091. getIndices?(): Nullable<IndicesArray>;
  24092. getScene?(): Scene;
  24093. getAbsolutePosition(): Vector3;
  24094. getAbsolutePivotPoint(): Vector3;
  24095. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24096. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24097. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24098. getClassName(): string;
  24099. }
  24100. class PhysicsImpostor {
  24101. object: IPhysicsEnabledObject;
  24102. type: number;
  24103. private _options;
  24104. private _scene;
  24105. static DEFAULT_OBJECT_SIZE: Vector3;
  24106. static IDENTITY_QUATERNION: Quaternion;
  24107. private _physicsEngine;
  24108. private _physicsBody;
  24109. private _bodyUpdateRequired;
  24110. private _onBeforePhysicsStepCallbacks;
  24111. private _onAfterPhysicsStepCallbacks;
  24112. private _onPhysicsCollideCallbacks;
  24113. private _deltaPosition;
  24114. private _deltaRotation;
  24115. private _deltaRotationConjugated;
  24116. private _parent;
  24117. private _isDisposed;
  24118. private static _tmpVecs;
  24119. private static _tmpQuat;
  24120. readonly isDisposed: boolean;
  24121. mass: number;
  24122. friction: number;
  24123. restitution: number;
  24124. uniqueId: number;
  24125. private _joints;
  24126. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24127. /**
  24128. * This function will completly initialize this impostor.
  24129. * It will create a new body - but only if this mesh has no parent.
  24130. * If it has, this impostor will not be used other than to define the impostor
  24131. * of the child mesh.
  24132. */
  24133. private _getPhysicsParent();
  24134. /**
  24135. * Should a new body be generated.
  24136. */
  24137. isBodyInitRequired(): boolean;
  24138. setScalingUpdated(updated: boolean): void;
  24139. /**
  24140. * Force a regeneration of this or the parent's impostor's body.
  24141. * Use under cautious - This will remove all joints already implemented.
  24142. */
  24143. forceUpdate(): void;
  24144. /**
  24145. * Gets the body that holds this impostor. Either its own, or its parent.
  24146. */
  24147. /**
  24148. * Set the physics body. Used mainly by the physics engine/plugin
  24149. */
  24150. physicsBody: any;
  24151. parent: Nullable<PhysicsImpostor>;
  24152. resetUpdateFlags(): void;
  24153. getObjectExtendSize(): Vector3;
  24154. getObjectCenter(): Vector3;
  24155. /**
  24156. * Get a specific parametes from the options parameter.
  24157. */
  24158. getParam(paramName: string): any;
  24159. /**
  24160. * Sets a specific parameter in the options given to the physics plugin
  24161. */
  24162. setParam(paramName: string, value: number): void;
  24163. /**
  24164. * Specifically change the body's mass option. Won't recreate the physics body object
  24165. */
  24166. setMass(mass: number): void;
  24167. getLinearVelocity(): Nullable<Vector3>;
  24168. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24169. getAngularVelocity(): Nullable<Vector3>;
  24170. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24171. /**
  24172. * Execute a function with the physics plugin native code.
  24173. * Provide a function the will have two variables - the world object and the physics body object.
  24174. */
  24175. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24176. /**
  24177. * Register a function that will be executed before the physics world is stepping forward.
  24178. */
  24179. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24180. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24181. /**
  24182. * Register a function that will be executed after the physics step
  24183. */
  24184. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24185. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24186. /**
  24187. * register a function that will be executed when this impostor collides against a different body.
  24188. */
  24189. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24190. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24191. private _tmpQuat;
  24192. private _tmpQuat2;
  24193. getParentsRotation(): Quaternion;
  24194. /**
  24195. * this function is executed by the physics engine.
  24196. */
  24197. beforeStep: () => void;
  24198. /**
  24199. * this function is executed by the physics engine.
  24200. */
  24201. afterStep: () => void;
  24202. /**
  24203. * Legacy collision detection event support
  24204. */
  24205. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24206. onCollide: (e: {
  24207. body: any;
  24208. }) => void;
  24209. /**
  24210. * Apply a force
  24211. */
  24212. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24213. /**
  24214. * Apply an impulse
  24215. */
  24216. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24217. /**
  24218. * A help function to create a joint.
  24219. */
  24220. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24221. /**
  24222. * Add a joint to this impostor with a different impostor.
  24223. */
  24224. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24225. /**
  24226. * Will keep this body still, in a sleep mode.
  24227. */
  24228. sleep(): PhysicsImpostor;
  24229. /**
  24230. * Wake the body up.
  24231. */
  24232. wakeUp(): PhysicsImpostor;
  24233. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24234. dispose(): void;
  24235. setDeltaPosition(position: Vector3): void;
  24236. setDeltaRotation(rotation: Quaternion): void;
  24237. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24238. getRadius(): number;
  24239. /**
  24240. * Sync a bone with this impostor
  24241. * @param bone The bone to sync to the impostor.
  24242. * @param boneMesh The mesh that the bone is influencing.
  24243. * @param jointPivot The pivot of the joint / bone in local space.
  24244. * @param distToJoint Optional distance from the impostor to the joint.
  24245. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24246. */
  24247. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24248. /**
  24249. * Sync impostor to a bone
  24250. * @param bone The bone that the impostor will be synced to.
  24251. * @param boneMesh The mesh that the bone is influencing.
  24252. * @param jointPivot The pivot of the joint / bone in local space.
  24253. * @param distToJoint Optional distance from the impostor to the joint.
  24254. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24255. * @param boneAxis Optional vector3 axis the bone is aligned with
  24256. */
  24257. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24258. static NoImpostor: number;
  24259. static SphereImpostor: number;
  24260. static BoxImpostor: number;
  24261. static PlaneImpostor: number;
  24262. static MeshImpostor: number;
  24263. static CylinderImpostor: number;
  24264. static ParticleImpostor: number;
  24265. static HeightmapImpostor: number;
  24266. }
  24267. }
  24268. declare module BABYLON {
  24269. interface PhysicsJointData {
  24270. mainPivot?: Vector3;
  24271. connectedPivot?: Vector3;
  24272. mainAxis?: Vector3;
  24273. connectedAxis?: Vector3;
  24274. collision?: boolean;
  24275. nativeParams?: any;
  24276. }
  24277. /**
  24278. * This is a holder class for the physics joint created by the physics plugin.
  24279. * It holds a set of functions to control the underlying joint.
  24280. */
  24281. class PhysicsJoint {
  24282. type: number;
  24283. jointData: PhysicsJointData;
  24284. private _physicsJoint;
  24285. protected _physicsPlugin: IPhysicsEnginePlugin;
  24286. constructor(type: number, jointData: PhysicsJointData);
  24287. physicsJoint: any;
  24288. physicsPlugin: IPhysicsEnginePlugin;
  24289. /**
  24290. * Execute a function that is physics-plugin specific.
  24291. * @param {Function} func the function that will be executed.
  24292. * It accepts two parameters: the physics world and the physics joint.
  24293. */
  24294. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24295. static DistanceJoint: number;
  24296. static HingeJoint: number;
  24297. static BallAndSocketJoint: number;
  24298. static WheelJoint: number;
  24299. static SliderJoint: number;
  24300. static PrismaticJoint: number;
  24301. static UniversalJoint: number;
  24302. static Hinge2Joint: number;
  24303. static PointToPointJoint: number;
  24304. static SpringJoint: number;
  24305. static LockJoint: number;
  24306. }
  24307. /**
  24308. * A class representing a physics distance joint.
  24309. */
  24310. class DistanceJoint extends PhysicsJoint {
  24311. constructor(jointData: DistanceJointData);
  24312. /**
  24313. * Update the predefined distance.
  24314. */
  24315. updateDistance(maxDistance: number, minDistance?: number): void;
  24316. }
  24317. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24318. constructor(type: number, jointData: PhysicsJointData);
  24319. /**
  24320. * Set the motor values.
  24321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24322. * @param {number} force the force to apply
  24323. * @param {number} maxForce max force for this motor.
  24324. */
  24325. setMotor(force?: number, maxForce?: number): void;
  24326. /**
  24327. * Set the motor's limits.
  24328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24329. */
  24330. setLimit(upperLimit: number, lowerLimit?: number): void;
  24331. }
  24332. /**
  24333. * This class represents a single hinge physics joint
  24334. */
  24335. class HingeJoint extends MotorEnabledJoint {
  24336. constructor(jointData: PhysicsJointData);
  24337. /**
  24338. * Set the motor values.
  24339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24340. * @param {number} force the force to apply
  24341. * @param {number} maxForce max force for this motor.
  24342. */
  24343. setMotor(force?: number, maxForce?: number): void;
  24344. /**
  24345. * Set the motor's limits.
  24346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24347. */
  24348. setLimit(upperLimit: number, lowerLimit?: number): void;
  24349. }
  24350. /**
  24351. * This class represents a dual hinge physics joint (same as wheel joint)
  24352. */
  24353. class Hinge2Joint extends MotorEnabledJoint {
  24354. constructor(jointData: PhysicsJointData);
  24355. /**
  24356. * Set the motor values.
  24357. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24358. * @param {number} force the force to apply
  24359. * @param {number} maxForce max force for this motor.
  24360. * @param {motorIndex} the motor's index, 0 or 1.
  24361. */
  24362. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24363. /**
  24364. * Set the motor limits.
  24365. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24366. * @param {number} upperLimit the upper limit
  24367. * @param {number} lowerLimit lower limit
  24368. * @param {motorIndex} the motor's index, 0 or 1.
  24369. */
  24370. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24371. }
  24372. interface IMotorEnabledJoint {
  24373. physicsJoint: any;
  24374. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24375. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24376. }
  24377. interface DistanceJointData extends PhysicsJointData {
  24378. maxDistance: number;
  24379. }
  24380. interface SpringJointData extends PhysicsJointData {
  24381. length: number;
  24382. stiffness: number;
  24383. damping: number;
  24384. }
  24385. }
  24386. declare module BABYLON {
  24387. class ReflectionProbe {
  24388. name: string;
  24389. private _scene;
  24390. private _renderTargetTexture;
  24391. private _projectionMatrix;
  24392. private _viewMatrix;
  24393. private _target;
  24394. private _add;
  24395. private _attachedMesh;
  24396. private _invertYAxis;
  24397. position: Vector3;
  24398. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24399. samples: number;
  24400. refreshRate: number;
  24401. getScene(): Scene;
  24402. readonly cubeTexture: RenderTargetTexture;
  24403. readonly renderList: Nullable<AbstractMesh[]>;
  24404. attachToMesh(mesh: AbstractMesh): void;
  24405. /**
  24406. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24407. *
  24408. * @param renderingGroupId The rendering group id corresponding to its index
  24409. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24410. */
  24411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24412. dispose(): void;
  24413. }
  24414. }
  24415. declare module BABYLON {
  24416. class Sprite {
  24417. name: string;
  24418. position: Vector3;
  24419. color: Color4;
  24420. width: number;
  24421. height: number;
  24422. angle: number;
  24423. cellIndex: number;
  24424. invertU: number;
  24425. invertV: number;
  24426. disposeWhenFinishedAnimating: boolean;
  24427. animations: Animation[];
  24428. isPickable: boolean;
  24429. actionManager: ActionManager;
  24430. private _animationStarted;
  24431. private _loopAnimation;
  24432. private _fromIndex;
  24433. private _toIndex;
  24434. private _delay;
  24435. private _direction;
  24436. private _manager;
  24437. private _time;
  24438. private _onAnimationEnd;
  24439. size: number;
  24440. constructor(name: string, manager: SpriteManager);
  24441. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  24442. stopAnimation(): void;
  24443. dispose(): void;
  24444. }
  24445. }
  24446. declare module BABYLON {
  24447. class SpriteManager {
  24448. name: string;
  24449. sprites: Sprite[];
  24450. renderingGroupId: number;
  24451. layerMask: number;
  24452. fogEnabled: boolean;
  24453. isPickable: boolean;
  24454. cellWidth: number;
  24455. cellHeight: number;
  24456. /**
  24457. * An event triggered when the manager is disposed.
  24458. */
  24459. onDisposeObservable: Observable<SpriteManager>;
  24460. private _onDisposeObserver;
  24461. onDispose: () => void;
  24462. private _capacity;
  24463. private _spriteTexture;
  24464. private _epsilon;
  24465. private _scene;
  24466. private _vertexData;
  24467. private _buffer;
  24468. private _vertexBuffers;
  24469. private _indexBuffer;
  24470. private _effectBase;
  24471. private _effectFog;
  24472. texture: Texture;
  24473. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  24474. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  24475. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24476. render(): void;
  24477. dispose(): void;
  24478. }
  24479. }
  24480. declare module BABYLON {
  24481. class BoundingBoxRenderer {
  24482. frontColor: Color3;
  24483. backColor: Color3;
  24484. showBackLines: boolean;
  24485. renderList: SmartArray<BoundingBox>;
  24486. private _scene;
  24487. private _colorShader;
  24488. private _vertexBuffers;
  24489. private _indexBuffer;
  24490. constructor(scene: Scene);
  24491. private _prepareRessources();
  24492. private _createIndexBuffer();
  24493. reset(): void;
  24494. render(): void;
  24495. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  24496. dispose(): void;
  24497. }
  24498. }
  24499. declare module BABYLON {
  24500. /**
  24501. * This represents a depth renderer in Babylon.
  24502. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  24503. */
  24504. class DepthRenderer {
  24505. private _scene;
  24506. private _depthMap;
  24507. private _effect;
  24508. private _cachedDefines;
  24509. private _camera;
  24510. /**
  24511. * Instantiates a depth renderer
  24512. * @param scene The scene the renderer belongs to
  24513. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  24514. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  24515. */
  24516. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  24517. /**
  24518. * Creates the depth rendering effect and checks if the effect is ready.
  24519. * @param subMesh The submesh to be used to render the depth map of
  24520. * @param useInstances If multiple world instances should be used
  24521. * @returns if the depth renderer is ready to render the depth map
  24522. */
  24523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24524. /**
  24525. * Gets the texture which the depth map will be written to.
  24526. * @returns The depth map texture
  24527. */
  24528. getDepthMap(): RenderTargetTexture;
  24529. /**
  24530. * Disposes of the depth renderer.
  24531. */
  24532. dispose(): void;
  24533. }
  24534. }
  24535. declare module BABYLON {
  24536. class EdgesRenderer {
  24537. edgesWidthScalerForOrthographic: number;
  24538. edgesWidthScalerForPerspective: number;
  24539. private _source;
  24540. private _linesPositions;
  24541. private _linesNormals;
  24542. private _linesIndices;
  24543. private _epsilon;
  24544. private _indicesCount;
  24545. private _lineShader;
  24546. private _ib;
  24547. private _buffers;
  24548. private _checkVerticesInsteadOfIndices;
  24549. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  24550. private _prepareRessources();
  24551. dispose(): void;
  24552. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  24553. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  24554. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  24555. render(): void;
  24556. }
  24557. }
  24558. declare module BABYLON {
  24559. /**
  24560. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  24561. */
  24562. class GeometryBufferRenderer {
  24563. private _scene;
  24564. private _multiRenderTarget;
  24565. private _ratio;
  24566. private _enablePosition;
  24567. protected _effect: Effect;
  24568. protected _cachedDefines: string;
  24569. /**
  24570. * Set the render list (meshes to be rendered) used in the G buffer.
  24571. */
  24572. renderList: Mesh[];
  24573. /**
  24574. * Gets wether or not G buffer are supported by the running hardware.
  24575. * This requires draw buffer supports
  24576. */
  24577. readonly isSupported: boolean;
  24578. /**
  24579. * Gets wether or not position are enabled for the G buffer.
  24580. */
  24581. /**
  24582. * Sets wether or not position are enabled for the G buffer.
  24583. */
  24584. enablePosition: boolean;
  24585. /**
  24586. * Gets the scene associated with the buffer.
  24587. */
  24588. readonly scene: Scene;
  24589. /**
  24590. * Gets the ratio used by the buffer during its creation.
  24591. * How big is the buffer related to the main canvas.
  24592. */
  24593. readonly ratio: number;
  24594. /**
  24595. * Creates a new G Buffer for the scene
  24596. * @param scene The scene the buffer belongs to
  24597. * @param ratio How big is the buffer related to the main canvas.
  24598. */
  24599. constructor(scene: Scene, ratio?: number);
  24600. /**
  24601. * Checks wether everything is ready to render a submesh to the G buffer.
  24602. * @param subMesh the submesh to check readiness for
  24603. * @param useInstances is the mesh drawn using instance or not
  24604. * @returns true if ready otherwise false
  24605. */
  24606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24607. /**
  24608. * Gets the current underlying G Buffer.
  24609. * @returns the buffer
  24610. */
  24611. getGBuffer(): MultiRenderTarget;
  24612. /**
  24613. * Gets the number of samples used to render the buffer (anti aliasing).
  24614. */
  24615. /**
  24616. * Sets the number of samples used to render the buffer (anti aliasing).
  24617. */
  24618. samples: number;
  24619. /**
  24620. * Disposes the renderer and frees up associated resources.
  24621. */
  24622. dispose(): void;
  24623. protected _createRenderTargets(): void;
  24624. }
  24625. }
  24626. declare module BABYLON {
  24627. class OutlineRenderer {
  24628. private _scene;
  24629. private _effect;
  24630. private _cachedDefines;
  24631. zOffset: number;
  24632. constructor(scene: Scene);
  24633. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  24634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24635. }
  24636. }
  24637. declare module BABYLON {
  24638. class RenderingGroup {
  24639. index: number;
  24640. private _scene;
  24641. private _opaqueSubMeshes;
  24642. private _transparentSubMeshes;
  24643. private _alphaTestSubMeshes;
  24644. private _depthOnlySubMeshes;
  24645. private _particleSystems;
  24646. private _spriteManagers;
  24647. private _opaqueSortCompareFn;
  24648. private _alphaTestSortCompareFn;
  24649. private _transparentSortCompareFn;
  24650. private _renderOpaque;
  24651. private _renderAlphaTest;
  24652. private _renderTransparent;
  24653. private _edgesRenderers;
  24654. onBeforeTransparentRendering: () => void;
  24655. /**
  24656. * Set the opaque sort comparison function.
  24657. * If null the sub meshes will be render in the order they were created
  24658. */
  24659. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24660. /**
  24661. * Set the alpha test sort comparison function.
  24662. * If null the sub meshes will be render in the order they were created
  24663. */
  24664. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24665. /**
  24666. * Set the transparent sort comparison function.
  24667. * If null the sub meshes will be render in the order they were created
  24668. */
  24669. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  24670. /**
  24671. * Creates a new rendering group.
  24672. * @param index The rendering group index
  24673. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  24674. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  24675. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  24676. */
  24677. 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>);
  24678. /**
  24679. * Render all the sub meshes contained in the group.
  24680. * @param customRenderFunction Used to override the default render behaviour of the group.
  24681. * @returns true if rendered some submeshes.
  24682. */
  24683. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  24684. /**
  24685. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  24686. * @param subMeshes The submeshes to render
  24687. */
  24688. private renderOpaqueSorted(subMeshes);
  24689. /**
  24690. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  24691. * @param subMeshes The submeshes to render
  24692. */
  24693. private renderAlphaTestSorted(subMeshes);
  24694. /**
  24695. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  24696. * @param subMeshes The submeshes to render
  24697. */
  24698. private renderTransparentSorted(subMeshes);
  24699. /**
  24700. * Renders the submeshes in a specified order.
  24701. * @param subMeshes The submeshes to sort before render
  24702. * @param sortCompareFn The comparison function use to sort
  24703. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  24704. * @param transparent Specifies to activate blending if true
  24705. */
  24706. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  24707. /**
  24708. * Renders the submeshes in the order they were dispatched (no sort applied).
  24709. * @param subMeshes The submeshes to render
  24710. */
  24711. private static renderUnsorted(subMeshes);
  24712. /**
  24713. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  24714. * are rendered back to front if in the same alpha index.
  24715. *
  24716. * @param a The first submesh
  24717. * @param b The second submesh
  24718. * @returns The result of the comparison
  24719. */
  24720. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  24721. /**
  24722. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  24723. * are rendered back to front.
  24724. *
  24725. * @param a The first submesh
  24726. * @param b The second submesh
  24727. * @returns The result of the comparison
  24728. */
  24729. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  24730. /**
  24731. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  24732. * are rendered front to back (prevent overdraw).
  24733. *
  24734. * @param a The first submesh
  24735. * @param b The second submesh
  24736. * @returns The result of the comparison
  24737. */
  24738. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  24739. /**
  24740. * Resets the different lists of submeshes to prepare a new frame.
  24741. */
  24742. prepare(): void;
  24743. dispose(): void;
  24744. /**
  24745. * Inserts the submesh in its correct queue depending on its material.
  24746. * @param subMesh The submesh to dispatch
  24747. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  24748. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  24749. */
  24750. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  24751. dispatchSprites(spriteManager: SpriteManager): void;
  24752. dispatchParticles(particleSystem: IParticleSystem): void;
  24753. private _renderParticles(activeMeshes);
  24754. private _renderSprites();
  24755. }
  24756. }
  24757. declare module BABYLON {
  24758. class RenderingManager {
  24759. /**
  24760. * The max id used for rendering groups (not included)
  24761. */
  24762. static MAX_RENDERINGGROUPS: number;
  24763. /**
  24764. * The min id used for rendering groups (included)
  24765. */
  24766. static MIN_RENDERINGGROUPS: number;
  24767. /**
  24768. * Used to globally prevent autoclearing scenes.
  24769. */
  24770. static AUTOCLEAR: boolean;
  24771. private _scene;
  24772. private _renderingGroups;
  24773. private _depthStencilBufferAlreadyCleaned;
  24774. private _autoClearDepthStencil;
  24775. private _customOpaqueSortCompareFn;
  24776. private _customAlphaTestSortCompareFn;
  24777. private _customTransparentSortCompareFn;
  24778. private _renderinGroupInfo;
  24779. constructor(scene: Scene);
  24780. private _clearDepthStencilBuffer(depth?, stencil?);
  24781. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  24782. reset(): void;
  24783. dispose(): void;
  24784. /**
  24785. * Clear the info related to rendering groups preventing retention points during dispose.
  24786. */
  24787. freeRenderingGroups(): void;
  24788. private _prepareRenderingGroup(renderingGroupId);
  24789. dispatchSprites(spriteManager: SpriteManager): void;
  24790. dispatchParticles(particleSystem: IParticleSystem): void;
  24791. /**
  24792. * @param subMesh The submesh to dispatch
  24793. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  24794. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  24795. */
  24796. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  24797. /**
  24798. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24799. * This allowed control for front to back rendering or reversly depending of the special needs.
  24800. *
  24801. * @param renderingGroupId The rendering group id corresponding to its index
  24802. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24803. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24804. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24805. */
  24806. 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;
  24807. /**
  24808. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24809. *
  24810. * @param renderingGroupId The rendering group id corresponding to its index
  24811. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24812. * @param depth Automatically clears depth between groups if true and autoClear is true.
  24813. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  24814. */
  24815. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  24816. }
  24817. }
  24818. declare module BABYLON {
  24819. /**
  24820. * @hidden
  24821. **/
  24822. class _AlphaState {
  24823. private _isAlphaBlendDirty;
  24824. private _isBlendFunctionParametersDirty;
  24825. private _isBlendEquationParametersDirty;
  24826. private _isBlendConstantsDirty;
  24827. private _alphaBlend;
  24828. private _blendFunctionParameters;
  24829. private _blendEquationParameters;
  24830. private _blendConstants;
  24831. /**
  24832. * Initializes the state.
  24833. */
  24834. constructor();
  24835. readonly isDirty: boolean;
  24836. alphaBlend: boolean;
  24837. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  24838. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  24839. setAlphaEquationParameters(rgb: number, alpha: number): void;
  24840. reset(): void;
  24841. apply(gl: WebGLRenderingContext): void;
  24842. }
  24843. }
  24844. declare module BABYLON {
  24845. /**
  24846. * @hidden
  24847. **/
  24848. class _DepthCullingState {
  24849. private _isDepthTestDirty;
  24850. private _isDepthMaskDirty;
  24851. private _isDepthFuncDirty;
  24852. private _isCullFaceDirty;
  24853. private _isCullDirty;
  24854. private _isZOffsetDirty;
  24855. private _isFrontFaceDirty;
  24856. private _depthTest;
  24857. private _depthMask;
  24858. private _depthFunc;
  24859. private _cull;
  24860. private _cullFace;
  24861. private _zOffset;
  24862. private _frontFace;
  24863. /**
  24864. * Initializes the state.
  24865. */
  24866. constructor();
  24867. readonly isDirty: boolean;
  24868. zOffset: number;
  24869. cullFace: Nullable<number>;
  24870. cull: Nullable<boolean>;
  24871. depthFunc: Nullable<number>;
  24872. depthMask: boolean;
  24873. depthTest: boolean;
  24874. frontFace: Nullable<number>;
  24875. reset(): void;
  24876. apply(gl: WebGLRenderingContext): void;
  24877. }
  24878. }
  24879. declare module BABYLON {
  24880. /**
  24881. * @hidden
  24882. **/
  24883. class _StencilState {
  24884. private _isStencilTestDirty;
  24885. private _isStencilMaskDirty;
  24886. private _isStencilFuncDirty;
  24887. private _isStencilOpDirty;
  24888. private _stencilTest;
  24889. private _stencilMask;
  24890. private _stencilFunc;
  24891. private _stencilFuncRef;
  24892. private _stencilFuncMask;
  24893. private _stencilOpStencilFail;
  24894. private _stencilOpDepthFail;
  24895. private _stencilOpStencilDepthPass;
  24896. readonly isDirty: boolean;
  24897. stencilFunc: number;
  24898. stencilFuncRef: number;
  24899. stencilFuncMask: number;
  24900. stencilOpStencilFail: number;
  24901. stencilOpDepthFail: number;
  24902. stencilOpStencilDepthPass: number;
  24903. stencilMask: number;
  24904. stencilTest: boolean;
  24905. constructor();
  24906. reset(): void;
  24907. apply(gl: WebGLRenderingContext): void;
  24908. }
  24909. }
  24910. declare module BABYLON {
  24911. /**
  24912. * Postprocess used to generate anaglyphic rendering
  24913. */
  24914. class AnaglyphPostProcess extends PostProcess {
  24915. private _passedProcess;
  24916. /**
  24917. * Creates a new AnaglyphPostProcess
  24918. * @param name defines postprocess name
  24919. * @param options defines creation options or target ratio scale
  24920. * @param rigCameras defines cameras using this postprocess
  24921. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  24922. * @param engine defines hosting engine
  24923. * @param reusable defines if the postprocess will be reused multiple times per frame
  24924. */
  24925. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  24926. }
  24927. }
  24928. declare module BABYLON {
  24929. class BlackAndWhitePostProcess extends PostProcess {
  24930. degree: number;
  24931. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24932. }
  24933. }
  24934. declare module BABYLON {
  24935. /**
  24936. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  24937. */
  24938. class BloomEffect extends PostProcessRenderEffect {
  24939. private bloomScale;
  24940. /**
  24941. * Internal
  24942. */
  24943. /**
  24944. * Internal
  24945. */
  24946. private _blurX;
  24947. private _blurY;
  24948. private _merge;
  24949. /**
  24950. * The luminance threshold to find bright areas of the image to bloom.
  24951. */
  24952. threshold: number;
  24953. /**
  24954. * The strength of the bloom.
  24955. */
  24956. weight: number;
  24957. /**
  24958. * Specifies the size of the bloom blur kernel, relative to the final output size
  24959. */
  24960. kernel: number;
  24961. /**
  24962. * Creates a new instance of @see BloomEffect
  24963. * @param scene The scene the effect belongs to.
  24964. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  24965. * @param bloomKernel The size of the kernel to be used when applying the blur.
  24966. * @param bloomWeight The the strength of bloom.
  24967. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  24968. * @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)
  24969. */
  24970. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  24971. /**
  24972. * Disposes each of the internal effects for a given camera.
  24973. * @param camera The camera to dispose the effect on.
  24974. */
  24975. disposeEffects(camera: Camera): void;
  24976. /**
  24977. * Internal
  24978. */
  24979. /**
  24980. * Internal
  24981. * @returns if all the contained post processes are ready.
  24982. */
  24983. }
  24984. }
  24985. declare module BABYLON {
  24986. /**
  24987. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24988. */
  24989. class BloomMergePostProcess extends PostProcess {
  24990. /** Weight of the bloom to be added to the original input. */ weight: number;
  24991. /**
  24992. * Creates a new instance of @see BloomMergePostProcess
  24993. * @param name The name of the effect.
  24994. * @param originalFromInput Post process which's input will be used for the merge.
  24995. * @param blurred Blurred highlights post process which's output will be used.
  24996. * @param weight Weight of the bloom to be added to the original input.
  24997. * @param options The required width/height ratio to downsize to before computing the render pass.
  24998. * @param camera The camera to apply the render pass to.
  24999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25000. * @param engine The engine which the post process will be applied. (default: current engine)
  25001. * @param reusable If the post process can be reused on the same frame. (default: false)
  25002. * @param textureType Type of textures used when performing the post process. (default: 0)
  25003. * @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)
  25004. */
  25005. 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);
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * The Blur Post Process which blurs an image based on a kernel and direction.
  25011. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25012. */
  25013. class BlurPostProcess extends PostProcess {
  25014. /** The direction in which to blur the image. */ direction: Vector2;
  25015. private blockCompilation;
  25016. protected _kernel: number;
  25017. protected _idealKernel: number;
  25018. protected _packedFloat: boolean;
  25019. private _staticDefines;
  25020. /**
  25021. * Gets the length in pixels of the blur sample region
  25022. */
  25023. /**
  25024. * Sets the length in pixels of the blur sample region
  25025. */
  25026. kernel: number;
  25027. /**
  25028. * Gets wether or not the blur is unpacking/repacking floats
  25029. */
  25030. /**
  25031. * Sets wether or not the blur needs to unpack/repack floats
  25032. */
  25033. packedFloat: boolean;
  25034. /**
  25035. * Creates a new instance BlurPostProcess
  25036. * @param name The name of the effect.
  25037. * @param direction The direction in which to blur the image.
  25038. * @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.
  25039. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25040. * @param camera The camera to apply the render pass to.
  25041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25042. * @param engine The engine which the post process will be applied. (default: current engine)
  25043. * @param reusable If the post process can be reused on the same frame. (default: false)
  25044. * @param textureType Type of textures used when performing the post process. (default: 0)
  25045. * @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)
  25046. */
  25047. 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);
  25048. /**
  25049. * Updates the effect with the current post process compile time values and recompiles the shader.
  25050. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25051. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25052. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25053. * @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
  25054. * @param onCompiled Called when the shader has been compiled.
  25055. * @param onError Called if there is an error when compiling a shader.
  25056. */
  25057. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25058. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25059. /**
  25060. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25061. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25062. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25063. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25064. * The gaps between physical kernels are compensated for in the weighting of the samples
  25065. * @param idealKernel Ideal blur kernel.
  25066. * @return Nearest best kernel.
  25067. */
  25068. protected _nearestBestKernel(idealKernel: number): number;
  25069. /**
  25070. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25071. * @param x The point on the Gaussian distribution to sample.
  25072. * @return the value of the Gaussian function at x.
  25073. */
  25074. protected _gaussianWeight(x: number): number;
  25075. /**
  25076. * Generates a string that can be used as a floating point number in GLSL.
  25077. * @param x Value to print.
  25078. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25079. * @return GLSL float string.
  25080. */
  25081. protected _glslFloat(x: number, decimalFigures?: number): string;
  25082. }
  25083. }
  25084. declare module BABYLON {
  25085. /**
  25086. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25087. */
  25088. class ChromaticAberrationPostProcess extends PostProcess {
  25089. /**
  25090. * The amount of seperation of rgb channels (default: 30)
  25091. */
  25092. aberrationAmount: number;
  25093. /**
  25094. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25095. */
  25096. radialIntensity: number;
  25097. /**
  25098. * 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))
  25099. */
  25100. direction: Vector2;
  25101. /**
  25102. * 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))
  25103. */
  25104. centerPosition: Vector2;
  25105. /**
  25106. * Creates a new instance ChromaticAberrationPostProcess
  25107. * @param name The name of the effect.
  25108. * @param screenWidth The width of the screen to apply the effect on.
  25109. * @param screenHeight The height of the screen to apply the effect on.
  25110. * @param options The required width/height ratio to downsize to before computing the render pass.
  25111. * @param camera The camera to apply the render pass to.
  25112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25113. * @param engine The engine which the post process will be applied. (default: current engine)
  25114. * @param reusable If the post process can be reused on the same frame. (default: false)
  25115. * @param textureType Type of textures used when performing the post process. (default: 0)
  25116. * @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)
  25117. */
  25118. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25119. }
  25120. }
  25121. declare module BABYLON {
  25122. /**
  25123. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25124. */
  25125. class CircleOfConfusionPostProcess extends PostProcess {
  25126. /**
  25127. * 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.
  25128. */
  25129. lensSize: number;
  25130. /**
  25131. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25132. */
  25133. fStop: number;
  25134. /**
  25135. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25136. */
  25137. focusDistance: number;
  25138. /**
  25139. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25140. */
  25141. focalLength: number;
  25142. private _depthTexture;
  25143. /**
  25144. * Creates a new instance CircleOfConfusionPostProcess
  25145. * @param name The name of the effect.
  25146. * @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.
  25147. * @param options The required width/height ratio to downsize to before computing the render pass.
  25148. * @param camera The camera to apply the render pass to.
  25149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25150. * @param engine The engine which the post process will be applied. (default: current engine)
  25151. * @param reusable If the post process can be reused on the same frame. (default: false)
  25152. * @param textureType Type of textures used when performing the post process. (default: 0)
  25153. * @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)
  25154. */
  25155. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25156. /**
  25157. * 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.
  25158. */
  25159. depthTexture: RenderTargetTexture;
  25160. }
  25161. }
  25162. declare module BABYLON {
  25163. class ColorCorrectionPostProcess extends PostProcess {
  25164. private _colorTableTexture;
  25165. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25166. }
  25167. }
  25168. declare module BABYLON {
  25169. /**
  25170. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25171. * input texture to perform effects such as edge detection or sharpening
  25172. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25173. */
  25174. class ConvolutionPostProcess extends PostProcess {
  25175. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25176. /**
  25177. * Creates a new instance ConvolutionPostProcess
  25178. * @param name The name of the effect.
  25179. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25180. * @param options The required width/height ratio to downsize to before computing the render pass.
  25181. * @param camera The camera to apply the render pass to.
  25182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25183. * @param engine The engine which the post process will be applied. (default: current engine)
  25184. * @param reusable If the post process can be reused on the same frame. (default: false)
  25185. * @param textureType Type of textures used when performing the post process. (default: 0)
  25186. */
  25187. 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);
  25188. /**
  25189. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25190. */
  25191. static EdgeDetect0Kernel: number[];
  25192. /**
  25193. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25194. */
  25195. static EdgeDetect1Kernel: number[];
  25196. /**
  25197. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25198. */
  25199. static EdgeDetect2Kernel: number[];
  25200. /**
  25201. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25202. */
  25203. static SharpenKernel: number[];
  25204. /**
  25205. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25206. */
  25207. static EmbossKernel: number[];
  25208. /**
  25209. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25210. */
  25211. static GaussianKernel: number[];
  25212. }
  25213. }
  25214. declare module BABYLON {
  25215. /**
  25216. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25217. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25218. * based on samples that have a large difference in distance than the center pixel.
  25219. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25220. */
  25221. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25222. direction: Vector2;
  25223. /**
  25224. * Creates a new instance CircleOfConfusionPostProcess
  25225. * @param name The name of the effect.
  25226. * @param scene The scene the effect belongs to.
  25227. * @param direction The direction the blur should be applied.
  25228. * @param kernel The size of the kernel used to blur.
  25229. * @param options The required width/height ratio to downsize to before computing the render pass.
  25230. * @param camera The camera to apply the render pass to.
  25231. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25232. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25234. * @param engine The engine which the post process will be applied. (default: current engine)
  25235. * @param reusable If the post process can be reused on the same frame. (default: false)
  25236. * @param textureType Type of textures used when performing the post process. (default: 0)
  25237. * @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)
  25238. */
  25239. 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);
  25240. }
  25241. }
  25242. declare module BABYLON {
  25243. /**
  25244. * Specifies the level of max blur that should be applied when using the depth of field effect
  25245. */
  25246. enum DepthOfFieldEffectBlurLevel {
  25247. /**
  25248. * Subtle blur
  25249. */
  25250. Low = 0,
  25251. /**
  25252. * Medium blur
  25253. */
  25254. Medium = 1,
  25255. /**
  25256. * Large blur
  25257. */
  25258. High = 2,
  25259. }
  25260. /**
  25261. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25262. */
  25263. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25264. private _circleOfConfusion;
  25265. /**
  25266. * Internal, blurs from high to low
  25267. */
  25268. private _depthOfFieldBlurY;
  25269. private _dofMerge;
  25270. /**
  25271. * Internal post processes in depth of field effect
  25272. */
  25273. /**
  25274. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25275. */
  25276. focalLength: number;
  25277. /**
  25278. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25279. */
  25280. fStop: number;
  25281. /**
  25282. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25283. */
  25284. focusDistance: number;
  25285. /**
  25286. * 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.
  25287. */
  25288. lensSize: number;
  25289. /**
  25290. * Creates a new instance DepthOfFieldEffect
  25291. * @param scene The scene the effect belongs to.
  25292. * @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.
  25293. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25294. * @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)
  25295. */
  25296. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25297. /**
  25298. * 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.
  25299. */
  25300. depthTexture: RenderTargetTexture;
  25301. /**
  25302. * Disposes each of the internal effects for a given camera.
  25303. * @param camera The camera to dispose the effect on.
  25304. */
  25305. disposeEffects(camera: Camera): void;
  25306. /**
  25307. * Internal
  25308. */
  25309. /**
  25310. * Internal
  25311. * @returns if all the contained post processes are ready.
  25312. */
  25313. }
  25314. }
  25315. declare module BABYLON {
  25316. /**
  25317. * Options to be set when merging outputs from the default pipeline.
  25318. */
  25319. class DepthOfFieldMergePostProcessOptions {
  25320. /**
  25321. * The original image to merge on top of
  25322. */
  25323. originalFromInput: PostProcess;
  25324. /**
  25325. * Parameters to perform the merge of the depth of field effect
  25326. */
  25327. depthOfField?: {
  25328. circleOfConfusion: PostProcess;
  25329. blurSteps: Array<PostProcess>;
  25330. };
  25331. /**
  25332. * Parameters to perform the merge of bloom effect
  25333. */
  25334. bloom?: {
  25335. blurred: PostProcess;
  25336. weight: number;
  25337. };
  25338. }
  25339. /**
  25340. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25341. */
  25342. class DepthOfFieldMergePostProcess extends PostProcess {
  25343. private blurSteps;
  25344. /**
  25345. * Creates a new instance of DepthOfFieldMergePostProcess
  25346. * @param name The name of the effect.
  25347. * @param originalFromInput Post process which's input will be used for the merge.
  25348. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25349. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25350. * @param options The required width/height ratio to downsize to before computing the render pass.
  25351. * @param camera The camera to apply the render pass to.
  25352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25353. * @param engine The engine which the post process will be applied. (default: current engine)
  25354. * @param reusable If the post process can be reused on the same frame. (default: false)
  25355. * @param textureType Type of textures used when performing the post process. (default: 0)
  25356. * @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)
  25357. */
  25358. 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);
  25359. /**
  25360. * Updates the effect with the current post process compile time values and recompiles the shader.
  25361. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25362. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25363. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25364. * @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
  25365. * @param onCompiled Called when the shader has been compiled.
  25366. * @param onError Called if there is an error when compiling a shader.
  25367. */
  25368. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25369. }
  25370. }
  25371. declare module BABYLON {
  25372. class DisplayPassPostProcess extends PostProcess {
  25373. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25374. }
  25375. }
  25376. declare module BABYLON {
  25377. /**
  25378. * 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.
  25379. */
  25380. class ExtractHighlightsPostProcess extends PostProcess {
  25381. /**
  25382. * The luminance threshold, pixels below this value will be set to black.
  25383. */
  25384. threshold: number;
  25385. /**
  25386. * Internal
  25387. */
  25388. /**
  25389. * Post process which has the input texture to be used when performing highlight extraction
  25390. */
  25391. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25392. }
  25393. }
  25394. declare module BABYLON {
  25395. class FilterPostProcess extends PostProcess {
  25396. kernelMatrix: Matrix;
  25397. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25398. }
  25399. }
  25400. declare module BABYLON {
  25401. class FxaaPostProcess extends PostProcess {
  25402. texelWidth: number;
  25403. texelHeight: number;
  25404. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25405. private _getDefines();
  25406. }
  25407. }
  25408. declare module BABYLON {
  25409. /**
  25410. * The GrainPostProcess adds noise to the image at mid luminance levels
  25411. */
  25412. class GrainPostProcess extends PostProcess {
  25413. /**
  25414. * The intensity of the grain added (default: 30)
  25415. */
  25416. intensity: number;
  25417. /**
  25418. * If the grain should be randomized on every frame
  25419. */
  25420. animated: boolean;
  25421. /**
  25422. * Creates a new instance of @see GrainPostProcess
  25423. * @param name The name of the effect.
  25424. * @param options The required width/height ratio to downsize to before computing the render pass.
  25425. * @param camera The camera to apply the render pass to.
  25426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25427. * @param engine The engine which the post process will be applied. (default: current engine)
  25428. * @param reusable If the post process can be reused on the same frame. (default: false)
  25429. * @param textureType Type of textures used when performing the post process. (default: 0)
  25430. * @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)
  25431. */
  25432. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25433. }
  25434. }
  25435. declare module BABYLON {
  25436. class HighlightsPostProcess extends PostProcess {
  25437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25438. }
  25439. }
  25440. declare module BABYLON {
  25441. class ImageProcessingPostProcess extends PostProcess {
  25442. /**
  25443. * Default configuration related to image processing available in the PBR Material.
  25444. */
  25445. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25446. /**
  25447. * Gets the image processing configuration used either in this material.
  25448. */
  25449. /**
  25450. * Sets the Default image processing configuration used either in the this material.
  25451. *
  25452. * If sets to null, the scene one is in use.
  25453. */
  25454. imageProcessingConfiguration: ImageProcessingConfiguration;
  25455. /**
  25456. * Keep track of the image processing observer to allow dispose and replace.
  25457. */
  25458. private _imageProcessingObserver;
  25459. /**
  25460. * Attaches a new image processing configuration to the PBR Material.
  25461. * @param configuration
  25462. */
  25463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25464. /**
  25465. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25466. */
  25467. /**
  25468. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25469. */
  25470. colorCurves: Nullable<ColorCurves>;
  25471. /**
  25472. * Gets wether the color curves effect is enabled.
  25473. */
  25474. /**
  25475. * Sets wether the color curves effect is enabled.
  25476. */
  25477. colorCurvesEnabled: boolean;
  25478. /**
  25479. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25480. */
  25481. /**
  25482. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25483. */
  25484. colorGradingTexture: Nullable<BaseTexture>;
  25485. /**
  25486. * Gets wether the color grading effect is enabled.
  25487. */
  25488. /**
  25489. * Gets wether the color grading effect is enabled.
  25490. */
  25491. colorGradingEnabled: boolean;
  25492. /**
  25493. * Gets exposure used in the effect.
  25494. */
  25495. /**
  25496. * Sets exposure used in the effect.
  25497. */
  25498. exposure: number;
  25499. /**
  25500. * Gets wether tonemapping is enabled or not.
  25501. */
  25502. /**
  25503. * Sets wether tonemapping is enabled or not
  25504. */
  25505. toneMappingEnabled: boolean;
  25506. /**
  25507. * Gets contrast used in the effect.
  25508. */
  25509. /**
  25510. * Sets contrast used in the effect.
  25511. */
  25512. contrast: number;
  25513. /**
  25514. * Gets Vignette stretch size.
  25515. */
  25516. /**
  25517. * Sets Vignette stretch size.
  25518. */
  25519. vignetteStretch: number;
  25520. /**
  25521. * Gets Vignette centre X Offset.
  25522. */
  25523. /**
  25524. * Sets Vignette centre X Offset.
  25525. */
  25526. vignetteCentreX: number;
  25527. /**
  25528. * Gets Vignette centre Y Offset.
  25529. */
  25530. /**
  25531. * Sets Vignette centre Y Offset.
  25532. */
  25533. vignetteCentreY: number;
  25534. /**
  25535. * Gets Vignette weight or intensity of the vignette effect.
  25536. */
  25537. /**
  25538. * Sets Vignette weight or intensity of the vignette effect.
  25539. */
  25540. vignetteWeight: number;
  25541. /**
  25542. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25543. * if vignetteEnabled is set to true.
  25544. */
  25545. /**
  25546. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25547. * if vignetteEnabled is set to true.
  25548. */
  25549. vignetteColor: Color4;
  25550. /**
  25551. * Gets Camera field of view used by the Vignette effect.
  25552. */
  25553. /**
  25554. * Sets Camera field of view used by the Vignette effect.
  25555. */
  25556. vignetteCameraFov: number;
  25557. /**
  25558. * Gets the vignette blend mode allowing different kind of effect.
  25559. */
  25560. /**
  25561. * Sets the vignette blend mode allowing different kind of effect.
  25562. */
  25563. vignetteBlendMode: number;
  25564. /**
  25565. * Gets wether the vignette effect is enabled.
  25566. */
  25567. /**
  25568. * Sets wether the vignette effect is enabled.
  25569. */
  25570. vignetteEnabled: boolean;
  25571. private _fromLinearSpace;
  25572. /**
  25573. * Gets wether the input of the processing is in Gamma or Linear Space.
  25574. */
  25575. /**
  25576. * Sets wether the input of the processing is in Gamma or Linear Space.
  25577. */
  25578. fromLinearSpace: boolean;
  25579. /**
  25580. * Defines cache preventing GC.
  25581. */
  25582. private _defines;
  25583. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25584. getClassName(): string;
  25585. protected _updateParameters(): void;
  25586. dispose(camera?: Camera): void;
  25587. }
  25588. }
  25589. declare module BABYLON {
  25590. class PassPostProcess extends PostProcess {
  25591. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25592. }
  25593. }
  25594. declare module BABYLON {
  25595. type PostProcessOptions = {
  25596. width: number;
  25597. height: number;
  25598. };
  25599. /**
  25600. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25601. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25602. */
  25603. class PostProcess {
  25604. /** Name of the PostProcess. */ name: string;
  25605. /**
  25606. * Width of the texture to apply the post process on
  25607. */
  25608. width: number;
  25609. /**
  25610. * Height of the texture to apply the post process on
  25611. */
  25612. height: number;
  25613. /**
  25614. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25615. */
  25616. /**
  25617. * Sampling mode used by the shader
  25618. * See https://doc.babylonjs.com/classes/3.1/texture
  25619. */
  25620. renderTargetSamplingMode: number;
  25621. /**
  25622. * Clear color to use when screen clearing
  25623. */
  25624. clearColor: Color4;
  25625. /**
  25626. * If the buffer needs to be cleared before applying the post process. (default: true)
  25627. * Should be set to false if shader will overwrite all previous pixels.
  25628. */
  25629. autoClear: boolean;
  25630. /**
  25631. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25632. */
  25633. alphaMode: number;
  25634. /**
  25635. * Sets the setAlphaBlendConstants of the babylon engine
  25636. */
  25637. alphaConstants: Color4;
  25638. /**
  25639. * Animations to be used for the post processing
  25640. */
  25641. animations: Animation[];
  25642. /**
  25643. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25644. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25645. */
  25646. enablePixelPerfectMode: boolean;
  25647. /**
  25648. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25649. */
  25650. scaleMode: number;
  25651. /**
  25652. * Force textures to be a power of two (default: false)
  25653. */
  25654. alwaysForcePOT: boolean;
  25655. /**
  25656. * Number of sample textures (default: 1)
  25657. */
  25658. samples: number;
  25659. /**
  25660. * Modify the scale of the post process to be the same as the viewport (default: false)
  25661. */
  25662. adaptScaleToCurrentViewport: boolean;
  25663. private _camera;
  25664. private _scene;
  25665. private _engine;
  25666. private _options;
  25667. private _reusable;
  25668. private _textureType;
  25669. /**
  25670. * Smart array of input and output textures for the post process.
  25671. */
  25672. /**
  25673. * The index in _textures that corresponds to the output texture.
  25674. */
  25675. private _effect;
  25676. private _samplers;
  25677. private _fragmentUrl;
  25678. private _vertexUrl;
  25679. private _parameters;
  25680. private _scaleRatio;
  25681. protected _indexParameters: any;
  25682. private _shareOutputWithPostProcess;
  25683. private _texelSize;
  25684. private _forcedOutputTexture;
  25685. /**
  25686. * An event triggered when the postprocess is activated.
  25687. */
  25688. onActivateObservable: Observable<Camera>;
  25689. private _onActivateObserver;
  25690. /**
  25691. * A function that is added to the onActivateObservable
  25692. */
  25693. onActivate: Nullable<(camera: Camera) => void>;
  25694. /**
  25695. * An event triggered when the postprocess changes its size.
  25696. */
  25697. onSizeChangedObservable: Observable<PostProcess>;
  25698. private _onSizeChangedObserver;
  25699. /**
  25700. * A function that is added to the onSizeChangedObservable
  25701. */
  25702. onSizeChanged: (postProcess: PostProcess) => void;
  25703. /**
  25704. * An event triggered when the postprocess applies its effect.
  25705. */
  25706. onApplyObservable: Observable<Effect>;
  25707. private _onApplyObserver;
  25708. /**
  25709. * A function that is added to the onApplyObservable
  25710. */
  25711. onApply: (effect: Effect) => void;
  25712. /**
  25713. * An event triggered before rendering the postprocess
  25714. */
  25715. onBeforeRenderObservable: Observable<Effect>;
  25716. private _onBeforeRenderObserver;
  25717. /**
  25718. * A function that is added to the onBeforeRenderObservable
  25719. */
  25720. onBeforeRender: (effect: Effect) => void;
  25721. /**
  25722. * An event triggered after rendering the postprocess
  25723. */
  25724. onAfterRenderObservable: Observable<Effect>;
  25725. private _onAfterRenderObserver;
  25726. /**
  25727. * A function that is added to the onAfterRenderObservable
  25728. */
  25729. onAfterRender: (efect: Effect) => void;
  25730. /**
  25731. * 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
  25732. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  25733. */
  25734. inputTexture: InternalTexture;
  25735. /**
  25736. * Gets the camera which post process is applied to.
  25737. * @returns The camera the post process is applied to.
  25738. */
  25739. getCamera(): Camera;
  25740. /**
  25741. * Gets the texel size of the postprocess.
  25742. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  25743. */
  25744. readonly texelSize: Vector2;
  25745. /**
  25746. * Creates a new instance PostProcess
  25747. * @param name The name of the PostProcess.
  25748. * @param fragmentUrl The url of the fragment shader to be used.
  25749. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  25750. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  25751. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25752. * @param camera The camera to apply the render pass to.
  25753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25754. * @param engine The engine which the post process will be applied. (default: current engine)
  25755. * @param reusable If the post process can be reused on the same frame. (default: false)
  25756. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  25757. * @param textureType Type of textures used when performing the post process. (default: 0)
  25758. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  25759. * @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
  25760. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  25761. */
  25762. 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);
  25763. /**
  25764. * Gets the engine which this post process belongs to.
  25765. * @returns The engine the post process was enabled with.
  25766. */
  25767. getEngine(): Engine;
  25768. /**
  25769. * The effect that is created when initializing the post process.
  25770. * @returns The created effect corrisponding the the postprocess.
  25771. */
  25772. getEffect(): Effect;
  25773. /**
  25774. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  25775. * @param postProcess The post process to share the output with.
  25776. * @returns This post process.
  25777. */
  25778. shareOutputWith(postProcess: PostProcess): PostProcess;
  25779. /**
  25780. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  25781. * This should be called if the post process that shares output with this post process is disabled/disposed.
  25782. */
  25783. useOwnOutput(): void;
  25784. /**
  25785. * Updates the effect with the current post process compile time values and recompiles the shader.
  25786. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25787. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25788. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25789. * @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
  25790. * @param onCompiled Called when the shader has been compiled.
  25791. * @param onError Called if there is an error when compiling a shader.
  25792. */
  25793. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25794. /**
  25795. * The post process is reusable if it can be used multiple times within one frame.
  25796. * @returns If the post process is reusable
  25797. */
  25798. isReusable(): boolean;
  25799. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  25800. markTextureDirty(): void;
  25801. /**
  25802. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  25803. * 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.
  25804. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  25805. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  25806. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  25807. * @returns The target texture that was bound to be written to.
  25808. */
  25809. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  25810. /**
  25811. * If the post process is supported.
  25812. */
  25813. readonly isSupported: boolean;
  25814. /**
  25815. * The aspect ratio of the output texture.
  25816. */
  25817. readonly aspectRatio: number;
  25818. /**
  25819. * Get a value indicating if the post-process is ready to be used
  25820. * @returns true if the post-process is ready (shader is compiled)
  25821. */
  25822. isReady(): boolean;
  25823. /**
  25824. * Binds all textures and uniforms to the shader, this will be run on every pass.
  25825. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  25826. */
  25827. apply(): Nullable<Effect>;
  25828. private _disposeTextures();
  25829. /**
  25830. * Disposes the post process.
  25831. * @param camera The camera to dispose the post process on.
  25832. */
  25833. dispose(camera?: Camera): void;
  25834. }
  25835. }
  25836. declare module BABYLON {
  25837. /**
  25838. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25839. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25840. */
  25841. class PostProcessManager {
  25842. private _scene;
  25843. private _indexBuffer;
  25844. private _vertexBuffers;
  25845. /**
  25846. * Creates a new instance PostProcess
  25847. * @param scene The scene that the post process is associated with.
  25848. */
  25849. constructor(scene: Scene);
  25850. private _prepareBuffers();
  25851. private _buildIndexBuffer();
  25852. /**
  25853. * Rebuilds the vertex buffers of the manager.
  25854. */
  25855. /**
  25856. * Prepares a frame to be run through a post process.
  25857. * @param sourceTexture The input texture to the post procesess. (default: null)
  25858. * @param postProcesses An array of post processes to be run. (default: null)
  25859. * @returns True if the post processes were able to be run.
  25860. */
  25861. /**
  25862. * Manually render a set of post processes to a texture.
  25863. * @param postProcesses An array of post processes to be run.
  25864. * @param targetTexture The target texture to render to.
  25865. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25866. */
  25867. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  25868. /**
  25869. * Finalize the result of the output of the postprocesses.
  25870. * @param doNotPresent If true the result will not be displayed to the screen.
  25871. * @param targetTexture The target texture to render to.
  25872. * @param faceIndex The index of the face to bind the target texture to.
  25873. * @param postProcesses The array of post processes to render.
  25874. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25875. */
  25876. /**
  25877. * Disposes of the post process manager.
  25878. */
  25879. dispose(): void;
  25880. }
  25881. }
  25882. declare module BABYLON {
  25883. class RefractionPostProcess extends PostProcess {
  25884. color: Color3;
  25885. depth: number;
  25886. colorLevel: number;
  25887. private _refTexture;
  25888. private _ownRefractionTexture;
  25889. /**
  25890. * Gets or sets the refraction texture
  25891. * Please note that you are responsible for disposing the texture if you set it manually
  25892. */
  25893. refractionTexture: Texture;
  25894. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25895. dispose(camera: Camera): void;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * The SharpenPostProcess applies a sharpen kernel to every pixel
  25901. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25902. */
  25903. class SharpenPostProcess extends PostProcess {
  25904. /**
  25905. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  25906. */
  25907. colorAmount: number;
  25908. /**
  25909. * How much sharpness should be applied (default: 0.3)
  25910. */
  25911. edgeAmount: number;
  25912. /**
  25913. * Creates a new instance ConvolutionPostProcess
  25914. * @param name The name of the effect.
  25915. * @param options The required width/height ratio to downsize to before computing the render pass.
  25916. * @param camera The camera to apply the render pass to.
  25917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25918. * @param engine The engine which the post process will be applied. (default: current engine)
  25919. * @param reusable If the post process can be reused on the same frame. (default: false)
  25920. * @param textureType Type of textures used when performing the post process. (default: 0)
  25921. * @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)
  25922. */
  25923. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25924. }
  25925. }
  25926. declare module BABYLON {
  25927. class StereoscopicInterlacePostProcess extends PostProcess {
  25928. private _stepSize;
  25929. private _passedProcess;
  25930. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /** Defines operator used for tonemapping */
  25935. enum TonemappingOperator {
  25936. /** Hable */
  25937. Hable = 0,
  25938. /** Reinhard */
  25939. Reinhard = 1,
  25940. /** HejiDawson */
  25941. HejiDawson = 2,
  25942. /** Photographic */
  25943. Photographic = 3,
  25944. }
  25945. /**
  25946. * Defines a post process to apply tone mapping
  25947. */
  25948. class TonemapPostProcess extends PostProcess {
  25949. private _operator;
  25950. /** Defines the required exposure adjustement */
  25951. exposureAdjustment: number;
  25952. /**
  25953. * Creates a new TonemapPostProcess
  25954. * @param name defines the name of the postprocess
  25955. * @param _operator defines the operator to use
  25956. * @param exposureAdjustment defines the required exposure adjustement
  25957. * @param camera defines the camera to use (can be null)
  25958. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  25959. * @param engine defines the hosting engine (can be ignore if camera is set)
  25960. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  25961. */
  25962. constructor(name: string, _operator: TonemappingOperator,
  25963. /** Defines the required exposure adjustement */
  25964. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  25965. }
  25966. }
  25967. declare module BABYLON {
  25968. class VolumetricLightScatteringPostProcess extends PostProcess {
  25969. private _volumetricLightScatteringPass;
  25970. private _volumetricLightScatteringRTT;
  25971. private _viewPort;
  25972. private _screenCoordinates;
  25973. private _cachedDefines;
  25974. /**
  25975. * If not undefined, the mesh position is computed from the attached node position
  25976. */
  25977. attachedNode: {
  25978. position: Vector3;
  25979. };
  25980. /**
  25981. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  25982. */
  25983. customMeshPosition: Vector3;
  25984. /**
  25985. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  25986. */
  25987. useCustomMeshPosition: boolean;
  25988. /**
  25989. * If the post-process should inverse the light scattering direction
  25990. */
  25991. invert: boolean;
  25992. /**
  25993. * The internal mesh used by the post-process
  25994. */
  25995. mesh: Mesh;
  25996. useDiffuseColor: boolean;
  25997. /**
  25998. * Array containing the excluded meshes not rendered in the internal pass
  25999. */
  26000. excludedMeshes: AbstractMesh[];
  26001. /**
  26002. * Controls the overall intensity of the post-process
  26003. */
  26004. exposure: number;
  26005. /**
  26006. * Dissipates each sample's contribution in range [0, 1]
  26007. */
  26008. decay: number;
  26009. /**
  26010. * Controls the overall intensity of each sample
  26011. */
  26012. weight: number;
  26013. /**
  26014. * Controls the density of each sample
  26015. */
  26016. density: number;
  26017. /**
  26018. * @constructor
  26019. * @param {string} name - The post-process name
  26020. * @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)
  26021. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26022. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26023. * @param {number} samples - The post-process quality, default 100
  26024. * @param {number} samplingMode - The post-process filtering mode
  26025. * @param {BABYLON.Engine} engine - The babylon engine
  26026. * @param {boolean} reusable - If the post-process is reusable
  26027. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26028. */
  26029. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26030. getClassName(): string;
  26031. private _isReady(subMesh, useInstances);
  26032. /**
  26033. * Sets the new light position for light scattering effect
  26034. * @param {BABYLON.Vector3} The new custom light position
  26035. */
  26036. setCustomMeshPosition(position: Vector3): void;
  26037. /**
  26038. * Returns the light position for light scattering effect
  26039. * @return {BABYLON.Vector3} The custom light position
  26040. */
  26041. getCustomMeshPosition(): Vector3;
  26042. /**
  26043. * Disposes the internal assets and detaches the post-process from the camera
  26044. */
  26045. dispose(camera: Camera): void;
  26046. /**
  26047. * Returns the render target texture used by the post-process
  26048. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26049. */
  26050. getPass(): RenderTargetTexture;
  26051. private _meshExcluded(mesh);
  26052. private _createPass(scene, ratio);
  26053. private _updateMeshScreenCoordinates(scene);
  26054. /**
  26055. * Creates a default mesh for the Volumeric Light Scattering post-process
  26056. * @param {string} The mesh name
  26057. * @param {BABYLON.Scene} The scene where to create the mesh
  26058. * @return {BABYLON.Mesh} the default mesh
  26059. */
  26060. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26061. }
  26062. }
  26063. declare module BABYLON {
  26064. class VRDistortionCorrectionPostProcess extends PostProcess {
  26065. private _isRightEye;
  26066. private _distortionFactors;
  26067. private _postProcessScaleFactor;
  26068. private _lensCenterOffset;
  26069. private _scaleIn;
  26070. private _scaleFactor;
  26071. private _lensCenter;
  26072. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26073. }
  26074. }
  26075. declare module BABYLON {
  26076. /**
  26077. * Class used to evalaute queries containing `and` and `or` operators
  26078. */
  26079. class AndOrNotEvaluator {
  26080. /**
  26081. * Evaluate a query
  26082. * @param query defines the query to evaluate
  26083. * @param evaluateCallback defines the callback used to filter result
  26084. * @returns true if the query matches
  26085. */
  26086. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26087. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26088. private static _SimplifyNegation(booleanString);
  26089. }
  26090. }
  26091. declare module BABYLON {
  26092. /**
  26093. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26094. */
  26095. enum AssetTaskState {
  26096. /**
  26097. * Initialization
  26098. */
  26099. INIT = 0,
  26100. /**
  26101. * Running
  26102. */
  26103. RUNNING = 1,
  26104. /**
  26105. * Done
  26106. */
  26107. DONE = 2,
  26108. /**
  26109. * Error
  26110. */
  26111. ERROR = 3,
  26112. }
  26113. /**
  26114. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26115. */
  26116. abstract class AbstractAssetTask {
  26117. /**
  26118. * Task name
  26119. */ name: string;
  26120. /**
  26121. * Callback called when the task is successful
  26122. */
  26123. onSuccess: (task: any) => void;
  26124. /**
  26125. * Callback called when the task is not successful
  26126. */
  26127. onError: (task: any, message?: string, exception?: any) => void;
  26128. /**
  26129. * Creates a new {BABYLON.AssetsManager}
  26130. * @param name defines the name of the task
  26131. */
  26132. constructor(
  26133. /**
  26134. * Task name
  26135. */ name: string);
  26136. private _isCompleted;
  26137. private _taskState;
  26138. private _errorObject;
  26139. /**
  26140. * Get if the task is completed
  26141. */
  26142. readonly isCompleted: boolean;
  26143. /**
  26144. * Gets the current state of the task
  26145. */
  26146. readonly taskState: AssetTaskState;
  26147. /**
  26148. * Gets the current error object (if task is in error)
  26149. */
  26150. readonly errorObject: {
  26151. message?: string;
  26152. exception?: any;
  26153. };
  26154. /**
  26155. * Internal only
  26156. * @hidden
  26157. */
  26158. /**
  26159. * Execute the current task
  26160. * @param scene defines the scene where you want your assets to be loaded
  26161. * @param onSuccess is a callback called when the task is successfully executed
  26162. * @param onError is a callback called if an error occurs
  26163. */
  26164. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26165. /**
  26166. * Execute the current task
  26167. * @param scene defines the scene where you want your assets to be loaded
  26168. * @param onSuccess is a callback called when the task is successfully executed
  26169. * @param onError is a callback called if an error occurs
  26170. */
  26171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26172. private onErrorCallback(onError, message?, exception?);
  26173. private onDoneCallback(onSuccess, onError);
  26174. }
  26175. /**
  26176. * Define the interface used by progress events raised during assets loading
  26177. */
  26178. interface IAssetsProgressEvent {
  26179. /**
  26180. * Defines the number of remaining tasks to process
  26181. */
  26182. remainingCount: number;
  26183. /**
  26184. * Defines the total number of tasks
  26185. */
  26186. totalCount: number;
  26187. /**
  26188. * Defines the task that was just processed
  26189. */
  26190. task: AbstractAssetTask;
  26191. }
  26192. /**
  26193. * Class used to share progress information about assets loading
  26194. */
  26195. class AssetsProgressEvent implements IAssetsProgressEvent {
  26196. /**
  26197. * Defines the number of remaining tasks to process
  26198. */
  26199. remainingCount: number;
  26200. /**
  26201. * Defines the total number of tasks
  26202. */
  26203. totalCount: number;
  26204. /**
  26205. * Defines the task that was just processed
  26206. */
  26207. task: AbstractAssetTask;
  26208. /**
  26209. * Creates a {BABYLON.AssetsProgressEvent}
  26210. * @param remainingCount defines the number of remaining tasks to process
  26211. * @param totalCount defines the total number of tasks
  26212. * @param task defines the task that was just processed
  26213. */
  26214. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26215. }
  26216. /**
  26217. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26218. */
  26219. class MeshAssetTask extends AbstractAssetTask {
  26220. /**
  26221. * Defines the name of the task
  26222. */
  26223. name: string;
  26224. /**
  26225. * Defines the list of mesh's names you want to load
  26226. */
  26227. meshesNames: any;
  26228. /**
  26229. * Defines the root url to use as a base to load your meshes and associated resources
  26230. */
  26231. rootUrl: string;
  26232. /**
  26233. * Defines the filename of the scene to load from
  26234. */
  26235. sceneFilename: string;
  26236. /**
  26237. * Gets the list of loaded meshes
  26238. */
  26239. loadedMeshes: Array<AbstractMesh>;
  26240. /**
  26241. * Gets the list of loaded particle systems
  26242. */
  26243. loadedParticleSystems: Array<ParticleSystem>;
  26244. /**
  26245. * Gets the list of loaded skeletons
  26246. */
  26247. loadedSkeletons: Array<Skeleton>;
  26248. /**
  26249. * Callback called when the task is successful
  26250. */
  26251. onSuccess: (task: MeshAssetTask) => void;
  26252. /**
  26253. * Callback called when the task is successful
  26254. */
  26255. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26256. /**
  26257. * Creates a new {BABYLON.MeshAssetTask}
  26258. * @param name defines the name of the task
  26259. * @param meshesNames defines the list of mesh's names you want to load
  26260. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26261. * @param sceneFilename defines the filename of the scene to load from
  26262. */
  26263. constructor(
  26264. /**
  26265. * Defines the name of the task
  26266. */
  26267. name: string,
  26268. /**
  26269. * Defines the list of mesh's names you want to load
  26270. */
  26271. meshesNames: any,
  26272. /**
  26273. * Defines the root url to use as a base to load your meshes and associated resources
  26274. */
  26275. rootUrl: string,
  26276. /**
  26277. * Defines the filename of the scene to load from
  26278. */
  26279. sceneFilename: string);
  26280. /**
  26281. * Execute the current task
  26282. * @param scene defines the scene where you want your assets to be loaded
  26283. * @param onSuccess is a callback called when the task is successfully executed
  26284. * @param onError is a callback called if an error occurs
  26285. */
  26286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26287. }
  26288. /**
  26289. * Define a task used by {BABYLON.AssetsManager} to load text content
  26290. */
  26291. class TextFileAssetTask extends AbstractAssetTask {
  26292. /**
  26293. * Defines the name of the task
  26294. */
  26295. name: string;
  26296. /**
  26297. * Defines the location of the file to load
  26298. */
  26299. url: string;
  26300. /**
  26301. * Gets the loaded text string
  26302. */
  26303. text: string;
  26304. /**
  26305. * Callback called when the task is successful
  26306. */
  26307. onSuccess: (task: TextFileAssetTask) => void;
  26308. /**
  26309. * Callback called when the task is successful
  26310. */
  26311. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26312. /**
  26313. * Creates a new TextFileAssetTask object
  26314. * @param name defines the name of the task
  26315. * @param url defines the location of the file to load
  26316. */
  26317. constructor(
  26318. /**
  26319. * Defines the name of the task
  26320. */
  26321. name: string,
  26322. /**
  26323. * Defines the location of the file to load
  26324. */
  26325. url: string);
  26326. /**
  26327. * Execute the current task
  26328. * @param scene defines the scene where you want your assets to be loaded
  26329. * @param onSuccess is a callback called when the task is successfully executed
  26330. * @param onError is a callback called if an error occurs
  26331. */
  26332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26333. }
  26334. /**
  26335. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26336. */
  26337. class BinaryFileAssetTask extends AbstractAssetTask {
  26338. /**
  26339. * Defines the name of the task
  26340. */
  26341. name: string;
  26342. /**
  26343. * Defines the location of the file to load
  26344. */
  26345. url: string;
  26346. /**
  26347. * Gets the lodaded data (as an array buffer)
  26348. */
  26349. data: ArrayBuffer;
  26350. /**
  26351. * Callback called when the task is successful
  26352. */
  26353. onSuccess: (task: BinaryFileAssetTask) => void;
  26354. /**
  26355. * Callback called when the task is successful
  26356. */
  26357. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26358. /**
  26359. * Creates a new BinaryFileAssetTask object
  26360. * @param name defines the name of the new task
  26361. * @param url defines the location of the file to load
  26362. */
  26363. constructor(
  26364. /**
  26365. * Defines the name of the task
  26366. */
  26367. name: string,
  26368. /**
  26369. * Defines the location of the file to load
  26370. */
  26371. url: string);
  26372. /**
  26373. * Execute the current task
  26374. * @param scene defines the scene where you want your assets to be loaded
  26375. * @param onSuccess is a callback called when the task is successfully executed
  26376. * @param onError is a callback called if an error occurs
  26377. */
  26378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26379. }
  26380. /**
  26381. * Define a task used by {BABYLON.AssetsManager} to load images
  26382. */
  26383. class ImageAssetTask extends AbstractAssetTask {
  26384. /**
  26385. * Defines the name of the task
  26386. */
  26387. name: string;
  26388. /**
  26389. * Defines the location of the image to load
  26390. */
  26391. url: string;
  26392. /**
  26393. * Gets the loaded images
  26394. */
  26395. image: HTMLImageElement;
  26396. /**
  26397. * Callback called when the task is successful
  26398. */
  26399. onSuccess: (task: ImageAssetTask) => void;
  26400. /**
  26401. * Callback called when the task is successful
  26402. */
  26403. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26404. /**
  26405. * Creates a new ImageAssetTask
  26406. * @param name defines the name of the task
  26407. * @param url defines the location of the image to load
  26408. */
  26409. constructor(
  26410. /**
  26411. * Defines the name of the task
  26412. */
  26413. name: string,
  26414. /**
  26415. * Defines the location of the image to load
  26416. */
  26417. url: string);
  26418. /**
  26419. * Execute the current task
  26420. * @param scene defines the scene where you want your assets to be loaded
  26421. * @param onSuccess is a callback called when the task is successfully executed
  26422. * @param onError is a callback called if an error occurs
  26423. */
  26424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26425. }
  26426. /**
  26427. * Defines the interface used by texture loading tasks
  26428. */
  26429. interface ITextureAssetTask<TEX extends BaseTexture> {
  26430. /**
  26431. * Gets the loaded texture
  26432. */
  26433. texture: TEX;
  26434. }
  26435. /**
  26436. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26437. */
  26438. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26439. /**
  26440. * Defines the name of the task
  26441. */
  26442. name: string;
  26443. /**
  26444. * Defines the location of the file to load
  26445. */
  26446. url: string;
  26447. /**
  26448. * Defines if mipmap should not be generated (default is false)
  26449. */
  26450. noMipmap: boolean | undefined;
  26451. /**
  26452. * Defines if texture must be inverted on Y axis (default is false)
  26453. */
  26454. invertY: boolean | undefined;
  26455. /**
  26456. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26457. */
  26458. samplingMode: number;
  26459. /**
  26460. * Gets the loaded texture
  26461. */
  26462. texture: Texture;
  26463. /**
  26464. * Callback called when the task is successful
  26465. */
  26466. onSuccess: (task: TextureAssetTask) => void;
  26467. /**
  26468. * Callback called when the task is successful
  26469. */
  26470. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26471. /**
  26472. * Creates a new TextureAssetTask object
  26473. * @param name defines the name of the task
  26474. * @param url defines the location of the file to load
  26475. * @param noMipmap defines if mipmap should not be generated (default is false)
  26476. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26477. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26478. */
  26479. constructor(
  26480. /**
  26481. * Defines the name of the task
  26482. */
  26483. name: string,
  26484. /**
  26485. * Defines the location of the file to load
  26486. */
  26487. url: string,
  26488. /**
  26489. * Defines if mipmap should not be generated (default is false)
  26490. */
  26491. noMipmap?: boolean | undefined,
  26492. /**
  26493. * Defines if texture must be inverted on Y axis (default is false)
  26494. */
  26495. invertY?: boolean | undefined,
  26496. /**
  26497. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26498. */
  26499. samplingMode?: number);
  26500. /**
  26501. * Execute the current task
  26502. * @param scene defines the scene where you want your assets to be loaded
  26503. * @param onSuccess is a callback called when the task is successfully executed
  26504. * @param onError is a callback called if an error occurs
  26505. */
  26506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26507. }
  26508. /**
  26509. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26510. */
  26511. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26512. /**
  26513. * Defines the name of the task
  26514. */
  26515. name: string;
  26516. /**
  26517. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26518. */
  26519. url: string;
  26520. /**
  26521. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26522. */
  26523. extensions: string[] | undefined;
  26524. /**
  26525. * Defines if mipmaps should not be generated (default is false)
  26526. */
  26527. noMipmap: boolean | undefined;
  26528. /**
  26529. * Defines the explicit list of files (undefined by default)
  26530. */
  26531. files: string[] | undefined;
  26532. /**
  26533. * Gets the loaded texture
  26534. */
  26535. texture: CubeTexture;
  26536. /**
  26537. * Callback called when the task is successful
  26538. */
  26539. onSuccess: (task: CubeTextureAssetTask) => void;
  26540. /**
  26541. * Callback called when the task is successful
  26542. */
  26543. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26544. /**
  26545. * Creates a new CubeTextureAssetTask
  26546. * @param name defines the name of the task
  26547. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26548. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26549. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26550. * @param files defines the explicit list of files (undefined by default)
  26551. */
  26552. constructor(
  26553. /**
  26554. * Defines the name of the task
  26555. */
  26556. name: string,
  26557. /**
  26558. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26559. */
  26560. url: string,
  26561. /**
  26562. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26563. */
  26564. extensions?: string[] | undefined,
  26565. /**
  26566. * Defines if mipmaps should not be generated (default is false)
  26567. */
  26568. noMipmap?: boolean | undefined,
  26569. /**
  26570. * Defines the explicit list of files (undefined by default)
  26571. */
  26572. files?: string[] | undefined);
  26573. /**
  26574. * Execute the current task
  26575. * @param scene defines the scene where you want your assets to be loaded
  26576. * @param onSuccess is a callback called when the task is successfully executed
  26577. * @param onError is a callback called if an error occurs
  26578. */
  26579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26580. }
  26581. /**
  26582. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  26583. */
  26584. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  26585. /**
  26586. * Defines the name of the task
  26587. */
  26588. name: string;
  26589. /**
  26590. * Defines the location of the file to load
  26591. */
  26592. url: string;
  26593. /**
  26594. * Defines the desired size (the more it increases the longer the generation will be)
  26595. */
  26596. size: number;
  26597. /**
  26598. * Defines if mipmaps should not be generated (default is false)
  26599. */
  26600. noMipmap: boolean;
  26601. /**
  26602. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26603. */
  26604. generateHarmonics: boolean;
  26605. /**
  26606. * 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)
  26607. */
  26608. gammaSpace: boolean;
  26609. /**
  26610. * Internal Use Only
  26611. */
  26612. reserved: boolean;
  26613. /**
  26614. * Gets the loaded texture
  26615. */
  26616. texture: HDRCubeTexture;
  26617. /**
  26618. * Callback called when the task is successful
  26619. */
  26620. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  26621. /**
  26622. * Callback called when the task is successful
  26623. */
  26624. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  26625. /**
  26626. * Creates a new HDRCubeTextureAssetTask object
  26627. * @param name defines the name of the task
  26628. * @param url defines the location of the file to load
  26629. * @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.
  26630. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26631. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26632. * @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)
  26633. * @param reserved Internal use only
  26634. */
  26635. constructor(
  26636. /**
  26637. * Defines the name of the task
  26638. */
  26639. name: string,
  26640. /**
  26641. * Defines the location of the file to load
  26642. */
  26643. url: string,
  26644. /**
  26645. * Defines the desired size (the more it increases the longer the generation will be)
  26646. */
  26647. size: number,
  26648. /**
  26649. * Defines if mipmaps should not be generated (default is false)
  26650. */
  26651. noMipmap?: boolean,
  26652. /**
  26653. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26654. */
  26655. generateHarmonics?: boolean,
  26656. /**
  26657. * 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)
  26658. */
  26659. gammaSpace?: boolean,
  26660. /**
  26661. * Internal Use Only
  26662. */
  26663. reserved?: boolean);
  26664. /**
  26665. * Execute the current task
  26666. * @param scene defines the scene where you want your assets to be loaded
  26667. * @param onSuccess is a callback called when the task is successfully executed
  26668. * @param onError is a callback called if an error occurs
  26669. */
  26670. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26671. }
  26672. /**
  26673. * This class can be used to easily import assets into a scene
  26674. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  26675. */
  26676. class AssetsManager {
  26677. private _scene;
  26678. private _isLoading;
  26679. protected _tasks: AbstractAssetTask[];
  26680. protected _waitingTasksCount: number;
  26681. protected _totalTasksCount: number;
  26682. /**
  26683. * Callback called when all tasks are processed
  26684. */
  26685. onFinish: (tasks: AbstractAssetTask[]) => void;
  26686. /**
  26687. * Callback called when a task is successful
  26688. */
  26689. onTaskSuccess: (task: AbstractAssetTask) => void;
  26690. /**
  26691. * Callback called when a task had an error
  26692. */
  26693. onTaskError: (task: AbstractAssetTask) => void;
  26694. /**
  26695. * Callback called when a task is done (whatever the result is)
  26696. */
  26697. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  26698. /**
  26699. * Observable called when all tasks are processed
  26700. */
  26701. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  26702. /**
  26703. * Observable called when a task had an error
  26704. */
  26705. onTaskErrorObservable: Observable<AbstractAssetTask>;
  26706. /**
  26707. * Observable called when a task is successful
  26708. */
  26709. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  26710. /**
  26711. * Observable called when a task is done (whatever the result is)
  26712. */
  26713. onProgressObservable: Observable<IAssetsProgressEvent>;
  26714. /**
  26715. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  26716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26717. */
  26718. useDefaultLoadingScreen: boolean;
  26719. /**
  26720. * Creates a new AssetsManager
  26721. * @param scene defines the scene to work on
  26722. */
  26723. constructor(scene: Scene);
  26724. /**
  26725. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  26726. * @param taskName defines the name of the new task
  26727. * @param meshesNames defines the name of meshes to load
  26728. * @param rootUrl defines the root url to use to locate files
  26729. * @param sceneFilename defines the filename of the scene file
  26730. * @returns a new {BABYLON.MeshAssetTask} object
  26731. */
  26732. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  26733. /**
  26734. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  26735. * @param taskName defines the name of the new task
  26736. * @param url defines the url of the file to load
  26737. * @returns a new {BABYLON.TextFileAssetTask} object
  26738. */
  26739. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  26740. /**
  26741. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  26742. * @param taskName defines the name of the new task
  26743. * @param url defines the url of the file to load
  26744. * @returns a new {BABYLON.BinaryFileAssetTask} object
  26745. */
  26746. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  26747. /**
  26748. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  26749. * @param taskName defines the name of the new task
  26750. * @param url defines the url of the file to load
  26751. * @returns a new {BABYLON.ImageAssetTask} object
  26752. */
  26753. addImageTask(taskName: string, url: string): ImageAssetTask;
  26754. /**
  26755. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  26756. * @param taskName defines the name of the new task
  26757. * @param url defines the url of the file to load
  26758. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26759. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  26760. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  26761. * @returns a new {BABYLON.TextureAssetTask} object
  26762. */
  26763. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  26764. /**
  26765. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  26766. * @param taskName defines the name of the new task
  26767. * @param url defines the url of the file to load
  26768. * @param extensions defines the extension to use to load the cube map (can be null)
  26769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26770. * @param files defines the list of files to load (can be null)
  26771. * @returns a new {BABYLON.CubeTextureAssetTask} object
  26772. */
  26773. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  26774. /**
  26775. *
  26776. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  26777. * @param taskName defines the name of the new task
  26778. * @param url defines the url of the file to load
  26779. * @param size defines the size you want for the cubemap (can be null)
  26780. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26781. * @param generateHarmonics defines if you want to automatically generate (true by default)
  26782. * @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)
  26783. * @param reserved Internal use only
  26784. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  26785. */
  26786. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  26787. private _decreaseWaitingTasksCount(task);
  26788. private _runTask(task);
  26789. /**
  26790. * Reset the {BABYLON.AssetsManager} and remove all tasks
  26791. * @return the current instance of the {BABYLON.AssetsManager}
  26792. */
  26793. reset(): AssetsManager;
  26794. /**
  26795. * Start the loading process
  26796. * @return the current instance of the {BABYLON.AssetsManager}
  26797. */
  26798. load(): AssetsManager;
  26799. }
  26800. }
  26801. declare module BABYLON {
  26802. /**
  26803. * Class used to enable access to IndexedDB
  26804. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  26805. */
  26806. class Database {
  26807. private callbackManifestChecked;
  26808. private currentSceneUrl;
  26809. private db;
  26810. private _enableSceneOffline;
  26811. private _enableTexturesOffline;
  26812. private manifestVersionFound;
  26813. private mustUpdateRessources;
  26814. private hasReachedQuota;
  26815. private isSupported;
  26816. private idbFactory;
  26817. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  26818. static IsUASupportingBlobStorage: boolean;
  26819. /** Gets a boolean indicating if Database storate is enabled */
  26820. static IDBStorageEnabled: boolean;
  26821. /**
  26822. * Gets a boolean indicating if scene must be saved in the database
  26823. */
  26824. readonly enableSceneOffline: boolean;
  26825. /**
  26826. * Gets a boolean indicating if textures must be saved in the database
  26827. */
  26828. readonly enableTexturesOffline: boolean;
  26829. /**
  26830. * Creates a new Database
  26831. * @param urlToScene defines the url to load the scene
  26832. * @param callbackManifestChecked defines the callback to use when manifest is checked
  26833. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  26834. */
  26835. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  26836. private static _ParseURL;
  26837. private static _ReturnFullUrlLocation;
  26838. private _checkManifestFile();
  26839. /**
  26840. * Open the database and make it available
  26841. * @param successCallback defines the callback to call on success
  26842. * @param errorCallback defines the callback to call on error
  26843. */
  26844. openAsync(successCallback: () => void, errorCallback: () => void): void;
  26845. /**
  26846. * Loads an image from the database
  26847. * @param url defines the url to load from
  26848. * @param image defines the target DOM image
  26849. */
  26850. loadImageFromDB(url: string, image: HTMLImageElement): void;
  26851. private _loadImageFromDBAsync(url, image, notInDBCallback);
  26852. private _saveImageIntoDBAsync(url, image);
  26853. private _checkVersionFromDB(url, versionLoaded);
  26854. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  26855. private _saveVersionIntoDBAsync(url, callback);
  26856. /**
  26857. * Loads a file from database
  26858. * @param url defines the URL to load from
  26859. * @param sceneLoaded defines a callback to call on success
  26860. * @param progressCallBack defines a callback to call when progress changed
  26861. * @param errorCallback defines a callback to call on error
  26862. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  26863. */
  26864. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  26865. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  26866. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  26867. }
  26868. }
  26869. declare module BABYLON {
  26870. interface DDSInfo {
  26871. width: number;
  26872. height: number;
  26873. mipmapCount: number;
  26874. isFourCC: boolean;
  26875. isRGB: boolean;
  26876. isLuminance: boolean;
  26877. isCube: boolean;
  26878. isCompressed: boolean;
  26879. dxgiFormat: number;
  26880. textureType: number;
  26881. /** Sphericle polynomial created for the dds texture */
  26882. sphericalPolynomial?: SphericalPolynomial;
  26883. }
  26884. class DDSTools {
  26885. static StoreLODInAlphaChannel: boolean;
  26886. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  26887. private static _FloatView;
  26888. private static _Int32View;
  26889. private static _ToHalfFloat(value);
  26890. private static _FromHalfFloat(value);
  26891. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  26892. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  26893. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  26894. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  26895. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  26896. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  26897. private static _ExtractLongWordOrder(value);
  26898. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  26899. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  26900. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  26901. }
  26902. }
  26903. declare module BABYLON {
  26904. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26905. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26906. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26907. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26908. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26909. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26910. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26911. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26912. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26913. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26914. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26915. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26916. /**
  26917. * Decorator used to define property that can be serialized as reference to a camera
  26918. * @param sourceName defines the name of the property to decorate
  26919. */
  26920. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26921. class SerializationHelper {
  26922. static Serialize<T>(entity: T, serializationObject?: any): any;
  26923. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26924. static Clone<T>(creationFunction: () => T, source: T): T;
  26925. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26926. }
  26927. }
  26928. declare module BABYLON {
  26929. /**
  26930. * Wrapper class for promise with external resolve and reject.
  26931. */
  26932. class Deferred<T> {
  26933. /**
  26934. * The promise associated with this deferred object.
  26935. */
  26936. readonly promise: Promise<T>;
  26937. private _resolve;
  26938. private _reject;
  26939. /**
  26940. * The resolve method of the promise associated with this deferred object.
  26941. */
  26942. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  26943. /**
  26944. * The reject method of the promise associated with this deferred object.
  26945. */
  26946. readonly reject: (reason?: any) => void;
  26947. /**
  26948. * Constructor for this deferred object.
  26949. */
  26950. constructor();
  26951. }
  26952. }
  26953. declare module BABYLON {
  26954. class FilesInput {
  26955. static FilesToLoad: {
  26956. [key: string]: File;
  26957. };
  26958. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  26959. private _engine;
  26960. private _currentScene;
  26961. private _sceneLoadedCallback;
  26962. private _progressCallback;
  26963. private _additionalRenderLoopLogicCallback;
  26964. private _textureLoadingCallback;
  26965. private _startingProcessingFilesCallback;
  26966. private _onReloadCallback;
  26967. private _errorCallback;
  26968. private _elementToMonitor;
  26969. private _sceneFileToLoad;
  26970. private _filesToLoad;
  26971. 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);
  26972. private _dragEnterHandler;
  26973. private _dragOverHandler;
  26974. private _dropHandler;
  26975. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  26976. dispose(): void;
  26977. private renderFunction();
  26978. private drag(e);
  26979. private drop(eventDrop);
  26980. private _traverseFolder(folder, files, remaining, callback);
  26981. private _processFiles(files);
  26982. loadFiles(event: any): void;
  26983. private _processReload();
  26984. reload(): void;
  26985. }
  26986. }
  26987. declare module BABYLON {
  26988. /**
  26989. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  26990. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  26991. */
  26992. class KhronosTextureContainer {
  26993. arrayBuffer: any;
  26994. static HEADER_LEN: number;
  26995. static COMPRESSED_2D: number;
  26996. static COMPRESSED_3D: number;
  26997. static TEX_2D: number;
  26998. static TEX_3D: number;
  26999. glType: number;
  27000. glTypeSize: number;
  27001. glFormat: number;
  27002. glInternalFormat: number;
  27003. glBaseInternalFormat: number;
  27004. pixelWidth: number;
  27005. pixelHeight: number;
  27006. pixelDepth: number;
  27007. numberOfArrayElements: number;
  27008. numberOfFaces: number;
  27009. numberOfMipmapLevels: number;
  27010. bytesOfKeyValueData: number;
  27011. loadType: number;
  27012. /**
  27013. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27014. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27015. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27016. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27017. */
  27018. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27019. switchEndainness(val: number): number;
  27020. /**
  27021. * It is assumed that the texture has already been created & is currently bound
  27022. */
  27023. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27024. private _upload2DCompressedLevels(gl, loadMipmaps);
  27025. }
  27026. }
  27027. declare module BABYLON {
  27028. /**
  27029. * A class serves as a medium between the observable and its observers
  27030. */
  27031. class EventState {
  27032. /**
  27033. * Create a new EventState
  27034. * @param mask defines the mask associated with this state
  27035. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27036. * @param target defines the original target of the state
  27037. * @param currentTarget defines the current target of the state
  27038. */
  27039. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27040. /**
  27041. * Initialize the current event state
  27042. * @param mask defines the mask associated with this state
  27043. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27044. * @param target defines the original target of the state
  27045. * @param currentTarget defines the current target of the state
  27046. * @returns the current event state
  27047. */
  27048. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27049. /**
  27050. * An Observer can set this property to true to prevent subsequent observers of being notified
  27051. */
  27052. skipNextObservers: boolean;
  27053. /**
  27054. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27055. */
  27056. mask: number;
  27057. /**
  27058. * The object that originally notified the event
  27059. */
  27060. target?: any;
  27061. /**
  27062. * The current object in the bubbling phase
  27063. */
  27064. currentTarget?: any;
  27065. /**
  27066. * This will be populated with the return value of the last function that was executed.
  27067. * If it is the first function in the callback chain it will be the event data.
  27068. */
  27069. lastReturnValue?: any;
  27070. }
  27071. /**
  27072. * Represent an Observer registered to a given Observable object.
  27073. */
  27074. class Observer<T> {
  27075. /**
  27076. * Defines the callback to call when the observer is notified
  27077. */
  27078. callback: (eventData: T, eventState: EventState) => void;
  27079. /**
  27080. * Defines the mask of the observer (used to filter notifications)
  27081. */
  27082. mask: number;
  27083. /**
  27084. * Defines the current scope used to restore the JS context
  27085. */
  27086. scope: any;
  27087. /** @hidden */
  27088. /**
  27089. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27090. */
  27091. unregisterOnNextCall: boolean;
  27092. /**
  27093. * Creates a new observer
  27094. * @param callback defines the callback to call when the observer is notified
  27095. * @param mask defines the mask of the observer (used to filter notifications)
  27096. * @param scope defines the current scope used to restore the JS context
  27097. */
  27098. constructor(
  27099. /**
  27100. * Defines the callback to call when the observer is notified
  27101. */
  27102. callback: (eventData: T, eventState: EventState) => void,
  27103. /**
  27104. * Defines the mask of the observer (used to filter notifications)
  27105. */
  27106. mask: number,
  27107. /**
  27108. * Defines the current scope used to restore the JS context
  27109. */
  27110. scope?: any);
  27111. }
  27112. /**
  27113. * Represent a list of observers registered to multiple Observables object.
  27114. */
  27115. class MultiObserver<T> {
  27116. private _observers;
  27117. private _observables;
  27118. /**
  27119. * Release associated resources
  27120. */
  27121. dispose(): void;
  27122. /**
  27123. * Raise a callback when one of the observable will notify
  27124. * @param observables defines a list of observables to watch
  27125. * @param callback defines the callback to call on notification
  27126. * @param mask defines the mask used to filter notifications
  27127. * @param scope defines the current scope used to restore the JS context
  27128. * @returns the new MultiObserver
  27129. */
  27130. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27131. }
  27132. /**
  27133. * The Observable class is a simple implementation of the Observable pattern.
  27134. *
  27135. * 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.
  27136. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27137. * 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).
  27138. * 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.
  27139. */
  27140. class Observable<T> {
  27141. private _observers;
  27142. private _eventState;
  27143. private _onObserverAdded;
  27144. /**
  27145. * Creates a new observable
  27146. * @param onObserverAdded defines a callback to call when a new observer is added
  27147. */
  27148. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27149. /**
  27150. * Create a new Observer with the specified callback
  27151. * @param callback the callback that will be executed for that Observer
  27152. * @param mask the mask used to filter observers
  27153. * @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.
  27154. * @param scope optional scope for the callback to be called from
  27155. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27156. * @returns the new observer created for the callback
  27157. */
  27158. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27159. /**
  27160. * Remove an Observer from the Observable object
  27161. * @param observer the instance of the Observer to remove
  27162. * @returns false if it doesn't belong to this Observable
  27163. */
  27164. remove(observer: Nullable<Observer<T>>): boolean;
  27165. /**
  27166. * Remove a callback from the Observable object
  27167. * @param callback the callback to remove
  27168. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27169. * @returns false if it doesn't belong to this Observable
  27170. */
  27171. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27172. private _deferUnregister(observer);
  27173. /**
  27174. * Notify all Observers by calling their respective callback with the given data
  27175. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27176. * @param eventData defines the data to send to all observers
  27177. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27178. * @param target defines the original target of the state
  27179. * @param currentTarget defines the current target of the state
  27180. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27181. */
  27182. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27183. /**
  27184. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27185. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27186. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27187. * and it is crucial that all callbacks will be executed.
  27188. * The order of the callbacks is kept, callbacks are not executed parallel.
  27189. *
  27190. * @param eventData The data to be sent to each callback
  27191. * @param mask is used to filter observers defaults to -1
  27192. * @param target defines the callback target (see EventState)
  27193. * @param currentTarget defines he current object in the bubbling phase
  27194. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27195. */
  27196. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27197. /**
  27198. * Notify a specific observer
  27199. * @param observer defines the observer to notify
  27200. * @param eventData defines the data to be sent to each callback
  27201. * @param mask is used to filter observers defaults to -1
  27202. */
  27203. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27204. /**
  27205. * Gets a boolean indicating if the observable has at least one observer
  27206. * @returns true is the Observable has at least one Observer registered
  27207. */
  27208. hasObservers(): boolean;
  27209. /**
  27210. * Clear the list of observers
  27211. */
  27212. clear(): void;
  27213. /**
  27214. * Clone the current observable
  27215. * @returns a new observable
  27216. */
  27217. clone(): Observable<T>;
  27218. /**
  27219. * Does this observable handles observer registered with a given mask
  27220. * @param mask defines the mask to be tested
  27221. * @return whether or not one observer registered with the given mask is handeled
  27222. **/
  27223. hasSpecificMask(mask?: number): boolean;
  27224. }
  27225. }
  27226. declare module BABYLON {
  27227. /**
  27228. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27229. */
  27230. class PerformanceMonitor {
  27231. private _enabled;
  27232. private _rollingFrameTime;
  27233. private _lastFrameTimeMs;
  27234. /**
  27235. * constructor
  27236. * @param frameSampleSize The number of samples required to saturate the sliding window
  27237. */
  27238. constructor(frameSampleSize?: number);
  27239. /**
  27240. * Samples current frame
  27241. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27242. */
  27243. sampleFrame(timeMs?: number): void;
  27244. /**
  27245. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27246. * @return Average frame time in milliseconds
  27247. */
  27248. readonly averageFrameTime: number;
  27249. /**
  27250. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27251. * @return Frame time variance in milliseconds squared
  27252. */
  27253. readonly averageFrameTimeVariance: number;
  27254. /**
  27255. * Returns the frame time of the most recent frame
  27256. * @return Frame time in milliseconds
  27257. */
  27258. readonly instantaneousFrameTime: number;
  27259. /**
  27260. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27261. * @return Framerate in frames per second
  27262. */
  27263. readonly averageFPS: number;
  27264. /**
  27265. * Returns the average framerate in frames per second using the most recent frame time
  27266. * @return Framerate in frames per second
  27267. */
  27268. readonly instantaneousFPS: number;
  27269. /**
  27270. * Returns true if enough samples have been taken to completely fill the sliding window
  27271. * @return true if saturated
  27272. */
  27273. readonly isSaturated: boolean;
  27274. /**
  27275. * Enables contributions to the sliding window sample set
  27276. */
  27277. enable(): void;
  27278. /**
  27279. * Disables contributions to the sliding window sample set
  27280. * Samples will not be interpolated over the disabled period
  27281. */
  27282. disable(): void;
  27283. /**
  27284. * Returns true if sampling is enabled
  27285. * @return true if enabled
  27286. */
  27287. readonly isEnabled: boolean;
  27288. /**
  27289. * Resets performance monitor
  27290. */
  27291. reset(): void;
  27292. }
  27293. /**
  27294. * RollingAverage
  27295. *
  27296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27297. */
  27298. class RollingAverage {
  27299. /**
  27300. * Current average
  27301. */
  27302. average: number;
  27303. /**
  27304. * Current variance
  27305. */
  27306. variance: number;
  27307. protected _samples: Array<number>;
  27308. protected _sampleCount: number;
  27309. protected _pos: number;
  27310. protected _m2: number;
  27311. /**
  27312. * constructor
  27313. * @param length The number of samples required to saturate the sliding window
  27314. */
  27315. constructor(length: number);
  27316. /**
  27317. * Adds a sample to the sample set
  27318. * @param v The sample value
  27319. */
  27320. add(v: number): void;
  27321. /**
  27322. * Returns previously added values or null if outside of history or outside the sliding window domain
  27323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27324. * @return Value previously recorded with add() or null if outside of range
  27325. */
  27326. history(i: number): number;
  27327. /**
  27328. * Returns true if enough samples have been taken to completely fill the sliding window
  27329. * @return true if sample-set saturated
  27330. */
  27331. isSaturated(): boolean;
  27332. /**
  27333. * Resets the rolling average (equivalent to 0 samples taken so far)
  27334. */
  27335. reset(): void;
  27336. /**
  27337. * Wraps a value around the sample range boundaries
  27338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27339. * @return Wrapped position in sample range
  27340. */
  27341. protected _wrapPosition(i: number): number;
  27342. }
  27343. }
  27344. declare module BABYLON {
  27345. /**
  27346. * Helper class that provides a small promise polyfill
  27347. */
  27348. class PromisePolyfill {
  27349. /**
  27350. * Static function used to check if the polyfill is required
  27351. * If this is the case then the function will inject the polyfill to window.Promise
  27352. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27353. */
  27354. static Apply(force?: boolean): void;
  27355. }
  27356. }
  27357. declare module BABYLON {
  27358. /**
  27359. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27360. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27361. */
  27362. class SceneOptimization {
  27363. /**
  27364. * Defines the priority of this optimization (0 by default which means first in the list)
  27365. */
  27366. priority: number;
  27367. /**
  27368. * Gets a string describing the action executed by the current optimization
  27369. * @returns description string
  27370. */
  27371. getDescription(): string;
  27372. /**
  27373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27374. * @param scene defines the current scene where to apply this optimization
  27375. * @param optimizer defines the current optimizer
  27376. * @returns true if everything that can be done was applied
  27377. */
  27378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27379. /**
  27380. * Creates the SceneOptimization object
  27381. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27382. * @param desc defines the description associated with the optimization
  27383. */
  27384. constructor(
  27385. /**
  27386. * Defines the priority of this optimization (0 by default which means first in the list)
  27387. */
  27388. priority?: number);
  27389. }
  27390. /**
  27391. * Defines an optimization used to reduce the size of render target textures
  27392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27393. */
  27394. class TextureOptimization extends SceneOptimization {
  27395. /**
  27396. * Defines the priority of this optimization (0 by default which means first in the list)
  27397. */
  27398. priority: number;
  27399. /**
  27400. * 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
  27401. */
  27402. maximumSize: number;
  27403. /**
  27404. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27405. */
  27406. step: number;
  27407. /**
  27408. * Gets a string describing the action executed by the current optimization
  27409. * @returns description string
  27410. */
  27411. getDescription(): string;
  27412. /**
  27413. * Creates the TextureOptimization object
  27414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27415. * @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
  27416. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27417. */
  27418. constructor(
  27419. /**
  27420. * Defines the priority of this optimization (0 by default which means first in the list)
  27421. */
  27422. priority?: number,
  27423. /**
  27424. * 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
  27425. */
  27426. maximumSize?: number,
  27427. /**
  27428. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27429. */
  27430. step?: number);
  27431. /**
  27432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27433. * @param scene defines the current scene where to apply this optimization
  27434. * @param optimizer defines the current optimizer
  27435. * @returns true if everything that can be done was applied
  27436. */
  27437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27438. }
  27439. /**
  27440. * Defines an optimization used to increase or decrease the rendering resolution
  27441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27442. */
  27443. class HardwareScalingOptimization extends SceneOptimization {
  27444. /**
  27445. * Defines the priority of this optimization (0 by default which means first in the list)
  27446. */
  27447. priority: number;
  27448. /**
  27449. * Defines the maximum scale to use (2 by default)
  27450. */
  27451. maximumScale: number;
  27452. /**
  27453. * Defines the step to use between two passes (0.5 by default)
  27454. */
  27455. step: number;
  27456. private _currentScale;
  27457. private _directionOffset;
  27458. /**
  27459. * Gets a string describing the action executed by the current optimization
  27460. * @return description string
  27461. */
  27462. getDescription(): string;
  27463. /**
  27464. * Creates the HardwareScalingOptimization object
  27465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27466. * @param maximumScale defines the maximum scale to use (2 by default)
  27467. * @param step defines the step to use between two passes (0.5 by default)
  27468. */
  27469. constructor(
  27470. /**
  27471. * Defines the priority of this optimization (0 by default which means first in the list)
  27472. */
  27473. priority?: number,
  27474. /**
  27475. * Defines the maximum scale to use (2 by default)
  27476. */
  27477. maximumScale?: number,
  27478. /**
  27479. * Defines the step to use between two passes (0.5 by default)
  27480. */
  27481. step?: number);
  27482. /**
  27483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27484. * @param scene defines the current scene where to apply this optimization
  27485. * @param optimizer defines the current optimizer
  27486. * @returns true if everything that can be done was applied
  27487. */
  27488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27489. }
  27490. /**
  27491. * Defines an optimization used to remove shadows
  27492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27493. */
  27494. class ShadowsOptimization extends SceneOptimization {
  27495. /**
  27496. * Gets a string describing the action executed by the current optimization
  27497. * @return description string
  27498. */
  27499. getDescription(): string;
  27500. /**
  27501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27502. * @param scene defines the current scene where to apply this optimization
  27503. * @param optimizer defines the current optimizer
  27504. * @returns true if everything that can be done was applied
  27505. */
  27506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27507. }
  27508. /**
  27509. * Defines an optimization used to turn post-processes off
  27510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27511. */
  27512. class PostProcessesOptimization extends SceneOptimization {
  27513. /**
  27514. * Gets a string describing the action executed by the current optimization
  27515. * @return description string
  27516. */
  27517. getDescription(): string;
  27518. /**
  27519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27520. * @param scene defines the current scene where to apply this optimization
  27521. * @param optimizer defines the current optimizer
  27522. * @returns true if everything that can be done was applied
  27523. */
  27524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27525. }
  27526. /**
  27527. * Defines an optimization used to turn lens flares off
  27528. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27529. */
  27530. class LensFlaresOptimization extends SceneOptimization {
  27531. /**
  27532. * Gets a string describing the action executed by the current optimization
  27533. * @return description string
  27534. */
  27535. getDescription(): string;
  27536. /**
  27537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27538. * @param scene defines the current scene where to apply this optimization
  27539. * @param optimizer defines the current optimizer
  27540. * @returns true if everything that can be done was applied
  27541. */
  27542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27543. }
  27544. /**
  27545. * Defines an optimization based on user defined callback.
  27546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27547. */
  27548. class CustomOptimization extends SceneOptimization {
  27549. /**
  27550. * Callback called to apply the custom optimization.
  27551. */
  27552. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  27553. /**
  27554. * Callback called to get custom description
  27555. */
  27556. onGetDescription: () => string;
  27557. /**
  27558. * Gets a string describing the action executed by the current optimization
  27559. * @returns description string
  27560. */
  27561. getDescription(): string;
  27562. /**
  27563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27564. * @param scene defines the current scene where to apply this optimization
  27565. * @param optimizer defines the current optimizer
  27566. * @returns true if everything that can be done was applied
  27567. */
  27568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27569. }
  27570. /**
  27571. * Defines an optimization used to turn particles off
  27572. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27573. */
  27574. class ParticlesOptimization extends SceneOptimization {
  27575. /**
  27576. * Gets a string describing the action executed by the current optimization
  27577. * @return description string
  27578. */
  27579. getDescription(): string;
  27580. /**
  27581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27582. * @param scene defines the current scene where to apply this optimization
  27583. * @param optimizer defines the current optimizer
  27584. * @returns true if everything that can be done was applied
  27585. */
  27586. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27587. }
  27588. /**
  27589. * Defines an optimization used to turn render targets off
  27590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27591. */
  27592. class RenderTargetsOptimization extends SceneOptimization {
  27593. /**
  27594. * Gets a string describing the action executed by the current optimization
  27595. * @return description string
  27596. */
  27597. getDescription(): string;
  27598. /**
  27599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27600. * @param scene defines the current scene where to apply this optimization
  27601. * @param optimizer defines the current optimizer
  27602. * @returns true if everything that can be done was applied
  27603. */
  27604. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27605. }
  27606. /**
  27607. * Defines an optimization used to merge meshes with compatible materials
  27608. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27609. */
  27610. class MergeMeshesOptimization extends SceneOptimization {
  27611. private static _UpdateSelectionTree;
  27612. /**
  27613. * Gets or sets a boolean which defines if optimization octree has to be updated
  27614. */
  27615. /**
  27616. * Gets or sets a boolean which defines if optimization octree has to be updated
  27617. */
  27618. static UpdateSelectionTree: boolean;
  27619. /**
  27620. * Gets a string describing the action executed by the current optimization
  27621. * @return description string
  27622. */
  27623. getDescription(): string;
  27624. private _canBeMerged;
  27625. /**
  27626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27627. * @param scene defines the current scene where to apply this optimization
  27628. * @param optimizer defines the current optimizer
  27629. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  27630. * @returns true if everything that can be done was applied
  27631. */
  27632. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  27633. }
  27634. /**
  27635. * Defines a list of options used by SceneOptimizer
  27636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27637. */
  27638. class SceneOptimizerOptions {
  27639. /**
  27640. * Defines the target frame rate to reach (60 by default)
  27641. */
  27642. targetFrameRate: number;
  27643. /**
  27644. * Defines the interval between two checkes (2000ms by default)
  27645. */
  27646. trackerDuration: number;
  27647. /**
  27648. * Gets the list of optimizations to apply
  27649. */
  27650. optimizations: SceneOptimization[];
  27651. /**
  27652. * Creates a new list of options used by SceneOptimizer
  27653. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  27654. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  27655. */
  27656. constructor(
  27657. /**
  27658. * Defines the target frame rate to reach (60 by default)
  27659. */
  27660. targetFrameRate?: number,
  27661. /**
  27662. * Defines the interval between two checkes (2000ms by default)
  27663. */
  27664. trackerDuration?: number);
  27665. /**
  27666. * Add a new optimization
  27667. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  27668. * @returns the current SceneOptimizerOptions
  27669. */
  27670. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  27671. /**
  27672. * Add a new custom optimization
  27673. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  27674. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  27675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27676. * @returns the current SceneOptimizerOptions
  27677. */
  27678. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  27679. /**
  27680. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  27681. * @param targetFrameRate defines the target frame rate (60 by default)
  27682. * @returns a SceneOptimizerOptions object
  27683. */
  27684. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27685. /**
  27686. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  27687. * @param targetFrameRate defines the target frame rate (60 by default)
  27688. * @returns a SceneOptimizerOptions object
  27689. */
  27690. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27691. /**
  27692. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  27693. * @param targetFrameRate defines the target frame rate (60 by default)
  27694. * @returns a SceneOptimizerOptions object
  27695. */
  27696. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27697. }
  27698. /**
  27699. * Class used to run optimizations in order to reach a target frame rate
  27700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27701. */
  27702. class SceneOptimizer implements IDisposable {
  27703. private _isRunning;
  27704. private _options;
  27705. private _scene;
  27706. private _currentPriorityLevel;
  27707. private _targetFrameRate;
  27708. private _trackerDuration;
  27709. private _currentFrameRate;
  27710. private _sceneDisposeObserver;
  27711. private _improvementMode;
  27712. /**
  27713. * Defines an observable called when the optimizer reaches the target frame rate
  27714. */
  27715. onSuccessObservable: Observable<SceneOptimizer>;
  27716. /**
  27717. * Defines an observable called when the optimizer enables an optimization
  27718. */
  27719. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  27720. /**
  27721. * Defines an observable called when the optimizer is not able to reach the target frame rate
  27722. */
  27723. onFailureObservable: Observable<SceneOptimizer>;
  27724. /**
  27725. * Gets a boolean indicating if the optimizer is in improvement mode
  27726. */
  27727. readonly isInImprovementMode: boolean;
  27728. /**
  27729. * Gets the current priority level (0 at start)
  27730. */
  27731. readonly currentPriorityLevel: number;
  27732. /**
  27733. * Gets the current frame rate checked by the SceneOptimizer
  27734. */
  27735. readonly currentFrameRate: number;
  27736. /**
  27737. * Gets or sets the current target frame rate (60 by default)
  27738. */
  27739. /**
  27740. * Gets or sets the current target frame rate (60 by default)
  27741. */
  27742. targetFrameRate: number;
  27743. /**
  27744. * Gets or sets the current interval between two checks (every 2000ms by default)
  27745. */
  27746. /**
  27747. * Gets or sets the current interval between two checks (every 2000ms by default)
  27748. */
  27749. trackerDuration: number;
  27750. /**
  27751. * Gets the list of active optimizations
  27752. */
  27753. readonly optimizations: SceneOptimization[];
  27754. /**
  27755. * Creates a new SceneOptimizer
  27756. * @param scene defines the scene to work on
  27757. * @param options defines the options to use with the SceneOptimizer
  27758. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  27759. * @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)
  27760. */
  27761. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  27762. /**
  27763. * Stops the current optimizer
  27764. */
  27765. stop(): void;
  27766. /**
  27767. * Reset the optimizer to initial step (current priority level = 0)
  27768. */
  27769. reset(): void;
  27770. /**
  27771. * Start the optimizer. By default it will try to reach a specific framerate
  27772. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  27773. */
  27774. start(): void;
  27775. private _checkCurrentState();
  27776. /**
  27777. * Release all resources
  27778. */
  27779. dispose(): void;
  27780. /**
  27781. * Helper function to create a SceneOptimizer with one single line of code
  27782. * @param scene defines the scene to work on
  27783. * @param options defines the options to use with the SceneOptimizer
  27784. * @param onSuccess defines a callback to call on success
  27785. * @param onFailure defines a callback to call on failure
  27786. * @returns the new SceneOptimizer object
  27787. */
  27788. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  27789. }
  27790. }
  27791. declare module BABYLON {
  27792. class SceneSerializer {
  27793. static ClearCache(): void;
  27794. static Serialize(scene: Scene): any;
  27795. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  27796. }
  27797. }
  27798. declare module BABYLON {
  27799. class SmartArray<T> {
  27800. data: Array<T>;
  27801. length: number;
  27802. protected _id: number;
  27803. [index: number]: T;
  27804. constructor(capacity: number);
  27805. push(value: T): void;
  27806. forEach(func: (content: T) => void): void;
  27807. sort(compareFn: (a: T, b: T) => number): void;
  27808. reset(): void;
  27809. dispose(): void;
  27810. concat(array: any): void;
  27811. indexOf(value: T): number;
  27812. contains(value: T): boolean;
  27813. private static _GlobalId;
  27814. }
  27815. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  27816. private _duplicateId;
  27817. [index: number]: T;
  27818. push(value: T): void;
  27819. pushNoDuplicate(value: T): boolean;
  27820. reset(): void;
  27821. concatWithNoDuplicate(array: any): void;
  27822. }
  27823. }
  27824. declare module BABYLON {
  27825. /**
  27826. * This class implement a typical dictionary using a string as key and the generic type T as value.
  27827. * The underlying implementation relies on an associative array to ensure the best performances.
  27828. * The value can be anything including 'null' but except 'undefined'
  27829. */
  27830. class StringDictionary<T> {
  27831. /**
  27832. * This will clear this dictionary and copy the content from the 'source' one.
  27833. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  27834. * @param source the dictionary to take the content from and copy to this dictionary
  27835. */
  27836. copyFrom(source: StringDictionary<T>): void;
  27837. /**
  27838. * Get a value based from its key
  27839. * @param key the given key to get the matching value from
  27840. * @return the value if found, otherwise undefined is returned
  27841. */
  27842. get(key: string): T | undefined;
  27843. /**
  27844. * Get a value from its key or add it if it doesn't exist.
  27845. * This method will ensure you that a given key/data will be present in the dictionary.
  27846. * @param key the given key to get the matching value from
  27847. * @param factory the factory that will create the value if the key is not present in the dictionary.
  27848. * The factory will only be invoked if there's no data for the given key.
  27849. * @return the value corresponding to the key.
  27850. */
  27851. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  27852. /**
  27853. * Get a value from its key if present in the dictionary otherwise add it
  27854. * @param key the key to get the value from
  27855. * @param val if there's no such key/value pair in the dictionary add it with this value
  27856. * @return the value corresponding to the key
  27857. */
  27858. getOrAdd(key: string, val: T): T;
  27859. /**
  27860. * Check if there's a given key in the dictionary
  27861. * @param key the key to check for
  27862. * @return true if the key is present, false otherwise
  27863. */
  27864. contains(key: string): boolean;
  27865. /**
  27866. * Add a new key and its corresponding value
  27867. * @param key the key to add
  27868. * @param value the value corresponding to the key
  27869. * @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
  27870. */
  27871. add(key: string, value: T): boolean;
  27872. set(key: string, value: T): boolean;
  27873. /**
  27874. * Get the element of the given key and remove it from the dictionary
  27875. * @param key
  27876. */
  27877. getAndRemove(key: string): Nullable<T>;
  27878. /**
  27879. * Remove a key/value from the dictionary.
  27880. * @param key the key to remove
  27881. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  27882. */
  27883. remove(key: string): boolean;
  27884. /**
  27885. * Clear the whole content of the dictionary
  27886. */
  27887. clear(): void;
  27888. readonly count: number;
  27889. /**
  27890. * Execute a callback on each key/val of the dictionary.
  27891. * Note that you can remove any element in this dictionary in the callback implementation
  27892. * @param callback the callback to execute on a given key/value pair
  27893. */
  27894. forEach(callback: (key: string, val: T) => void): void;
  27895. /**
  27896. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  27897. * If the callback returns null or undefined the method will iterate to the next key/value pair
  27898. * Note that you can remove any element in this dictionary in the callback implementation
  27899. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  27900. */
  27901. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  27902. private _count;
  27903. private _data;
  27904. }
  27905. }
  27906. declare module BABYLON {
  27907. class Tags {
  27908. static EnableFor(obj: any): void;
  27909. static DisableFor(obj: any): void;
  27910. static HasTags(obj: any): boolean;
  27911. static GetTags(obj: any, asString?: boolean): any;
  27912. static AddTagsTo(obj: any, tagsString: string): void;
  27913. private static _AddTagTo(obj: any, tag: string): void;
  27914. static RemoveTagsFrom(obj: any, tagsString: string): void;
  27915. private static _RemoveTagFrom(obj: any, tag: string): void;
  27916. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  27917. }
  27918. }
  27919. declare module BABYLON {
  27920. class TextureTools {
  27921. /**
  27922. * Uses the GPU to create a copy texture rescaled at a given size
  27923. * @param texture Texture to copy from
  27924. * @param width Desired width
  27925. * @param height Desired height
  27926. * @return Generated texture
  27927. */
  27928. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  27929. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  27930. private static _environmentBRDFBase64Texture;
  27931. }
  27932. }
  27933. declare module BABYLON {
  27934. class TGATools {
  27935. private static _TYPE_INDEXED;
  27936. private static _TYPE_RGB;
  27937. private static _TYPE_GREY;
  27938. private static _TYPE_RLE_INDEXED;
  27939. private static _TYPE_RLE_RGB;
  27940. private static _TYPE_RLE_GREY;
  27941. private static _ORIGIN_MASK;
  27942. private static _ORIGIN_SHIFT;
  27943. private static _ORIGIN_BL;
  27944. private static _ORIGIN_BR;
  27945. private static _ORIGIN_UL;
  27946. private static _ORIGIN_UR;
  27947. static GetTGAHeader(data: Uint8Array): any;
  27948. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  27949. 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;
  27950. 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;
  27951. 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;
  27952. 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;
  27953. 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;
  27954. 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;
  27955. }
  27956. }
  27957. declare module BABYLON {
  27958. interface IAnimatable {
  27959. animations: Array<Animation>;
  27960. }
  27961. class LoadFileError extends Error {
  27962. request: XMLHttpRequest | undefined;
  27963. private static _setPrototypeOf;
  27964. constructor(message: string, request?: XMLHttpRequest | undefined);
  27965. }
  27966. class RetryStrategy {
  27967. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27968. }
  27969. interface IFileRequest {
  27970. /**
  27971. * Raised when the request is complete (success or error).
  27972. */
  27973. onCompleteObservable: Observable<IFileRequest>;
  27974. /**
  27975. * Aborts the request for a file.
  27976. */
  27977. abort: () => void;
  27978. }
  27979. class Tools {
  27980. static BaseUrl: string;
  27981. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27982. /**
  27983. * Default behaviour for cors in the application.
  27984. * It can be a string if the expected behavior is identical in the entire app.
  27985. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  27986. */
  27987. static CorsBehavior: string | ((url: string | string[]) => string);
  27988. static UseFallbackTexture: boolean;
  27989. /**
  27990. * Use this object to register external classes like custom textures or material
  27991. * to allow the laoders to instantiate them
  27992. */
  27993. static RegisteredExternalClasses: {
  27994. [key: string]: Object;
  27995. };
  27996. static fallbackTexture: string;
  27997. /**
  27998. * Interpolates between a and b via alpha
  27999. * @param a The lower value (returned when alpha = 0)
  28000. * @param b The upper value (returned when alpha = 1)
  28001. * @param alpha The interpolation-factor
  28002. * @return The mixed value
  28003. */
  28004. static Mix(a: number, b: number, alpha: number): number;
  28005. static Instantiate(className: string): any;
  28006. /**
  28007. * Provides a slice function that will work even on IE
  28008. * @param data defines the array to slice
  28009. * @param start defines the start of the data (optional)
  28010. * @param end defines the end of the data (optional)
  28011. * @returns the new sliced array
  28012. */
  28013. static Slice<T>(data: T, start?: number, end?: number): T;
  28014. static SetImmediate(action: () => void): void;
  28015. static IsExponentOfTwo(value: number): boolean;
  28016. private static _tmpFloatArray;
  28017. /**
  28018. * Returns the nearest 32-bit single precision float representation of a Number
  28019. * @param value A Number. If the parameter is of a different type, it will get converted
  28020. * to a number or to NaN if it cannot be converted
  28021. * @returns number
  28022. */
  28023. static FloatRound(value: number): number;
  28024. /**
  28025. * Find the next highest power of two.
  28026. * @param x Number to start search from.
  28027. * @return Next highest power of two.
  28028. */
  28029. static CeilingPOT(x: number): number;
  28030. /**
  28031. * Find the next lowest power of two.
  28032. * @param x Number to start search from.
  28033. * @return Next lowest power of two.
  28034. */
  28035. static FloorPOT(x: number): number;
  28036. /**
  28037. * Find the nearest power of two.
  28038. * @param x Number to start search from.
  28039. * @return Next nearest power of two.
  28040. */
  28041. static NearestPOT(x: number): number;
  28042. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28043. static GetFilename(path: string): string;
  28044. /**
  28045. * Extracts the "folder" part of a path (everything before the filename).
  28046. * @param uri The URI to extract the info from
  28047. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28048. * @returns The "folder" part of the path
  28049. */
  28050. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28051. static GetDOMTextContent(element: HTMLElement): string;
  28052. static ToDegrees(angle: number): number;
  28053. static ToRadians(angle: number): number;
  28054. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28055. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28056. minimum: Vector3;
  28057. maximum: Vector3;
  28058. };
  28059. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28060. minimum: Vector3;
  28061. maximum: Vector3;
  28062. };
  28063. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28064. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28065. minimum: Vector2;
  28066. maximum: Vector2;
  28067. };
  28068. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28069. static GetPointerPrefix(): string;
  28070. /**
  28071. * @param func - the function to be called
  28072. * @param requester - the object that will request the next frame. Falls back to window.
  28073. */
  28074. static QueueNewFrame(func: () => void, requester?: any): number;
  28075. static RequestFullscreen(element: HTMLElement): void;
  28076. static ExitFullscreen(): void;
  28077. static SetCorsBehavior(url: string | string[], element: {
  28078. crossOrigin: string | null;
  28079. }): void;
  28080. static CleanUrl(url: string): string;
  28081. static PreprocessUrl: (url: string) => string;
  28082. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28083. 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;
  28084. /**
  28085. * Load a script (identified by an url). When the url returns, the
  28086. * content of this file is added into a new script element, attached to the DOM (body element)
  28087. */
  28088. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28089. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28090. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28091. static FileAsURL(content: string): string;
  28092. static Format(value: number, decimals?: number): string;
  28093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28094. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28095. static IsEmpty(obj: any): boolean;
  28096. static RegisterTopRootEvents(events: {
  28097. name: string;
  28098. handler: Nullable<(e: FocusEvent) => any>;
  28099. }[]): void;
  28100. static UnregisterTopRootEvents(events: {
  28101. name: string;
  28102. handler: Nullable<(e: FocusEvent) => any>;
  28103. }[]): void;
  28104. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28105. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28106. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28107. /**
  28108. * Generates an image screenshot from the specified camera.
  28109. *
  28110. * @param engine The engine to use for rendering
  28111. * @param camera The camera to use for rendering
  28112. * @param size This parameter can be set to a single number or to an object with the
  28113. * following (optional) properties: precision, width, height. If a single number is passed,
  28114. * it will be used for both width and height. If an object is passed, the screenshot size
  28115. * will be derived from the parameters. The precision property is a multiplier allowing
  28116. * rendering at a higher or lower resolution.
  28117. * @param successCallback The callback receives a single parameter which contains the
  28118. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28119. * src parameter of an <img> to display it.
  28120. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28121. * Check your browser for supported MIME types.
  28122. * @param samples Texture samples (default: 1)
  28123. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28124. * @param fileName A name for for the downloaded file.
  28125. * @constructor
  28126. */
  28127. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28128. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28129. /**
  28130. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28131. * Be aware Math.random() could cause collisions, but:
  28132. * "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"
  28133. */
  28134. static RandomId(): string;
  28135. /**
  28136. * Test if the given uri is a base64 string.
  28137. * @param uri The uri to test
  28138. * @return True if the uri is a base64 string or false otherwise.
  28139. */
  28140. static IsBase64(uri: string): boolean;
  28141. /**
  28142. * Decode the given base64 uri.
  28143. * @param uri The uri to decode
  28144. * @return The decoded base64 data.
  28145. */
  28146. static DecodeBase64(uri: string): ArrayBuffer;
  28147. private static _NoneLogLevel;
  28148. private static _MessageLogLevel;
  28149. private static _WarningLogLevel;
  28150. private static _ErrorLogLevel;
  28151. private static _LogCache;
  28152. static errorsCount: number;
  28153. static OnNewCacheEntry: (entry: string) => void;
  28154. static readonly NoneLogLevel: number;
  28155. static readonly MessageLogLevel: number;
  28156. static readonly WarningLogLevel: number;
  28157. static readonly ErrorLogLevel: number;
  28158. static readonly AllLogLevel: number;
  28159. private static _AddLogEntry(entry);
  28160. private static _FormatMessage(message);
  28161. private static _LogDisabled(message);
  28162. private static _LogEnabled(message);
  28163. private static _WarnDisabled(message);
  28164. private static _WarnEnabled(message);
  28165. private static _ErrorDisabled(message);
  28166. private static _ErrorEnabled(message);
  28167. static Log: (message: string) => void;
  28168. static Warn: (message: string) => void;
  28169. static Error: (message: string) => void;
  28170. static readonly LogCache: string;
  28171. static ClearLogCache(): void;
  28172. static LogLevels: number;
  28173. static IsWindowObjectExist(): boolean;
  28174. private static _PerformanceNoneLogLevel;
  28175. private static _PerformanceUserMarkLogLevel;
  28176. private static _PerformanceConsoleLogLevel;
  28177. private static _performance;
  28178. static readonly PerformanceNoneLogLevel: number;
  28179. static readonly PerformanceUserMarkLogLevel: number;
  28180. static readonly PerformanceConsoleLogLevel: number;
  28181. static PerformanceLogLevel: number;
  28182. private static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28183. private static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28184. private static _StartUserMark(counterName: string, condition?: boolean): void;
  28185. private static _EndUserMark(counterName: string, condition?: boolean): void;
  28186. private static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28187. private static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28188. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28189. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28190. static readonly Now: number;
  28191. /**
  28192. * This method will return the name of the class used to create the instance of the given object.
  28193. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28194. * @param object the object to get the class name from
  28195. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28196. */
  28197. static GetClassName(object: any, isType?: boolean): string;
  28198. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28199. /**
  28200. * This method will return the name of the full name of the class, including its owning module (if any).
  28201. * 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).
  28202. * @param object the object to get the class name from
  28203. * @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.
  28204. */
  28205. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28206. /**
  28207. * 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.
  28208. * @param array
  28209. */
  28210. static arrayOrStringFeeder(array: any): (i: number) => number;
  28211. /**
  28212. * Compute the hashCode of a stream of number
  28213. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28214. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28215. * @return the hash code computed
  28216. */
  28217. static hashCodeFromStream(feeder: (index: number) => number): number;
  28218. /**
  28219. * Returns a promise that resolves after the given amount of time.
  28220. * @param delay Number of milliseconds to delay
  28221. * @returns Promise that resolves after the given amount of time
  28222. */
  28223. static DelayAsync(delay: number): Promise<void>;
  28224. }
  28225. /**
  28226. * This class is used to track a performance counter which is number based.
  28227. * The user has access to many properties which give statistics of different nature
  28228. *
  28229. * The implementer can track two kinds of Performance Counter: time and count
  28230. * 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.
  28231. * 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.
  28232. */
  28233. class PerfCounter {
  28234. static Enabled: boolean;
  28235. /**
  28236. * Returns the smallest value ever
  28237. */
  28238. readonly min: number;
  28239. /**
  28240. * Returns the biggest value ever
  28241. */
  28242. readonly max: number;
  28243. /**
  28244. * Returns the average value since the performance counter is running
  28245. */
  28246. readonly average: number;
  28247. /**
  28248. * Returns the average value of the last second the counter was monitored
  28249. */
  28250. readonly lastSecAverage: number;
  28251. /**
  28252. * Returns the current value
  28253. */
  28254. readonly current: number;
  28255. readonly total: number;
  28256. readonly count: number;
  28257. constructor();
  28258. /**
  28259. * Call this method to start monitoring a new frame.
  28260. * 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.
  28261. */
  28262. fetchNewFrame(): void;
  28263. /**
  28264. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28265. * @param newCount the count value to add to the monitored count
  28266. * @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.
  28267. */
  28268. addCount(newCount: number, fetchResult: boolean): void;
  28269. /**
  28270. * Start monitoring this performance counter
  28271. */
  28272. beginMonitoring(): void;
  28273. /**
  28274. * Compute the time lapsed since the previous beginMonitoring() call.
  28275. * @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
  28276. */
  28277. endMonitoring(newFrame?: boolean): void;
  28278. private _fetchResult();
  28279. private _startMonitoringTime;
  28280. private _min;
  28281. private _max;
  28282. private _average;
  28283. private _current;
  28284. private _totalValueCount;
  28285. private _totalAccumulated;
  28286. private _lastSecAverage;
  28287. private _lastSecAccumulated;
  28288. private _lastSecTime;
  28289. private _lastSecValueCount;
  28290. }
  28291. /**
  28292. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28293. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28294. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28295. * @param name The name of the class, case should be preserved
  28296. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28297. */
  28298. function className(name: string, module?: string): (target: Object) => void;
  28299. /**
  28300. * An implementation of a loop for asynchronous functions.
  28301. */
  28302. class AsyncLoop {
  28303. iterations: number;
  28304. private _fn;
  28305. private _successCallback;
  28306. index: number;
  28307. private _done;
  28308. /**
  28309. * Constroctor.
  28310. * @param iterations the number of iterations.
  28311. * @param _fn the function to run each iteration
  28312. * @param _successCallback the callback that will be called upon succesful execution
  28313. * @param offset starting offset.
  28314. */
  28315. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28316. /**
  28317. * Execute the next iteration. Must be called after the last iteration was finished.
  28318. */
  28319. executeNext(): void;
  28320. /**
  28321. * Break the loop and run the success callback.
  28322. */
  28323. breakLoop(): void;
  28324. /**
  28325. * Helper function
  28326. */
  28327. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28328. /**
  28329. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28330. * @param iterations total number of iterations
  28331. * @param syncedIterations number of synchronous iterations in each async iteration.
  28332. * @param fn the function to call each iteration.
  28333. * @param callback a success call back that will be called when iterating stops.
  28334. * @param breakFunction a break condition (optional)
  28335. * @param timeout timeout settings for the setTimeout function. default - 0.
  28336. * @constructor
  28337. */
  28338. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28339. }
  28340. }
  28341. declare module BABYLON {
  28342. /**
  28343. * Defines the potential axis of a Joystick
  28344. */
  28345. enum JoystickAxis {
  28346. /** X axis */
  28347. X = 0,
  28348. /** Y axis */
  28349. Y = 1,
  28350. /** Z axis */
  28351. Z = 2,
  28352. }
  28353. /**
  28354. * Class used to define virtual joystick (used in touch mode)
  28355. */
  28356. class VirtualJoystick {
  28357. /**
  28358. * Gets or sets a boolean indicating that left and right values must be inverted
  28359. */
  28360. reverseLeftRight: boolean;
  28361. /**
  28362. * Gets or sets a boolean indicating that up and down values must be inverted
  28363. */
  28364. reverseUpDown: boolean;
  28365. /**
  28366. * Gets the offset value for the position (ie. the change of the position value)
  28367. */
  28368. deltaPosition: Vector3;
  28369. /**
  28370. * Gets a boolean indicating if the virtual joystick was pressed
  28371. */
  28372. pressed: boolean;
  28373. private static _globalJoystickIndex;
  28374. private static vjCanvas;
  28375. private static vjCanvasContext;
  28376. private static vjCanvasWidth;
  28377. private static vjCanvasHeight;
  28378. private static halfWidth;
  28379. private _action;
  28380. private _axisTargetedByLeftAndRight;
  28381. private _axisTargetedByUpAndDown;
  28382. private _joystickSensibility;
  28383. private _inversedSensibility;
  28384. private _joystickPointerID;
  28385. private _joystickColor;
  28386. private _joystickPointerPos;
  28387. private _joystickPreviousPointerPos;
  28388. private _joystickPointerStartPos;
  28389. private _deltaJoystickVector;
  28390. private _leftJoystick;
  28391. private _touches;
  28392. private _onPointerDownHandlerRef;
  28393. private _onPointerMoveHandlerRef;
  28394. private _onPointerUpHandlerRef;
  28395. private _onResize;
  28396. /**
  28397. * Creates a new virtual joystick
  28398. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28399. */
  28400. constructor(leftJoystick?: boolean);
  28401. /**
  28402. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28403. * @param newJoystickSensibility defines the new sensibility
  28404. */
  28405. setJoystickSensibility(newJoystickSensibility: number): void;
  28406. private _onPointerDown(e);
  28407. private _onPointerMove(e);
  28408. private _onPointerUp(e);
  28409. /**
  28410. * Change the color of the virtual joystick
  28411. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28412. */
  28413. setJoystickColor(newColor: string): void;
  28414. /**
  28415. * Defines a callback to call when the joystick is touched
  28416. * @param action defines the callback
  28417. */
  28418. setActionOnTouch(action: () => any): void;
  28419. /**
  28420. * Defines which axis you'd like to control for left & right
  28421. * @param axis defines the axis to use
  28422. */
  28423. setAxisForLeftRight(axis: JoystickAxis): void;
  28424. /**
  28425. * Defines which axis you'd like to control for up & down
  28426. * @param axis defines the axis to use
  28427. */
  28428. setAxisForUpDown(axis: JoystickAxis): void;
  28429. private _drawVirtualJoystick();
  28430. /**
  28431. * Release internal HTML canvas
  28432. */
  28433. releaseCanvas(): void;
  28434. }
  28435. }
  28436. declare module BABYLON {
  28437. /**
  28438. * Helper class to push actions to a pool of workers.
  28439. */
  28440. class WorkerPool implements IDisposable {
  28441. private _workerInfos;
  28442. private _pendingActions;
  28443. /**
  28444. * Constructor
  28445. * @param workers Array of workers to use for actions
  28446. */
  28447. constructor(workers: Array<Worker>);
  28448. /**
  28449. * Terminates all workers and clears any pending actions.
  28450. */
  28451. dispose(): void;
  28452. /**
  28453. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28454. * pended until a worker has completed its action.
  28455. * @param action The action to perform. Call onComplete when the action is complete.
  28456. */
  28457. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28458. private _execute(workerInfo, action);
  28459. }
  28460. }
  28461. declare module BABYLON {
  28462. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28463. readonly name: string;
  28464. private _zoomStopsAnimation;
  28465. private _idleRotationSpeed;
  28466. private _idleRotationWaitTime;
  28467. private _idleRotationSpinupTime;
  28468. /**
  28469. * Gets the flag that indicates if user zooming should stop animation.
  28470. */
  28471. /**
  28472. * Sets the flag that indicates if user zooming should stop animation.
  28473. */
  28474. zoomStopsAnimation: boolean;
  28475. /**
  28476. * Gets the default speed at which the camera rotates around the model.
  28477. */
  28478. /**
  28479. * Sets the default speed at which the camera rotates around the model.
  28480. */
  28481. idleRotationSpeed: number;
  28482. /**
  28483. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28484. */
  28485. /**
  28486. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28487. */
  28488. idleRotationWaitTime: number;
  28489. /**
  28490. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28491. */
  28492. /**
  28493. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28494. */
  28495. idleRotationSpinupTime: number;
  28496. /**
  28497. * Gets a value indicating if the camera is currently rotating because of this behavior
  28498. */
  28499. readonly rotationInProgress: boolean;
  28500. private _onPrePointerObservableObserver;
  28501. private _onAfterCheckInputsObserver;
  28502. private _attachedCamera;
  28503. private _isPointerDown;
  28504. private _lastFrameTime;
  28505. private _lastInteractionTime;
  28506. private _cameraRotationSpeed;
  28507. init(): void;
  28508. attach(camera: ArcRotateCamera): void;
  28509. detach(): void;
  28510. /**
  28511. * Returns true if user is scrolling.
  28512. * @return true if user is scrolling.
  28513. */
  28514. private _userIsZooming();
  28515. private _lastFrameRadius;
  28516. private _shouldAnimationStopForInteraction();
  28517. /**
  28518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28519. */
  28520. private _applyUserInteraction();
  28521. private _userIsMoving();
  28522. }
  28523. }
  28524. declare module BABYLON {
  28525. /**
  28526. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28527. */
  28528. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28529. readonly name: string;
  28530. /**
  28531. * The easing function used by animations
  28532. */
  28533. static EasingFunction: BackEase;
  28534. /**
  28535. * The easing mode used by animations
  28536. */
  28537. static EasingMode: number;
  28538. /**
  28539. * The duration of the animation, in milliseconds
  28540. */
  28541. transitionDuration: number;
  28542. /**
  28543. * Length of the distance animated by the transition when lower radius is reached
  28544. */
  28545. lowerRadiusTransitionRange: number;
  28546. /**
  28547. * Length of the distance animated by the transition when upper radius is reached
  28548. */
  28549. upperRadiusTransitionRange: number;
  28550. private _autoTransitionRange;
  28551. /**
  28552. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28553. */
  28554. /**
  28555. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28556. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  28557. */
  28558. autoTransitionRange: boolean;
  28559. private _attachedCamera;
  28560. private _onAfterCheckInputsObserver;
  28561. private _onMeshTargetChangedObserver;
  28562. init(): void;
  28563. attach(camera: ArcRotateCamera): void;
  28564. detach(): void;
  28565. private _radiusIsAnimating;
  28566. private _radiusBounceTransition;
  28567. private _animatables;
  28568. private _cachedWheelPrecision;
  28569. /**
  28570. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  28571. * @param radiusLimit The limit to check against.
  28572. * @return Bool to indicate if at limit.
  28573. */
  28574. private _isRadiusAtLimit(radiusLimit);
  28575. /**
  28576. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  28577. * @param radiusDelta The delta by which to animate to. Can be negative.
  28578. */
  28579. private _applyBoundRadiusAnimation(radiusDelta);
  28580. /**
  28581. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  28582. */
  28583. protected _clearAnimationLocks(): void;
  28584. /**
  28585. * Stops and removes all animations that have been applied to the camera
  28586. */
  28587. stopAllAnimations(): void;
  28588. }
  28589. }
  28590. declare module BABYLON {
  28591. class FramingBehavior implements Behavior<ArcRotateCamera> {
  28592. readonly name: string;
  28593. private _mode;
  28594. private _radiusScale;
  28595. private _positionScale;
  28596. private _defaultElevation;
  28597. private _elevationReturnTime;
  28598. private _elevationReturnWaitTime;
  28599. private _zoomStopsAnimation;
  28600. private _framingTime;
  28601. /**
  28602. * The easing function used by animations
  28603. */
  28604. static EasingFunction: ExponentialEase;
  28605. /**
  28606. * The easing mode used by animations
  28607. */
  28608. static EasingMode: number;
  28609. /**
  28610. * Gets current mode used by the behavior.
  28611. */
  28612. /**
  28613. * Sets the current mode used by the behavior
  28614. */
  28615. mode: number;
  28616. /**
  28617. * Gets the scale applied to the radius
  28618. */
  28619. /**
  28620. * Sets the scale applied to the radius (1 by default)
  28621. */
  28622. radiusScale: number;
  28623. /**
  28624. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  28625. */
  28626. /**
  28627. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  28628. */
  28629. positionScale: number;
  28630. /**
  28631. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  28632. * behaviour is triggered, in radians.
  28633. */
  28634. /**
  28635. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  28636. * behaviour is triggered, in radians.
  28637. */
  28638. defaultElevation: number;
  28639. /**
  28640. * Gets the time (in milliseconds) taken to return to the default beta position.
  28641. * Negative value indicates camera should not return to default.
  28642. */
  28643. /**
  28644. * Sets the time (in milliseconds) taken to return to the default beta position.
  28645. * Negative value indicates camera should not return to default.
  28646. */
  28647. elevationReturnTime: number;
  28648. /**
  28649. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  28650. */
  28651. /**
  28652. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  28653. */
  28654. elevationReturnWaitTime: number;
  28655. /**
  28656. * Gets the flag that indicates if user zooming should stop animation.
  28657. */
  28658. /**
  28659. * Sets the flag that indicates if user zooming should stop animation.
  28660. */
  28661. zoomStopsAnimation: boolean;
  28662. /**
  28663. * Gets the transition time when framing the mesh, in milliseconds
  28664. */
  28665. /**
  28666. * Sets the transition time when framing the mesh, in milliseconds
  28667. */
  28668. framingTime: number;
  28669. private _onPrePointerObservableObserver;
  28670. private _onAfterCheckInputsObserver;
  28671. private _onMeshTargetChangedObserver;
  28672. private _attachedCamera;
  28673. private _isPointerDown;
  28674. private _lastInteractionTime;
  28675. init(): void;
  28676. attach(camera: ArcRotateCamera): void;
  28677. detach(): void;
  28678. private _animatables;
  28679. private _betaIsAnimating;
  28680. private _betaTransition;
  28681. private _radiusTransition;
  28682. private _vectorTransition;
  28683. /**
  28684. * Targets the given mesh and updates zoom level accordingly.
  28685. * @param mesh The mesh to target.
  28686. * @param radius Optional. If a cached radius position already exists, overrides default.
  28687. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  28688. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  28689. * @param onAnimationEnd Callback triggered at the end of the framing animation
  28690. */
  28691. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  28692. /**
  28693. * Targets the given mesh with its children and updates zoom level accordingly.
  28694. * @param mesh The mesh to target.
  28695. * @param radius Optional. If a cached radius position already exists, overrides default.
  28696. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  28697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  28698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  28699. */
  28700. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  28701. /**
  28702. * Targets the given meshes with their children and updates zoom level accordingly.
  28703. * @param meshes The mesh to target.
  28704. * @param radius Optional. If a cached radius position already exists, overrides default.
  28705. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  28706. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  28707. * @param onAnimationEnd Callback triggered at the end of the framing animation
  28708. */
  28709. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  28710. /**
  28711. * Targets the given mesh and updates zoom level accordingly.
  28712. * @param mesh The mesh to target.
  28713. * @param radius Optional. If a cached radius position already exists, overrides default.
  28714. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  28715. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  28716. * @param onAnimationEnd Callback triggered at the end of the framing animation
  28717. */
  28718. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  28719. /**
  28720. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  28721. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  28722. * frustum width.
  28723. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  28724. * to fully enclose the mesh in the viewing frustum.
  28725. */
  28726. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  28727. /**
  28728. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  28729. * is automatically returned to its default position (expected to be above ground plane).
  28730. */
  28731. private _maintainCameraAboveGround();
  28732. /**
  28733. * Returns the frustum slope based on the canvas ratio and camera FOV
  28734. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  28735. */
  28736. private _getFrustumSlope();
  28737. /**
  28738. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  28739. */
  28740. private _clearAnimationLocks();
  28741. /**
  28742. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28743. */
  28744. private _applyUserInteraction();
  28745. /**
  28746. * Stops and removes all animations that have been applied to the camera
  28747. */
  28748. stopAllAnimations(): void;
  28749. /**
  28750. * Gets a value indicating if the user is moving the camera
  28751. */
  28752. readonly isUserIsMoving: boolean;
  28753. /**
  28754. * The camera can move all the way towards the mesh.
  28755. */
  28756. static IgnoreBoundsSizeMode: number;
  28757. /**
  28758. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  28759. */
  28760. static FitFrustumSidesMode: number;
  28761. }
  28762. }
  28763. declare module BABYLON {
  28764. interface IOctreeContainer<T> {
  28765. blocks: Array<OctreeBlock<T>>;
  28766. }
  28767. class Octree<T> {
  28768. maxDepth: number;
  28769. blocks: Array<OctreeBlock<T>>;
  28770. dynamicContent: T[];
  28771. private _maxBlockCapacity;
  28772. private _selectionContent;
  28773. private _creationFunc;
  28774. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  28775. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  28776. addMesh(entry: T): void;
  28777. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  28778. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  28779. intersectsRay(ray: Ray): SmartArray<T>;
  28780. 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;
  28781. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  28782. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  28783. }
  28784. }
  28785. declare module BABYLON {
  28786. class OctreeBlock<T> {
  28787. entries: T[];
  28788. blocks: Array<OctreeBlock<T>>;
  28789. private _depth;
  28790. private _maxDepth;
  28791. private _capacity;
  28792. private _minPoint;
  28793. private _maxPoint;
  28794. private _boundingVectors;
  28795. private _creationFunc;
  28796. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  28797. readonly capacity: number;
  28798. readonly minPoint: Vector3;
  28799. readonly maxPoint: Vector3;
  28800. addEntry(entry: T): void;
  28801. addEntries(entries: T[]): void;
  28802. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  28803. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  28804. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  28805. createInnerBlocks(): void;
  28806. }
  28807. }
  28808. declare module BABYLON {
  28809. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  28810. camera: ArcRotateCamera;
  28811. gamepad: Nullable<Gamepad>;
  28812. private _onGamepadConnectedObserver;
  28813. private _onGamepadDisconnectedObserver;
  28814. gamepadRotationSensibility: number;
  28815. gamepadMoveSensibility: number;
  28816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28817. detachControl(element: Nullable<HTMLElement>): void;
  28818. checkInputs(): void;
  28819. getClassName(): string;
  28820. getSimpleName(): string;
  28821. }
  28822. }
  28823. declare module BABYLON {
  28824. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  28825. camera: ArcRotateCamera;
  28826. private _keys;
  28827. keysUp: number[];
  28828. keysDown: number[];
  28829. keysLeft: number[];
  28830. keysRight: number[];
  28831. keysReset: number[];
  28832. panningSensibility: number;
  28833. zoomingSensibility: number;
  28834. useAltToZoom: boolean;
  28835. private _ctrlPressed;
  28836. private _altPressed;
  28837. private _onCanvasBlurObserver;
  28838. private _onKeyboardObserver;
  28839. private _engine;
  28840. private _scene;
  28841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28842. detachControl(element: Nullable<HTMLElement>): void;
  28843. checkInputs(): void;
  28844. getClassName(): string;
  28845. getSimpleName(): string;
  28846. }
  28847. }
  28848. declare module BABYLON {
  28849. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  28850. camera: ArcRotateCamera;
  28851. private _wheel;
  28852. private _observer;
  28853. wheelPrecision: number;
  28854. /**
  28855. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  28856. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  28857. */
  28858. wheelDeltaPercentage: number;
  28859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28860. detachControl(element: Nullable<HTMLElement>): void;
  28861. getClassName(): string;
  28862. getSimpleName(): string;
  28863. }
  28864. }
  28865. declare module BABYLON {
  28866. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  28867. camera: ArcRotateCamera;
  28868. buttons: number[];
  28869. angularSensibilityX: number;
  28870. angularSensibilityY: number;
  28871. pinchPrecision: number;
  28872. /**
  28873. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  28874. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  28875. */
  28876. pinchDeltaPercentage: number;
  28877. panningSensibility: number;
  28878. multiTouchPanning: boolean;
  28879. multiTouchPanAndZoom: boolean;
  28880. private _isPanClick;
  28881. pinchInwards: boolean;
  28882. private _pointerInput;
  28883. private _observer;
  28884. private _onMouseMove;
  28885. private _onGestureStart;
  28886. private _onGesture;
  28887. private _MSGestureHandler;
  28888. private _onLostFocus;
  28889. private _onContextMenu;
  28890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28891. detachControl(element: Nullable<HTMLElement>): void;
  28892. getClassName(): string;
  28893. getSimpleName(): string;
  28894. }
  28895. }
  28896. declare module BABYLON {
  28897. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  28898. camera: ArcRotateCamera;
  28899. alphaCorrection: number;
  28900. betaCorrection: number;
  28901. gammaCorrection: number;
  28902. private _alpha;
  28903. private _gamma;
  28904. private _dirty;
  28905. private _deviceOrientationHandler;
  28906. constructor();
  28907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28908. checkInputs(): void;
  28909. detachControl(element: Nullable<HTMLElement>): void;
  28910. getClassName(): string;
  28911. getSimpleName(): string;
  28912. }
  28913. }
  28914. declare module BABYLON {
  28915. /**
  28916. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  28917. * Screen rotation is taken into account.
  28918. */
  28919. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  28920. private _camera;
  28921. private _screenOrientationAngle;
  28922. private _constantTranform;
  28923. private _screenQuaternion;
  28924. private _alpha;
  28925. private _beta;
  28926. private _gamma;
  28927. constructor();
  28928. camera: FreeCamera;
  28929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28930. private _orientationChanged;
  28931. private _deviceOrientation;
  28932. detachControl(element: Nullable<HTMLElement>): void;
  28933. checkInputs(): void;
  28934. getClassName(): string;
  28935. getSimpleName(): string;
  28936. }
  28937. }
  28938. declare module BABYLON {
  28939. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  28940. camera: FreeCamera;
  28941. gamepad: Nullable<Gamepad>;
  28942. private _onGamepadConnectedObserver;
  28943. private _onGamepadDisconnectedObserver;
  28944. gamepadAngularSensibility: number;
  28945. gamepadMoveSensibility: number;
  28946. private _cameraTransform;
  28947. private _deltaTransform;
  28948. private _vector3;
  28949. private _vector2;
  28950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28951. detachControl(element: Nullable<HTMLElement>): void;
  28952. checkInputs(): void;
  28953. getClassName(): string;
  28954. getSimpleName(): string;
  28955. }
  28956. }
  28957. declare module BABYLON {
  28958. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  28959. camera: FreeCamera;
  28960. private _keys;
  28961. private _onCanvasBlurObserver;
  28962. private _onKeyboardObserver;
  28963. private _engine;
  28964. private _scene;
  28965. keysUp: number[];
  28966. keysDown: number[];
  28967. keysLeft: number[];
  28968. keysRight: number[];
  28969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28970. detachControl(element: Nullable<HTMLElement>): void;
  28971. checkInputs(): void;
  28972. getClassName(): string;
  28973. getSimpleName(): string;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  28978. touchEnabled: boolean;
  28979. camera: FreeCamera;
  28980. buttons: number[];
  28981. angularSensibility: number;
  28982. private _pointerInput;
  28983. private _onMouseMove;
  28984. private _observer;
  28985. private previousPosition;
  28986. constructor(touchEnabled?: boolean);
  28987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28988. detachControl(element: Nullable<HTMLElement>): void;
  28989. getClassName(): string;
  28990. getSimpleName(): string;
  28991. }
  28992. }
  28993. declare module BABYLON {
  28994. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  28995. camera: FreeCamera;
  28996. private _offsetX;
  28997. private _offsetY;
  28998. private _pointerPressed;
  28999. private _pointerInput;
  29000. private _observer;
  29001. private _onLostFocus;
  29002. touchAngularSensibility: number;
  29003. touchMoveSensibility: number;
  29004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29005. detachControl(element: Nullable<HTMLElement>): void;
  29006. checkInputs(): void;
  29007. getClassName(): string;
  29008. getSimpleName(): string;
  29009. }
  29010. }
  29011. declare module BABYLON {
  29012. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29013. camera: FreeCamera;
  29014. private _leftjoystick;
  29015. private _rightjoystick;
  29016. getLeftJoystick(): VirtualJoystick;
  29017. getRightJoystick(): VirtualJoystick;
  29018. checkInputs(): void;
  29019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29020. detachControl(element: Nullable<HTMLElement>): void;
  29021. getClassName(): string;
  29022. getSimpleName(): string;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. class VRCameraMetrics {
  29027. hResolution: number;
  29028. vResolution: number;
  29029. hScreenSize: number;
  29030. vScreenSize: number;
  29031. vScreenCenter: number;
  29032. eyeToScreenDistance: number;
  29033. lensSeparationDistance: number;
  29034. interpupillaryDistance: number;
  29035. distortionK: number[];
  29036. chromaAbCorrection: number[];
  29037. postProcessScaleFactor: number;
  29038. lensCenterOffset: number;
  29039. compensateDistortion: boolean;
  29040. readonly aspectRatio: number;
  29041. readonly aspectRatioFov: number;
  29042. readonly leftHMatrix: Matrix;
  29043. readonly rightHMatrix: Matrix;
  29044. readonly leftPreViewMatrix: Matrix;
  29045. readonly rightPreViewMatrix: Matrix;
  29046. static GetDefault(): VRCameraMetrics;
  29047. }
  29048. }
  29049. declare module BABYLON {
  29050. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29051. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29052. getClassName(): string;
  29053. }
  29054. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29055. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29056. getClassName(): string;
  29057. }
  29058. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29059. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29060. getClassName(): string;
  29061. }
  29062. }
  29063. declare module BABYLON {
  29064. /**
  29065. * Options to modify the vr teleportation behavior.
  29066. */
  29067. interface VRTeleportationOptions {
  29068. /**
  29069. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29070. */
  29071. floorMeshName?: string;
  29072. /**
  29073. * A list of meshes to be used as the teleportation floor. (default: empty)
  29074. */
  29075. floorMeshes?: Mesh[];
  29076. }
  29077. /**
  29078. * Options to modify the vr experience helper's behavior.
  29079. */
  29080. interface VRExperienceHelperOptions extends WebVROptions {
  29081. /**
  29082. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  29083. */
  29084. createDeviceOrientationCamera?: boolean;
  29085. /**
  29086. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  29087. */
  29088. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29089. }
  29090. /**
  29091. * Helps to quickly add VR support to an existing scene.
  29092. * See http://doc.babylonjs.com/how_to/webvr_helper
  29093. */
  29094. class VRExperienceHelper {
  29095. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29096. private _scene;
  29097. private _position;
  29098. private _btnVR;
  29099. private _btnVRDisplayed;
  29100. private _webVRsupported;
  29101. private _webVRready;
  29102. private _webVRrequesting;
  29103. private _webVRpresenting;
  29104. private _fullscreenVRpresenting;
  29105. private _canvas;
  29106. private _webVRCamera;
  29107. private _vrDeviceOrientationCamera;
  29108. private _deviceOrientationCamera;
  29109. private _existingCamera;
  29110. private _onKeyDown;
  29111. private _onVrDisplayPresentChange;
  29112. private _onVRDisplayChanged;
  29113. private _onVRRequestPresentStart;
  29114. private _onVRRequestPresentComplete;
  29115. /**
  29116. * Observable raised when entering VR.
  29117. */
  29118. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29119. /**
  29120. * Observable raised when exiting VR.
  29121. */
  29122. onExitingVRObservable: Observable<VRExperienceHelper>;
  29123. /**
  29124. * Observable raised when controller mesh is loaded.
  29125. */
  29126. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29127. /** Return this.onEnteringVRObservable
  29128. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29129. */
  29130. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29131. /** Return this.onExitingVRObservable
  29132. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29133. */
  29134. readonly onExitingVR: Observable<VRExperienceHelper>;
  29135. /** Return this.onControllerMeshLoadedObservable
  29136. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29137. */
  29138. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29139. private _rayLength;
  29140. private _useCustomVRButton;
  29141. private _teleportationRequested;
  29142. private _teleportActive;
  29143. private _floorMeshName;
  29144. private _floorMeshesCollection;
  29145. private _rotationAllowed;
  29146. private _teleportBackwardsVector;
  29147. private _rotationRightAsked;
  29148. private _rotationLeftAsked;
  29149. private _teleportationTarget;
  29150. private _isDefaultTeleportationTarget;
  29151. private _postProcessMove;
  29152. private _teleportationFillColor;
  29153. private _teleportationBorderColor;
  29154. private _rotationAngle;
  29155. private _haloCenter;
  29156. private _cameraGazer;
  29157. private _padSensibilityUp;
  29158. private _padSensibilityDown;
  29159. private leftController;
  29160. private rightController;
  29161. /**
  29162. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29163. */
  29164. onNewMeshSelected: Observable<AbstractMesh>;
  29165. /**
  29166. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29167. */
  29168. onNewMeshPicked: Observable<PickingInfo>;
  29169. private _circleEase;
  29170. /**
  29171. * Observable raised before camera teleportation
  29172. */
  29173. onBeforeCameraTeleport: Observable<Vector3>;
  29174. /**
  29175. * Observable raised after camera teleportation
  29176. */
  29177. onAfterCameraTeleport: Observable<Vector3>;
  29178. /**
  29179. * Observable raised when current selected mesh gets unselected
  29180. */
  29181. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29182. private _raySelectionPredicate;
  29183. /**
  29184. * To be optionaly changed by user to define custom ray selection
  29185. */
  29186. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29187. /**
  29188. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29189. */
  29190. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29191. /**
  29192. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29193. */
  29194. teleportationEnabled: boolean;
  29195. private _defaultHeight;
  29196. private _teleportationInitialized;
  29197. private _interactionsEnabled;
  29198. private _interactionsRequested;
  29199. private _displayGaze;
  29200. private _displayLaserPointer;
  29201. /**
  29202. * The mesh used to display where the user is going to teleport.
  29203. */
  29204. /**
  29205. * Sets the mesh to be used to display where the user is going to teleport.
  29206. */
  29207. teleportationTarget: Mesh;
  29208. /**
  29209. * The mesh used to display where the user is selecting,
  29210. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29211. * See http://doc.babylonjs.com/resources/baking_transformations
  29212. */
  29213. gazeTrackerMesh: Mesh;
  29214. /**
  29215. * If the ray of the gaze should be displayed.
  29216. */
  29217. /**
  29218. * Sets if the ray of the gaze should be displayed.
  29219. */
  29220. displayGaze: boolean;
  29221. /**
  29222. * If the ray of the LaserPointer should be displayed.
  29223. */
  29224. /**
  29225. * Sets if the ray of the LaserPointer should be displayed.
  29226. */
  29227. displayLaserPointer: boolean;
  29228. /**
  29229. * The deviceOrientationCamera used as the camera when not in VR.
  29230. */
  29231. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29232. /**
  29233. * Based on the current WebVR support, returns the current VR camera used.
  29234. */
  29235. readonly currentVRCamera: Nullable<Camera>;
  29236. /**
  29237. * The webVRCamera which is used when in VR.
  29238. */
  29239. readonly webVRCamera: WebVRFreeCamera;
  29240. /**
  29241. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29242. */
  29243. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29244. private readonly _teleportationRequestInitiated;
  29245. /**
  29246. * Instantiates a VRExperienceHelper.
  29247. * Helps to quickly add VR support to an existing scene.
  29248. * @param scene The scene the VRExperienceHelper belongs to.
  29249. * @param webVROptions Options to modify the vr experience helper's behavior.
  29250. */
  29251. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29252. private _onDefaultMeshLoaded(webVRController);
  29253. private _onResize;
  29254. private _onFullscreenChange;
  29255. /**
  29256. * Gets a value indicating if we are currently in VR mode.
  29257. */
  29258. readonly isInVRMode: boolean;
  29259. private onVrDisplayPresentChange();
  29260. private onVRDisplayChanged(eventArgs);
  29261. private moveButtonToBottomRight();
  29262. private displayVRButton();
  29263. private updateButtonVisibility();
  29264. /**
  29265. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29266. * Otherwise, will use the fullscreen API.
  29267. */
  29268. enterVR(): void;
  29269. /**
  29270. * Attempt to exit VR, or fullscreen.
  29271. */
  29272. exitVR(): void;
  29273. /**
  29274. * The position of the vr experience helper.
  29275. */
  29276. /**
  29277. * Sets the position of the vr experience helper.
  29278. */
  29279. position: Vector3;
  29280. /**
  29281. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29282. */
  29283. enableInteractions(): void;
  29284. private beforeRender;
  29285. private _isTeleportationFloor(mesh);
  29286. /**
  29287. * Adds a floor mesh to be used for teleportation.
  29288. * @param floorMesh the mesh to be used for teleportation.
  29289. */
  29290. addFloorMesh(floorMesh: Mesh): void;
  29291. /**
  29292. * Removes a floor mesh from being used for teleportation.
  29293. * @param floorMesh the mesh to be removed.
  29294. */
  29295. removeFloorMesh(floorMesh: Mesh): void;
  29296. /**
  29297. * Enables interactions and teleportation using the VR controllers and gaze.
  29298. * @param vrTeleportationOptions options to modify teleportation behavior.
  29299. */
  29300. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29301. private _onNewGamepadConnected;
  29302. private _tryEnableInteractionOnController;
  29303. private _onNewGamepadDisconnected;
  29304. private _enableInteractionOnController(controller);
  29305. private _checkTeleportWithRay(stateObject, gazer);
  29306. private _checkRotate(stateObject, gazer);
  29307. private _checkTeleportBackwards(stateObject, gazer);
  29308. private _enableTeleportationOnController(controller);
  29309. private _createTeleportationCircles();
  29310. private _displayTeleportationTarget();
  29311. private _hideTeleportationTarget();
  29312. private _rotateCamera(right);
  29313. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29314. private _workingVector;
  29315. private _workingQuaternion;
  29316. private _workingMatrix;
  29317. private _teleportCamera(location);
  29318. private _convertNormalToDirectionOfRay(normal, ray);
  29319. private _castRayAndSelectObject(gazer);
  29320. private _notifySelectedMeshUnselected(mesh);
  29321. /**
  29322. * Sets the color of the laser ray from the vr controllers.
  29323. * @param color new color for the ray.
  29324. */
  29325. changeLaserColor(color: Color3): void;
  29326. /**
  29327. * Sets the color of the ray from the vr headsets gaze.
  29328. * @param color new color for the ray.
  29329. */
  29330. changeGazeColor(color: Color3): void;
  29331. /**
  29332. * Exits VR and disposes of the vr experience helper
  29333. */
  29334. dispose(): void;
  29335. /**
  29336. * Gets the name of the VRExperienceHelper class
  29337. * @returns "VRExperienceHelper"
  29338. */
  29339. getClassName(): string;
  29340. }
  29341. }
  29342. declare module BABYLON {
  29343. /**
  29344. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29345. * IMPORTANT!! The data is right-hand data.
  29346. * @export
  29347. * @interface DevicePose
  29348. */
  29349. interface DevicePose {
  29350. /**
  29351. * The position of the device, values in array are [x,y,z].
  29352. */
  29353. readonly position: Nullable<Float32Array>;
  29354. /**
  29355. * The linearVelocity of the device, values in array are [x,y,z].
  29356. */
  29357. readonly linearVelocity: Nullable<Float32Array>;
  29358. /**
  29359. * The linearAcceleration of the device, values in array are [x,y,z].
  29360. */
  29361. readonly linearAcceleration: Nullable<Float32Array>;
  29362. /**
  29363. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29364. */
  29365. readonly orientation: Nullable<Float32Array>;
  29366. /**
  29367. * The angularVelocity of the device, values in array are [x,y,z].
  29368. */
  29369. readonly angularVelocity: Nullable<Float32Array>;
  29370. /**
  29371. * The angularAcceleration of the device, values in array are [x,y,z].
  29372. */
  29373. readonly angularAcceleration: Nullable<Float32Array>;
  29374. }
  29375. /**
  29376. * Interface representing a pose controlled object in Babylon.
  29377. * A pose controlled object has both regular pose values as well as pose values
  29378. * from an external device such as a VR head mounted display
  29379. */
  29380. interface PoseControlled {
  29381. /**
  29382. * The position of the object in babylon space.
  29383. */
  29384. position: Vector3;
  29385. /**
  29386. * The rotation quaternion of the object in babylon space.
  29387. */
  29388. rotationQuaternion: Quaternion;
  29389. /**
  29390. * The position of the device in babylon space.
  29391. */
  29392. devicePosition?: Vector3;
  29393. /**
  29394. * The rotation quaternion of the device in babylon space.
  29395. */
  29396. deviceRotationQuaternion: Quaternion;
  29397. /**
  29398. * The raw pose coming from the device.
  29399. */
  29400. rawPose: Nullable<DevicePose>;
  29401. /**
  29402. * The scale of the device to be used when translating from device space to babylon space.
  29403. */
  29404. deviceScaleFactor: number;
  29405. /**
  29406. * Updates the poseControlled values based on the input device pose.
  29407. * @param poseData the pose data to update the object with
  29408. */
  29409. updateFromDevice(poseData: DevicePose): void;
  29410. }
  29411. /**
  29412. * Set of options to customize the webVRCamera
  29413. */
  29414. interface WebVROptions {
  29415. /**
  29416. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29417. */
  29418. trackPosition?: boolean;
  29419. /**
  29420. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29421. */
  29422. positionScale?: number;
  29423. /**
  29424. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29425. */
  29426. displayName?: string;
  29427. /**
  29428. * Should the native controller meshes be initialized. (default: true)
  29429. */
  29430. controllerMeshes?: boolean;
  29431. /**
  29432. * Creating a default HemiLight only on controllers. (default: true)
  29433. */
  29434. defaultLightingOnControllers?: boolean;
  29435. /**
  29436. * If you don't want to use the default VR button of the helper. (default: false)
  29437. */
  29438. useCustomVRButton?: boolean;
  29439. /**
  29440. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29441. */
  29442. customVRButton?: HTMLButtonElement;
  29443. /**
  29444. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29445. */
  29446. rayLength?: number;
  29447. /**
  29448. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29449. */
  29450. defaultHeight?: number;
  29451. }
  29452. /**
  29453. * This represents a WebVR camera.
  29454. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29455. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29456. */
  29457. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29458. private webVROptions;
  29459. /**
  29460. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29461. */
  29462. /**
  29463. * The rawPose of the vrDevice.
  29464. */
  29465. rawPose: Nullable<DevicePose>;
  29466. private _onVREnabled;
  29467. private _specsVersion;
  29468. private _attached;
  29469. private _frameData;
  29470. protected _descendants: Array<Node>;
  29471. private _deviceRoomPosition;
  29472. private _deviceRoomRotationQuaternion;
  29473. private _standingMatrix;
  29474. /**
  29475. * Represents device position in babylon space.
  29476. */
  29477. devicePosition: Vector3;
  29478. /**
  29479. * Represents device rotation in babylon space.
  29480. */
  29481. deviceRotationQuaternion: Quaternion;
  29482. /**
  29483. * The scale of the device to be used when translating from device space to babylon space.
  29484. */
  29485. deviceScaleFactor: number;
  29486. private _deviceToWorld;
  29487. private _worldToDevice;
  29488. /**
  29489. * References to the webVR controllers for the vrDevice.
  29490. */
  29491. controllers: Array<WebVRController>;
  29492. /**
  29493. * Emits an event when a controller is attached.
  29494. */
  29495. onControllersAttachedObservable: Observable<WebVRController[]>;
  29496. /**
  29497. * Emits an event when a controller's mesh has been loaded;
  29498. */
  29499. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29500. /**
  29501. * If the rig cameras be used as parent instead of this camera.
  29502. */
  29503. rigParenting: boolean;
  29504. private _lightOnControllers;
  29505. private _defaultHeight?;
  29506. /**
  29507. * Instantiates a WebVRFreeCamera.
  29508. * @param name The name of the WebVRFreeCamera
  29509. * @param position The starting anchor position for the camera
  29510. * @param scene The scene the camera belongs to
  29511. * @param webVROptions a set of customizable options for the webVRCamera
  29512. */
  29513. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29514. /**
  29515. * Gets the device distance from the ground in meters.
  29516. * @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.
  29517. */
  29518. deviceDistanceToRoomGround(): number;
  29519. /**
  29520. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29521. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29522. */
  29523. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29524. /**
  29525. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29526. * @returns A promise with a boolean set to if the standing matrix is supported.
  29527. */
  29528. useStandingMatrixAsync(): Promise<boolean>;
  29529. /**
  29530. * Disposes the camera
  29531. */
  29532. dispose(): void;
  29533. /**
  29534. * Gets a vrController by name.
  29535. * @param name The name of the controller to retreive
  29536. * @returns the controller matching the name specified or null if not found
  29537. */
  29538. getControllerByName(name: string): Nullable<WebVRController>;
  29539. private _leftController;
  29540. /**
  29541. * The controller corrisponding to the users left hand.
  29542. */
  29543. readonly leftController: Nullable<WebVRController>;
  29544. private _rightController;
  29545. /**
  29546. * The controller corrisponding to the users right hand.
  29547. */
  29548. readonly rightController: Nullable<WebVRController>;
  29549. /**
  29550. * Casts a ray forward from the vrCamera's gaze.
  29551. * @param length Length of the ray (default: 100)
  29552. * @returns the ray corrisponding to the gaze
  29553. */
  29554. getForwardRay(length?: number): Ray;
  29555. /**
  29556. * Updates the camera based on device's frame data
  29557. */
  29558. /**
  29559. * Updates the poseControlled values based on the input device pose.
  29560. * @param poseData Pose coming from the device
  29561. */
  29562. updateFromDevice(poseData: DevicePose): void;
  29563. /**
  29564. * WebVR's attach control will start broadcasting frames to the device.
  29565. * Note that in certain browsers (chrome for example) this function must be called
  29566. * within a user-interaction callback. Example:
  29567. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29568. *
  29569. * @param element html element to attach the vrDevice to
  29570. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29571. */
  29572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29573. /**
  29574. * Detaches the camera from the html element and disables VR
  29575. *
  29576. * @param element html element to detach from
  29577. */
  29578. detachControl(element: HTMLElement): void;
  29579. /**
  29580. * @returns the name of this class
  29581. */
  29582. getClassName(): string;
  29583. /**
  29584. * Calls resetPose on the vrDisplay
  29585. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29586. */
  29587. resetToCurrentRotation(): void;
  29588. /**
  29589. * Updates the rig cameras (left and right eye)
  29590. */
  29591. private _workingVector;
  29592. private _oneVector;
  29593. private _workingMatrix;
  29594. private updateCacheCalled;
  29595. /**
  29596. * Updates the cached values of the camera
  29597. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29598. */
  29599. /**
  29600. * Updates the current device position and rotation in the babylon world
  29601. */
  29602. update(): void;
  29603. /**
  29604. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29605. * @returns an identity matrix
  29606. */
  29607. /**
  29608. * This function is called by the two RIG cameras.
  29609. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29610. */
  29611. protected _getWebVRViewMatrix(): Matrix;
  29612. protected _getWebVRProjectionMatrix(): Matrix;
  29613. private _onGamepadConnectedObserver;
  29614. private _onGamepadDisconnectedObserver;
  29615. /**
  29616. * Initializes the controllers and their meshes
  29617. */
  29618. initControllers(): void;
  29619. }
  29620. }
  29621. declare module BABYLON {
  29622. /**
  29623. * Interface to implement to create a shadow generator compatible with BJS.
  29624. */
  29625. interface IShadowGenerator {
  29626. /**
  29627. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29628. * @returns The render target texture if present otherwise, null
  29629. */
  29630. getShadowMap(): Nullable<RenderTargetTexture>;
  29631. /**
  29632. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29633. * @returns The render target texture if the shadow map is present otherwise, null
  29634. */
  29635. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29636. /**
  29637. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29638. * @param subMesh The submesh we want to render in the shadow map
  29639. * @param useInstances Defines wether will draw in the map using instances
  29640. * @returns true if ready otherwise, false
  29641. */
  29642. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29643. /**
  29644. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29645. * @param defines Defines of the material we want to update
  29646. * @param lightIndex Index of the light in the enabled light list of the material
  29647. */
  29648. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29649. /**
  29650. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29651. * defined in the generator but impacting the effect).
  29652. * It implies the unifroms available on the materials are the standard BJS ones.
  29653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29654. * @param effect The effect we are binfing the information for
  29655. */
  29656. bindShadowLight(lightIndex: string, effect: Effect): void;
  29657. /**
  29658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29659. * (eq to shadow prjection matrix * light transform matrix)
  29660. * @returns The transform matrix used to create the shadow map
  29661. */
  29662. getTransformMatrix(): Matrix;
  29663. /**
  29664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29665. * Cube and 2D textures for instance.
  29666. */
  29667. recreateShadowMap(): void;
  29668. /**
  29669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29670. * @param onCompiled Callback triggered at the and of the effects compilation
  29671. * @param options Sets of optional options forcing the compilation with different modes
  29672. */
  29673. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  29674. useInstances: boolean;
  29675. }>): void;
  29676. /**
  29677. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29678. * @param options Sets of optional options forcing the compilation with different modes
  29679. * @returns A promise that resolves when the compilation completes
  29680. */
  29681. forceCompilationAsync(options?: Partial<{
  29682. useInstances: boolean;
  29683. }>): Promise<void>;
  29684. /**
  29685. * Serializes the shadow generator setup to a json object.
  29686. * @returns The serialized JSON object
  29687. */
  29688. serialize(): any;
  29689. /**
  29690. * Disposes the Shadow map and related Textures and effects.
  29691. */
  29692. dispose(): void;
  29693. }
  29694. /**
  29695. * Default implementation IShadowGenerator.
  29696. * This is the main object responsible of generating shadows in the framework.
  29697. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29698. */
  29699. class ShadowGenerator implements IShadowGenerator {
  29700. /**
  29701. * Shadow generator mode None: no filtering applied.
  29702. */
  29703. static readonly FILTER_NONE: number;
  29704. /**
  29705. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29706. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29707. */
  29708. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29709. /**
  29710. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29711. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29712. */
  29713. static readonly FILTER_POISSONSAMPLING: number;
  29714. /**
  29715. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29717. */
  29718. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29719. /**
  29720. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29721. * edge artifacts on steep falloff.
  29722. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29723. */
  29724. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29725. /**
  29726. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29727. * edge artifacts on steep falloff.
  29728. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29729. */
  29730. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29731. /**
  29732. * Shadow generator mode PCF: Percentage Closer Filtering
  29733. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29734. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29735. */
  29736. static readonly FILTER_PCF: number;
  29737. /**
  29738. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29739. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29740. * Contact Hardening
  29741. */
  29742. static readonly FILTER_PCSS: number;
  29743. /**
  29744. * Reserved for PCF and PCSS
  29745. * Highest Quality.
  29746. *
  29747. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29748. *
  29749. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29750. */
  29751. static readonly QUALITY_HIGH: number;
  29752. /**
  29753. * Reserved for PCF and PCSS
  29754. * Good tradeoff for quality/perf cross devices
  29755. *
  29756. * Execute PCF on a 3*3 kernel.
  29757. *
  29758. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29759. */
  29760. static readonly QUALITY_MEDIUM: number;
  29761. /**
  29762. * Reserved for PCF and PCSS
  29763. * The lowest quality but the fastest.
  29764. *
  29765. * Execute PCF on a 1*1 kernel.
  29766. *
  29767. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29768. */
  29769. static readonly QUALITY_LOW: number;
  29770. private _bias;
  29771. /**
  29772. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29773. */
  29774. /**
  29775. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29776. */
  29777. bias: number;
  29778. private _normalBias;
  29779. /**
  29780. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29781. */
  29782. /**
  29783. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29784. */
  29785. normalBias: number;
  29786. private _blurBoxOffset;
  29787. /**
  29788. * Gets the blur box offset: offset applied during the blur pass.
  29789. * Only usefull if useKernelBlur = false
  29790. */
  29791. /**
  29792. * Sets the blur box offset: offset applied during the blur pass.
  29793. * Only usefull if useKernelBlur = false
  29794. */
  29795. blurBoxOffset: number;
  29796. private _blurScale;
  29797. /**
  29798. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29799. * 2 means half of the size.
  29800. */
  29801. /**
  29802. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29803. * 2 means half of the size.
  29804. */
  29805. blurScale: number;
  29806. private _blurKernel;
  29807. /**
  29808. * Gets the blur kernel: kernel size of the blur pass.
  29809. * Only usefull if useKernelBlur = true
  29810. */
  29811. /**
  29812. * Sets the blur kernel: kernel size of the blur pass.
  29813. * Only usefull if useKernelBlur = true
  29814. */
  29815. blurKernel: number;
  29816. private _useKernelBlur;
  29817. /**
  29818. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29819. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  29820. */
  29821. /**
  29822. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29823. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  29824. */
  29825. useKernelBlur: boolean;
  29826. private _depthScale;
  29827. /**
  29828. * Gets the depth scale used in ESM mode.
  29829. */
  29830. /**
  29831. * Sets the depth scale used in ESM mode.
  29832. * This can override the scale stored on the light.
  29833. */
  29834. depthScale: number;
  29835. private _filter;
  29836. /**
  29837. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29838. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29839. */
  29840. /**
  29841. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29842. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29843. */
  29844. filter: number;
  29845. /**
  29846. * Gets if the current filter is set to Poisson Sampling.
  29847. */
  29848. /**
  29849. * Sets the current filter to Poisson Sampling.
  29850. */
  29851. usePoissonSampling: boolean;
  29852. /**
  29853. * Gets if the current filter is set to VSM.
  29854. * DEPRECATED. Should use useExponentialShadowMap instead.
  29855. */
  29856. /**
  29857. * Sets the current filter is to VSM.
  29858. * DEPRECATED. Should use useExponentialShadowMap instead.
  29859. */
  29860. useVarianceShadowMap: boolean;
  29861. /**
  29862. * Gets if the current filter is set to blurred VSM.
  29863. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  29864. */
  29865. /**
  29866. * Sets the current filter is to blurred VSM.
  29867. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  29868. */
  29869. useBlurVarianceShadowMap: boolean;
  29870. /**
  29871. * Gets if the current filter is set to ESM.
  29872. */
  29873. /**
  29874. * Sets the current filter is to ESM.
  29875. */
  29876. useExponentialShadowMap: boolean;
  29877. /**
  29878. * Gets if the current filter is set to filtered ESM.
  29879. */
  29880. /**
  29881. * Gets if the current filter is set to filtered ESM.
  29882. */
  29883. useBlurExponentialShadowMap: boolean;
  29884. /**
  29885. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29886. * exponential to prevent steep falloff artifacts).
  29887. */
  29888. /**
  29889. * Sets the current filter to "close ESM" (using the inverse of the
  29890. * exponential to prevent steep falloff artifacts).
  29891. */
  29892. useCloseExponentialShadowMap: boolean;
  29893. /**
  29894. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29895. * exponential to prevent steep falloff artifacts).
  29896. */
  29897. /**
  29898. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29899. * exponential to prevent steep falloff artifacts).
  29900. */
  29901. useBlurCloseExponentialShadowMap: boolean;
  29902. /**
  29903. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29904. */
  29905. /**
  29906. * Sets the current filter to "PCF" (percentage closer filtering).
  29907. */
  29908. usePercentageCloserFiltering: boolean;
  29909. private _filteringQuality;
  29910. /**
  29911. * Gets the PCF or PCSS Quality.
  29912. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29913. */
  29914. /**
  29915. * Sets the PCF or PCSS Quality.
  29916. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29917. */
  29918. filteringQuality: number;
  29919. /**
  29920. * Gets if the current filter is set to "PCSS" (contact hardening).
  29921. */
  29922. /**
  29923. * Sets the current filter to "PCSS" (contact hardening).
  29924. */
  29925. useContactHardeningShadow: boolean;
  29926. private _contactHardeningLightSizeUVRatio;
  29927. /**
  29928. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29929. * Using a ratio helps keeping shape stability independently of the map size.
  29930. *
  29931. * It does not account for the light projection as it was having too much
  29932. * instability during the light setup or during light position changes.
  29933. *
  29934. * Only valid if useContactHardeningShadow is true.
  29935. */
  29936. /**
  29937. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29938. * Using a ratio helps keeping shape stability independently of the map size.
  29939. *
  29940. * It does not account for the light projection as it was having too much
  29941. * instability during the light setup or during light position changes.
  29942. *
  29943. * Only valid if useContactHardeningShadow is true.
  29944. */
  29945. contactHardeningLightSizeUVRatio: number;
  29946. private _darkness;
  29947. /**
  29948. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29949. * 0 means strongest and 1 would means no shadow.
  29950. * @returns the darkness.
  29951. */
  29952. getDarkness(): number;
  29953. /**
  29954. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29955. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29956. * @returns the shadow generator allowing fluent coding.
  29957. */
  29958. setDarkness(darkness: number): ShadowGenerator;
  29959. private _transparencyShadow;
  29960. /**
  29961. * Sets the ability to have transparent shadow (boolean).
  29962. * @param transparent True if transparent else False
  29963. * @returns the shadow generator allowing fluent coding
  29964. */
  29965. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29966. private _shadowMap;
  29967. private _shadowMap2;
  29968. /**
  29969. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29970. * @returns The render target texture if present otherwise, null
  29971. */
  29972. getShadowMap(): Nullable<RenderTargetTexture>;
  29973. /**
  29974. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29975. * @returns The render target texture if the shadow map is present otherwise, null
  29976. */
  29977. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29978. /**
  29979. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29980. * @param mesh Mesh to add
  29981. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29982. * @returns the Shadow Generator itself
  29983. */
  29984. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29985. /**
  29986. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29987. * @param mesh Mesh to remove
  29988. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29989. * @returns the Shadow Generator itself
  29990. */
  29991. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29992. /**
  29993. * Controls the extent to which the shadows fade out at the edge of the frustum
  29994. * Used only by directionals and spots
  29995. */
  29996. frustumEdgeFalloff: number;
  29997. private _light;
  29998. /**
  29999. * Returns the associated light object.
  30000. * @returns the light generating the shadow
  30001. */
  30002. getLight(): IShadowLight;
  30003. /**
  30004. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30005. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30006. * It might on the other hand introduce peter panning.
  30007. */
  30008. forceBackFacesOnly: boolean;
  30009. private _scene;
  30010. private _lightDirection;
  30011. private _effect;
  30012. private _viewMatrix;
  30013. private _projectionMatrix;
  30014. private _transformMatrix;
  30015. private _cachedPosition;
  30016. private _cachedDirection;
  30017. private _cachedDefines;
  30018. private _currentRenderID;
  30019. private _boxBlurPostprocess;
  30020. private _kernelBlurXPostprocess;
  30021. private _kernelBlurYPostprocess;
  30022. private _blurPostProcesses;
  30023. private _mapSize;
  30024. private _currentFaceIndex;
  30025. private _currentFaceIndexCache;
  30026. private _textureType;
  30027. private _defaultTextureMatrix;
  30028. /**
  30029. * Creates a ShadowGenerator object.
  30030. * A ShadowGenerator is the required tool to use the shadows.
  30031. * Each light casting shadows needs to use its own ShadowGenerator.
  30032. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  30033. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30034. * @param light The light object generating the shadows.
  30035. * @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.
  30036. */
  30037. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  30038. private _initializeGenerator();
  30039. private _initializeShadowMap();
  30040. private _initializeBlurRTTAndPostProcesses();
  30041. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  30042. private _renderSubMeshForShadowMap(subMesh);
  30043. private _applyFilterValues();
  30044. /**
  30045. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30046. * @param onCompiled Callback triggered at the and of the effects compilation
  30047. * @param options Sets of optional options forcing the compilation with different modes
  30048. */
  30049. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30050. useInstances: boolean;
  30051. }>): void;
  30052. /**
  30053. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30054. * @param options Sets of optional options forcing the compilation with different modes
  30055. * @returns A promise that resolves when the compilation completes
  30056. */
  30057. forceCompilationAsync(options?: Partial<{
  30058. useInstances: boolean;
  30059. }>): Promise<void>;
  30060. /**
  30061. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30062. * @param subMesh The submesh we want to render in the shadow map
  30063. * @param useInstances Defines wether will draw in the map using instances
  30064. * @returns true if ready otherwise, false
  30065. */
  30066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30067. /**
  30068. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30069. * @param defines Defines of the material we want to update
  30070. * @param lightIndex Index of the light in the enabled light list of the material
  30071. */
  30072. prepareDefines(defines: any, lightIndex: number): void;
  30073. /**
  30074. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30075. * defined in the generator but impacting the effect).
  30076. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30077. * @param effect The effect we are binfing the information for
  30078. */
  30079. bindShadowLight(lightIndex: string, effect: Effect): void;
  30080. /**
  30081. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30082. * (eq to shadow prjection matrix * light transform matrix)
  30083. * @returns The transform matrix used to create the shadow map
  30084. */
  30085. getTransformMatrix(): Matrix;
  30086. /**
  30087. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30088. * Cube and 2D textures for instance.
  30089. */
  30090. recreateShadowMap(): void;
  30091. private _disposeBlurPostProcesses();
  30092. private _disposeRTTandPostProcesses();
  30093. /**
  30094. * Disposes the ShadowGenerator.
  30095. * Returns nothing.
  30096. */
  30097. dispose(): void;
  30098. /**
  30099. * Serializes the shadow generator setup to a json object.
  30100. * @returns The serialized JSON object
  30101. */
  30102. serialize(): any;
  30103. /**
  30104. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30105. * @param parsedShadowGenerator The JSON object to parse
  30106. * @param scene The scene to create the shadow map for
  30107. * @returns The parsed shadow generator
  30108. */
  30109. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  30110. }
  30111. }
  30112. declare module BABYLON {
  30113. }
  30114. declare module BABYLON {
  30115. /**
  30116. * Google Daydream controller
  30117. */
  30118. class DaydreamController extends WebVRController {
  30119. /**
  30120. * Base Url for the controller model.
  30121. */
  30122. static MODEL_BASE_URL: string;
  30123. /**
  30124. * File name for the controller model.
  30125. */
  30126. static MODEL_FILENAME: string;
  30127. /**
  30128. * Gamepad Id prefix used to identify Daydream Controller.
  30129. */
  30130. static readonly GAMEPAD_ID_PREFIX: string;
  30131. /**
  30132. * Creates a new DaydreamController from a gamepad
  30133. * @param vrGamepad the gamepad that the controller should be created from
  30134. */
  30135. constructor(vrGamepad: any);
  30136. /**
  30137. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30138. * @param scene scene in which to add meshes
  30139. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30140. */
  30141. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30142. /**
  30143. * Called once for each button that changed state since the last frame
  30144. * @param buttonIdx Which button index changed
  30145. * @param state New state of the button
  30146. * @param changes Which properties on the state changed since last frame
  30147. */
  30148. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30149. }
  30150. }
  30151. declare module BABYLON {
  30152. /**
  30153. * Gear VR Controller
  30154. */
  30155. class GearVRController extends WebVRController {
  30156. /**
  30157. * Base Url for the controller model.
  30158. */
  30159. static MODEL_BASE_URL: string;
  30160. /**
  30161. * File name for the controller model.
  30162. */
  30163. static MODEL_FILENAME: string;
  30164. /**
  30165. * Gamepad Id prefix used to identify this controller.
  30166. */
  30167. static readonly GAMEPAD_ID_PREFIX: string;
  30168. private readonly _buttonIndexToObservableNameMap;
  30169. /**
  30170. * Creates a new GearVRController from a gamepad
  30171. * @param vrGamepad the gamepad that the controller should be created from
  30172. */
  30173. constructor(vrGamepad: any);
  30174. /**
  30175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30176. * @param scene scene in which to add meshes
  30177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30178. */
  30179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30180. /**
  30181. * Called once for each button that changed state since the last frame
  30182. * @param buttonIdx Which button index changed
  30183. * @param state New state of the button
  30184. * @param changes Which properties on the state changed since last frame
  30185. */
  30186. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30187. }
  30188. }
  30189. declare module BABYLON {
  30190. /**
  30191. * Generic Controller
  30192. */
  30193. class GenericController extends WebVRController {
  30194. /**
  30195. * Base Url for the controller model.
  30196. */
  30197. static readonly MODEL_BASE_URL: string;
  30198. /**
  30199. * File name for the controller model.
  30200. */
  30201. static readonly MODEL_FILENAME: string;
  30202. /**
  30203. * Creates a new GenericController from a gamepad
  30204. * @param vrGamepad the gamepad that the controller should be created from
  30205. */
  30206. constructor(vrGamepad: any);
  30207. /**
  30208. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30209. * @param scene scene in which to add meshes
  30210. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30211. */
  30212. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30213. /**
  30214. * Called once for each button that changed state since the last frame
  30215. * @param buttonIdx Which button index changed
  30216. * @param state New state of the button
  30217. * @param changes Which properties on the state changed since last frame
  30218. */
  30219. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30220. }
  30221. }
  30222. declare module BABYLON {
  30223. /**
  30224. * Oculus Touch Controller
  30225. */
  30226. class OculusTouchController extends WebVRController {
  30227. /**
  30228. * Base Url for the controller model.
  30229. */
  30230. static MODEL_BASE_URL: string;
  30231. /**
  30232. * File name for the left controller model.
  30233. */
  30234. static MODEL_LEFT_FILENAME: string;
  30235. /**
  30236. * File name for the right controller model.
  30237. */
  30238. static MODEL_RIGHT_FILENAME: string;
  30239. /**
  30240. * Fired when the secondary trigger on this controller is modified
  30241. */
  30242. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30243. /**
  30244. * Fired when the thumb rest on this controller is modified
  30245. */
  30246. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30247. /**
  30248. * Creates a new OculusTouchController from a gamepad
  30249. * @param vrGamepad the gamepad that the controller should be created from
  30250. */
  30251. constructor(vrGamepad: any);
  30252. /**
  30253. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30254. * @param scene scene in which to add meshes
  30255. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30256. */
  30257. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30258. /**
  30259. * Fired when the A button on this controller is modified
  30260. */
  30261. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30262. /**
  30263. * Fired when the B button on this controller is modified
  30264. */
  30265. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30266. /**
  30267. * Fired when the X button on this controller is modified
  30268. */
  30269. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30270. /**
  30271. * Fired when the Y button on this controller is modified
  30272. */
  30273. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30274. /**
  30275. * Called once for each button that changed state since the last frame
  30276. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30277. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30278. * 2) secondary trigger (same)
  30279. * 3) A (right) X (left), touch, pressed = value
  30280. * 4) B / Y
  30281. * 5) thumb rest
  30282. * @param buttonIdx Which button index changed
  30283. * @param state New state of the button
  30284. * @param changes Which properties on the state changed since last frame
  30285. */
  30286. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30287. }
  30288. }
  30289. declare module BABYLON {
  30290. /**
  30291. * Defines the types of pose enabled controllers that are supported
  30292. */
  30293. enum PoseEnabledControllerType {
  30294. /**
  30295. * HTC Vive
  30296. */
  30297. VIVE = 0,
  30298. /**
  30299. * Oculus Rift
  30300. */
  30301. OCULUS = 1,
  30302. /**
  30303. * Windows mixed reality
  30304. */
  30305. WINDOWS = 2,
  30306. /**
  30307. * Samsung gear VR
  30308. */
  30309. GEAR_VR = 3,
  30310. /**
  30311. * Google Daydream
  30312. */
  30313. DAYDREAM = 4,
  30314. /**
  30315. * Generic
  30316. */
  30317. GENERIC = 5,
  30318. }
  30319. /**
  30320. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30321. */
  30322. interface MutableGamepadButton {
  30323. /**
  30324. * Value of the button/trigger
  30325. */
  30326. value: number;
  30327. /**
  30328. * If the button/trigger is currently touched
  30329. */
  30330. touched: boolean;
  30331. /**
  30332. * If the button/trigger is currently pressed
  30333. */
  30334. pressed: boolean;
  30335. }
  30336. /**
  30337. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30338. * @hidden
  30339. */
  30340. interface ExtendedGamepadButton extends GamepadButton {
  30341. /**
  30342. * If the button/trigger is currently pressed
  30343. */
  30344. readonly pressed: boolean;
  30345. /**
  30346. * If the button/trigger is currently touched
  30347. */
  30348. readonly touched: boolean;
  30349. /**
  30350. * Value of the button/trigger
  30351. */
  30352. readonly value: number;
  30353. }
  30354. /**
  30355. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30356. */
  30357. class PoseEnabledControllerHelper {
  30358. /**
  30359. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30360. * @param vrGamepad the gamepad to initialized
  30361. * @returns a vr controller of the type the gamepad identified as
  30362. */
  30363. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30364. }
  30365. /**
  30366. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30367. */
  30368. class PoseEnabledController extends Gamepad implements PoseControlled {
  30369. private _deviceRoomPosition;
  30370. private _deviceRoomRotationQuaternion;
  30371. /**
  30372. * The device position in babylon space
  30373. */
  30374. devicePosition: Vector3;
  30375. /**
  30376. * The device rotation in babylon space
  30377. */
  30378. deviceRotationQuaternion: Quaternion;
  30379. /**
  30380. * The scale factor of the device in babylon space
  30381. */
  30382. deviceScaleFactor: number;
  30383. /**
  30384. * (Likely devicePosition should be used instead) The device position in its room space
  30385. */
  30386. position: Vector3;
  30387. /**
  30388. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30389. */
  30390. rotationQuaternion: Quaternion;
  30391. /**
  30392. * The type of controller (Eg. Windows mixed reality)
  30393. */
  30394. controllerType: PoseEnabledControllerType;
  30395. private _calculatedPosition;
  30396. private _calculatedRotation;
  30397. /**
  30398. * The raw pose from the device
  30399. */
  30400. rawPose: DevicePose;
  30401. /**
  30402. * Internal, the mesh attached to the controller
  30403. */
  30404. private _poseControlledCamera;
  30405. private _leftHandSystemQuaternion;
  30406. /**
  30407. * Internal, matrix used to convert room space to babylon space
  30408. */
  30409. /**
  30410. * Node to be used when casting a ray from the controller
  30411. */
  30412. /**
  30413. * Name of the child mesh that can be used to cast a ray from the controller
  30414. */
  30415. static readonly POINTING_POSE: string;
  30416. /**
  30417. * Creates a new PoseEnabledController from a gamepad
  30418. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30419. */
  30420. constructor(browserGamepad: any);
  30421. private _workingMatrix;
  30422. /**
  30423. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30424. */
  30425. update(): void;
  30426. /**
  30427. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30428. * @param poseData raw pose fromthe device
  30429. */
  30430. updateFromDevice(poseData: DevicePose): void;
  30431. /**
  30432. * @hidden
  30433. */
  30434. /**
  30435. * Attaches a mesh to the controller
  30436. * @param mesh the mesh to be attached
  30437. */
  30438. attachToMesh(mesh: AbstractMesh): void;
  30439. /**
  30440. * Attaches the controllers mesh to a camera
  30441. * @param camera the camera the mesh should be attached to
  30442. */
  30443. attachToPoseControlledCamera(camera: TargetCamera): void;
  30444. /**
  30445. * Disposes of the controller
  30446. */
  30447. dispose(): void;
  30448. /**
  30449. * The mesh that is attached to the controller
  30450. */
  30451. readonly mesh: Nullable<AbstractMesh>;
  30452. /**
  30453. * Gets the ray of the controller in the direction the controller is pointing
  30454. * @param length the length the resulting ray should be
  30455. * @returns a ray in the direction the controller is pointing
  30456. */
  30457. getForwardRay(length?: number): Ray;
  30458. }
  30459. }
  30460. declare module BABYLON {
  30461. /**
  30462. * Vive Controller
  30463. */
  30464. class ViveController extends WebVRController {
  30465. /**
  30466. * Base Url for the controller model.
  30467. */
  30468. static MODEL_BASE_URL: string;
  30469. /**
  30470. * File name for the controller model.
  30471. */
  30472. static MODEL_FILENAME: string;
  30473. /**
  30474. * Creates a new ViveController from a gamepad
  30475. * @param vrGamepad the gamepad that the controller should be created from
  30476. */
  30477. constructor(vrGamepad: any);
  30478. /**
  30479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30480. * @param scene scene in which to add meshes
  30481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30482. */
  30483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30484. /**
  30485. * Fired when the left button on this controller is modified
  30486. */
  30487. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30488. /**
  30489. * Fired when the right button on this controller is modified
  30490. */
  30491. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30492. /**
  30493. * Fired when the menu button on this controller is modified
  30494. */
  30495. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30496. /**
  30497. * Called once for each button that changed state since the last frame
  30498. * Vive mapping:
  30499. * 0: touchpad
  30500. * 1: trigger
  30501. * 2: left AND right buttons
  30502. * 3: menu button
  30503. * @param buttonIdx Which button index changed
  30504. * @param state New state of the button
  30505. * @param changes Which properties on the state changed since last frame
  30506. */
  30507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30508. }
  30509. }
  30510. declare module BABYLON {
  30511. /**
  30512. * Defines the WebVRController object that represents controllers tracked in 3D space
  30513. */
  30514. abstract class WebVRController extends PoseEnabledController {
  30515. /**
  30516. * Internal, the default controller model for the controller
  30517. */
  30518. protected _defaultModel: AbstractMesh;
  30519. /**
  30520. * Fired when the trigger state has changed
  30521. */
  30522. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30523. /**
  30524. * Fired when the main button state has changed
  30525. */
  30526. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30527. /**
  30528. * Fired when the secondary button state has changed
  30529. */
  30530. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30531. /**
  30532. * Fired when the pad state has changed
  30533. */
  30534. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30535. /**
  30536. * Fired when controllers stick values have changed
  30537. */
  30538. onPadValuesChangedObservable: Observable<StickValues>;
  30539. /**
  30540. * Array of button availible on the controller
  30541. */
  30542. protected _buttons: Array<MutableGamepadButton>;
  30543. private _onButtonStateChange;
  30544. /**
  30545. * Fired when a controller button's state has changed
  30546. * @param callback the callback containing the button that was modified
  30547. */
  30548. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30549. /**
  30550. * X and Y axis corrisponding to the controllers joystick
  30551. */
  30552. pad: StickValues;
  30553. /**
  30554. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30555. */
  30556. hand: string;
  30557. /**
  30558. * The default controller model for the controller
  30559. */
  30560. readonly defaultModel: AbstractMesh;
  30561. /**
  30562. * Creates a new WebVRController from a gamepad
  30563. * @param vrGamepad the gamepad that the WebVRController should be created from
  30564. */
  30565. constructor(vrGamepad: any);
  30566. /**
  30567. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30568. */
  30569. update(): void;
  30570. /**
  30571. * Function to be called when a button is modified
  30572. */
  30573. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30574. /**
  30575. * Loads a mesh and attaches it to the controller
  30576. * @param scene the scene the mesh should be added to
  30577. * @param meshLoaded callback for when the mesh has been loaded
  30578. */
  30579. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30580. private _setButtonValue(newState, currentState, buttonIndex);
  30581. private _changes;
  30582. private _checkChanges(newState, currentState);
  30583. /**
  30584. * Disposes of th webVRCOntroller
  30585. */
  30586. dispose(): void;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /**
  30591. * Defines the WindowsMotionController object that the state of the windows motion controller
  30592. */
  30593. class WindowsMotionController extends WebVRController {
  30594. /**
  30595. * The base url used to load the left and right controller models
  30596. */
  30597. static MODEL_BASE_URL: string;
  30598. /**
  30599. * The name of the left controller model file
  30600. */
  30601. static MODEL_LEFT_FILENAME: string;
  30602. /**
  30603. * The name of the right controller model file
  30604. */
  30605. static MODEL_RIGHT_FILENAME: string;
  30606. /**
  30607. * The controller name prefix for this controller type
  30608. */
  30609. static readonly GAMEPAD_ID_PREFIX: string;
  30610. /**
  30611. * The controller id pattern for this controller type
  30612. */
  30613. private static readonly GAMEPAD_ID_PATTERN;
  30614. private _loadedMeshInfo;
  30615. private readonly _mapping;
  30616. /**
  30617. * Fired when the trackpad on this controller is clicked
  30618. */
  30619. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30620. /**
  30621. * Fired when the trackpad on this controller is modified
  30622. */
  30623. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30624. /**
  30625. * The current x and y values of this controller's trackpad
  30626. */
  30627. trackpad: StickValues;
  30628. /**
  30629. * Creates a new WindowsMotionController from a gamepad
  30630. * @param vrGamepad the gamepad that the controller should be created from
  30631. */
  30632. constructor(vrGamepad: any);
  30633. /**
  30634. * Fired when the trigger on this controller is modified
  30635. */
  30636. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30637. /**
  30638. * Fired when the menu button on this controller is modified
  30639. */
  30640. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30641. /**
  30642. * Fired when the grip button on this controller is modified
  30643. */
  30644. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30645. /**
  30646. * Fired when the thumbstick button on this controller is modified
  30647. */
  30648. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30649. /**
  30650. * Fired when the touchpad button on this controller is modified
  30651. */
  30652. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30653. /**
  30654. * Fired when the touchpad values on this controller are modified
  30655. */
  30656. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30657. /**
  30658. * Called once per frame by the engine.
  30659. */
  30660. update(): void;
  30661. /**
  30662. * Called once for each button that changed state since the last frame
  30663. * @param buttonIdx Which button index changed
  30664. * @param state New state of the button
  30665. * @param changes Which properties on the state changed since last frame
  30666. */
  30667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30668. /**
  30669. * Moves the buttons on the controller mesh based on their current state
  30670. * @param buttonName the name of the button to move
  30671. * @param buttonValue the value of the button which determines the buttons new position
  30672. */
  30673. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30674. /**
  30675. * Moves the axis on the controller mesh based on its current state
  30676. * @param axis the index of the axis
  30677. * @param axisValue the value of the axis which determines the meshes new position
  30678. * @hidden
  30679. */
  30680. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30681. /**
  30682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30683. * @param scene scene in which to add meshes
  30684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30685. */
  30686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30687. /**
  30688. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30689. * can be transformed by button presses and axes values, based on this._mapping.
  30690. *
  30691. * @param scene scene in which the meshes exist
  30692. * @param meshes list of meshes that make up the controller model to process
  30693. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30694. */
  30695. private processModel(scene, meshes);
  30696. private createMeshInfo(rootNode);
  30697. /**
  30698. * Gets the ray of the controller in the direction the controller is pointing
  30699. * @param length the length the resulting ray should be
  30700. * @returns a ray in the direction the controller is pointing
  30701. */
  30702. getForwardRay(length?: number): Ray;
  30703. /**
  30704. * Disposes of the controller
  30705. */
  30706. dispose(): void;
  30707. }
  30708. }
  30709. declare module BABYLON {
  30710. /**
  30711. * Background material used to create an efficient environement around your scene.
  30712. */
  30713. class BackgroundMaterial extends PushMaterial {
  30714. /**
  30715. * Standard reflectance value at parallel view angle.
  30716. */
  30717. static StandardReflectance0: number;
  30718. /**
  30719. * Standard reflectance value at grazing angle.
  30720. */
  30721. static StandardReflectance90: number;
  30722. protected _primaryColor: Color3;
  30723. /**
  30724. * Key light Color (multiply against the environement texture)
  30725. */
  30726. primaryColor: Color3;
  30727. protected __perceptualColor: Nullable<Color3>;
  30728. /**
  30729. * Experimental Internal Use Only.
  30730. *
  30731. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  30732. * This acts as a helper to set the primary color to a more "human friendly" value.
  30733. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  30734. * output color as close as possible from the chosen value.
  30735. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  30736. * part of lighting setup.)
  30737. */
  30738. protected _primaryColorShadowLevel: float;
  30739. /**
  30740. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  30741. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  30742. */
  30743. primaryColorShadowLevel: float;
  30744. protected _primaryColorHighlightLevel: float;
  30745. /**
  30746. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  30747. * The primary color is used at the level chosen to define what the white area would look.
  30748. */
  30749. primaryColorHighlightLevel: float;
  30750. protected _reflectionTexture: Nullable<BaseTexture>;
  30751. /**
  30752. * Reflection Texture used in the material.
  30753. * Should be author in a specific way for the best result (refer to the documentation).
  30754. */
  30755. reflectionTexture: Nullable<BaseTexture>;
  30756. protected _reflectionBlur: float;
  30757. /**
  30758. * Reflection Texture level of blur.
  30759. *
  30760. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  30761. * texture twice.
  30762. */
  30763. reflectionBlur: float;
  30764. protected _diffuseTexture: Nullable<BaseTexture>;
  30765. /**
  30766. * Diffuse Texture used in the material.
  30767. * Should be author in a specific way for the best result (refer to the documentation).
  30768. */
  30769. diffuseTexture: Nullable<BaseTexture>;
  30770. protected _shadowLights: Nullable<IShadowLight[]>;
  30771. /**
  30772. * Specify the list of lights casting shadow on the material.
  30773. * All scene shadow lights will be included if null.
  30774. */
  30775. shadowLights: Nullable<IShadowLight[]>;
  30776. protected _shadowLevel: float;
  30777. /**
  30778. * Helps adjusting the shadow to a softer level if required.
  30779. * 0 means black shadows and 1 means no shadows.
  30780. */
  30781. shadowLevel: float;
  30782. protected _sceneCenter: Vector3;
  30783. /**
  30784. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  30785. * It is usually zero but might be interesting to modify according to your setup.
  30786. */
  30787. sceneCenter: Vector3;
  30788. protected _opacityFresnel: boolean;
  30789. /**
  30790. * This helps specifying that the material is falling off to the sky box at grazing angle.
  30791. * This helps ensuring a nice transition when the camera goes under the ground.
  30792. */
  30793. opacityFresnel: boolean;
  30794. protected _reflectionFresnel: boolean;
  30795. /**
  30796. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  30797. * This helps adding a mirror texture on the ground.
  30798. */
  30799. reflectionFresnel: boolean;
  30800. protected _reflectionFalloffDistance: number;
  30801. /**
  30802. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  30803. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  30804. */
  30805. reflectionFalloffDistance: number;
  30806. protected _reflectionAmount: number;
  30807. /**
  30808. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  30809. */
  30810. reflectionAmount: number;
  30811. protected _reflectionReflectance0: number;
  30812. /**
  30813. * This specifies the weight of the reflection at grazing angle.
  30814. */
  30815. reflectionReflectance0: number;
  30816. protected _reflectionReflectance90: number;
  30817. /**
  30818. * This specifies the weight of the reflection at a perpendicular point of view.
  30819. */
  30820. reflectionReflectance90: number;
  30821. /**
  30822. * Sets the reflection reflectance fresnel values according to the default standard
  30823. * empirically know to work well :-)
  30824. */
  30825. reflectionStandardFresnelWeight: number;
  30826. protected _useRGBColor: boolean;
  30827. /**
  30828. * Helps to directly use the maps channels instead of their level.
  30829. */
  30830. useRGBColor: boolean;
  30831. protected _enableNoise: boolean;
  30832. /**
  30833. * This helps reducing the banding effect that could occur on the background.
  30834. */
  30835. enableNoise: boolean;
  30836. /**
  30837. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  30838. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  30839. * Recommended to be keep at 1.0 except for special cases.
  30840. */
  30841. fovMultiplier: number;
  30842. private _fovMultiplier;
  30843. /**
  30844. * Enable the FOV adjustment feature controlled by fovMultiplier.
  30845. */
  30846. useEquirectangularFOV: boolean;
  30847. private _maxSimultaneousLights;
  30848. /**
  30849. * Number of Simultaneous lights allowed on the material.
  30850. */
  30851. maxSimultaneousLights: int;
  30852. /**
  30853. * Default configuration related to image processing available in the Background Material.
  30854. */
  30855. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30856. /**
  30857. * Keep track of the image processing observer to allow dispose and replace.
  30858. */
  30859. private _imageProcessingObserver;
  30860. /**
  30861. * Attaches a new image processing configuration to the PBR Material.
  30862. * @param configuration (if null the scene configuration will be use)
  30863. */
  30864. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30865. /**
  30866. * Gets the image processing configuration used either in this material.
  30867. */
  30868. /**
  30869. * Sets the Default image processing configuration used either in the this material.
  30870. *
  30871. * If sets to null, the scene one is in use.
  30872. */
  30873. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  30874. /**
  30875. * Gets wether the color curves effect is enabled.
  30876. */
  30877. /**
  30878. * Sets wether the color curves effect is enabled.
  30879. */
  30880. cameraColorCurvesEnabled: boolean;
  30881. /**
  30882. * Gets wether the color grading effect is enabled.
  30883. */
  30884. /**
  30885. * Gets wether the color grading effect is enabled.
  30886. */
  30887. cameraColorGradingEnabled: boolean;
  30888. /**
  30889. * Gets wether tonemapping is enabled or not.
  30890. */
  30891. /**
  30892. * Sets wether tonemapping is enabled or not
  30893. */
  30894. cameraToneMappingEnabled: boolean;
  30895. /**
  30896. * The camera exposure used on this material.
  30897. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30898. * This corresponds to a photographic exposure.
  30899. */
  30900. /**
  30901. * The camera exposure used on this material.
  30902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30903. * This corresponds to a photographic exposure.
  30904. */
  30905. cameraExposure: float;
  30906. /**
  30907. * Gets The camera contrast used on this material.
  30908. */
  30909. /**
  30910. * Sets The camera contrast used on this material.
  30911. */
  30912. cameraContrast: float;
  30913. /**
  30914. * Gets the Color Grading 2D Lookup Texture.
  30915. */
  30916. /**
  30917. * Sets the Color Grading 2D Lookup Texture.
  30918. */
  30919. cameraColorGradingTexture: Nullable<BaseTexture>;
  30920. /**
  30921. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30922. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30923. * 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;
  30924. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30925. */
  30926. /**
  30927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30929. * 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;
  30930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30931. */
  30932. cameraColorCurves: Nullable<ColorCurves>;
  30933. /**
  30934. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  30935. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  30936. */
  30937. switchToBGR: boolean;
  30938. private _renderTargets;
  30939. private _reflectionControls;
  30940. private _white;
  30941. private _primaryShadowColor;
  30942. private _primaryHighlightColor;
  30943. /**
  30944. * Instantiates a Background Material in the given scene
  30945. * @param name The friendly name of the material
  30946. * @param scene The scene to add the material to
  30947. */
  30948. constructor(name: string, scene: Scene);
  30949. /**
  30950. * The entire material has been created in order to prevent overdraw.
  30951. * @returns false
  30952. */
  30953. needAlphaTesting(): boolean;
  30954. /**
  30955. * The entire material has been created in order to prevent overdraw.
  30956. * @returns true if blending is enable
  30957. */
  30958. needAlphaBlending(): boolean;
  30959. /**
  30960. * Checks wether the material is ready to be rendered for a given mesh.
  30961. * @param mesh The mesh to render
  30962. * @param subMesh The submesh to check against
  30963. * @param useInstances Specify wether or not the material is used with instances
  30964. * @returns true if all the dependencies are ready (Textures, Effects...)
  30965. */
  30966. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30967. /**
  30968. * Compute the primary color according to the chosen perceptual color.
  30969. */
  30970. private _computePrimaryColorFromPerceptualColor();
  30971. /**
  30972. * Compute the highlights and shadow colors according to their chosen levels.
  30973. */
  30974. private _computePrimaryColors();
  30975. /**
  30976. * Build the uniform buffer used in the material.
  30977. */
  30978. buildUniformLayout(): void;
  30979. /**
  30980. * Unbind the material.
  30981. */
  30982. unbind(): void;
  30983. /**
  30984. * Bind only the world matrix to the material.
  30985. * @param world The world matrix to bind.
  30986. */
  30987. bindOnlyWorldMatrix(world: Matrix): void;
  30988. /**
  30989. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  30990. * @param world The world matrix to bind.
  30991. * @param subMesh The submesh to bind for.
  30992. */
  30993. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30994. /**
  30995. * Dispose the material.
  30996. * @param forceDisposeEffect Force disposal of the associated effect.
  30997. * @param forceDisposeTextures Force disposal of the associated textures.
  30998. */
  30999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31000. /**
  31001. * Clones the material.
  31002. * @param name The cloned name.
  31003. * @returns The cloned material.
  31004. */
  31005. clone(name: string): BackgroundMaterial;
  31006. /**
  31007. * Serializes the current material to its JSON representation.
  31008. * @returns The JSON representation.
  31009. */
  31010. serialize(): any;
  31011. /**
  31012. * Gets the class name of the material
  31013. * @returns "BackgroundMaterial"
  31014. */
  31015. getClassName(): string;
  31016. /**
  31017. * Parse a JSON input to create back a background material.
  31018. * @param source The JSON data to parse
  31019. * @param scene The scene to create the parsed material in
  31020. * @param rootUrl The root url of the assets the material depends upon
  31021. * @returns the instantiated BackgroundMaterial.
  31022. */
  31023. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31024. }
  31025. }
  31026. declare module BABYLON {
  31027. class BaseTexture {
  31028. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31029. name: string;
  31030. private _hasAlpha;
  31031. hasAlpha: boolean;
  31032. getAlphaFromRGB: boolean;
  31033. level: number;
  31034. coordinatesIndex: number;
  31035. private _coordinatesMode;
  31036. /**
  31037. * How a texture is mapped.
  31038. *
  31039. * | Value | Type | Description |
  31040. * | ----- | ----------------------------------- | ----------- |
  31041. * | 0 | EXPLICIT_MODE | |
  31042. * | 1 | SPHERICAL_MODE | |
  31043. * | 2 | PLANAR_MODE | |
  31044. * | 3 | CUBIC_MODE | |
  31045. * | 4 | PROJECTION_MODE | |
  31046. * | 5 | SKYBOX_MODE | |
  31047. * | 6 | INVCUBIC_MODE | |
  31048. * | 7 | EQUIRECTANGULAR_MODE | |
  31049. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31050. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31051. */
  31052. coordinatesMode: number;
  31053. /**
  31054. * | Value | Type | Description |
  31055. * | ----- | ------------------ | ----------- |
  31056. * | 0 | CLAMP_ADDRESSMODE | |
  31057. * | 1 | WRAP_ADDRESSMODE | |
  31058. * | 2 | MIRROR_ADDRESSMODE | |
  31059. */
  31060. wrapU: number;
  31061. /**
  31062. * | Value | Type | Description |
  31063. * | ----- | ------------------ | ----------- |
  31064. * | 0 | CLAMP_ADDRESSMODE | |
  31065. * | 1 | WRAP_ADDRESSMODE | |
  31066. * | 2 | MIRROR_ADDRESSMODE | |
  31067. */
  31068. wrapV: number;
  31069. /**
  31070. * | Value | Type | Description |
  31071. * | ----- | ------------------ | ----------- |
  31072. * | 0 | CLAMP_ADDRESSMODE | |
  31073. * | 1 | WRAP_ADDRESSMODE | |
  31074. * | 2 | MIRROR_ADDRESSMODE | |
  31075. */
  31076. wrapR: number;
  31077. anisotropicFilteringLevel: number;
  31078. isCube: boolean;
  31079. is3D: boolean;
  31080. gammaSpace: boolean;
  31081. invertZ: boolean;
  31082. lodLevelInAlpha: boolean;
  31083. lodGenerationOffset: number;
  31084. lodGenerationScale: number;
  31085. isRenderTarget: boolean;
  31086. readonly uid: string;
  31087. toString(): string;
  31088. getClassName(): string;
  31089. animations: Animation[];
  31090. /**
  31091. * An event triggered when the texture is disposed.
  31092. */
  31093. onDisposeObservable: Observable<BaseTexture>;
  31094. private _onDisposeObserver;
  31095. onDispose: () => void;
  31096. delayLoadState: number;
  31097. private _scene;
  31098. private _uid;
  31099. readonly isBlocking: boolean;
  31100. constructor(scene: Nullable<Scene>);
  31101. getScene(): Nullable<Scene>;
  31102. getTextureMatrix(): Matrix;
  31103. getReflectionTextureMatrix(): Matrix;
  31104. getInternalTexture(): Nullable<InternalTexture>;
  31105. isReadyOrNotBlocking(): boolean;
  31106. isReady(): boolean;
  31107. getSize(): ISize;
  31108. getBaseSize(): ISize;
  31109. scale(ratio: number): void;
  31110. readonly canRescale: boolean;
  31111. delayLoad(): void;
  31112. clone(): Nullable<BaseTexture>;
  31113. readonly textureType: number;
  31114. readonly textureFormat: number;
  31115. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  31116. releaseInternalTexture(): void;
  31117. sphericalPolynomial: Nullable<SphericalPolynomial>;
  31118. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  31119. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  31120. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  31121. dispose(): void;
  31122. serialize(): any;
  31123. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31124. }
  31125. }
  31126. declare module BABYLON {
  31127. /**
  31128. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  31129. * It can help converting any input color in a desired output one. This can then be used to create effects
  31130. * from sepia, black and white to sixties or futuristic rendering...
  31131. *
  31132. * The only supported format is currently 3dl.
  31133. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  31134. */
  31135. class ColorGradingTexture extends BaseTexture {
  31136. /**
  31137. * The current texture matrix. (will always be identity in color grading texture)
  31138. */
  31139. private _textureMatrix;
  31140. /**
  31141. * The texture URL.
  31142. */
  31143. url: string;
  31144. /**
  31145. * Empty line regex stored for GC.
  31146. */
  31147. private static _noneEmptyLineRegex;
  31148. private _engine;
  31149. /**
  31150. * Instantiates a ColorGradingTexture from the following parameters.
  31151. *
  31152. * @param url The location of the color gradind data (currently only supporting 3dl)
  31153. * @param scene The scene the texture will be used in
  31154. */
  31155. constructor(url: string, scene: Scene);
  31156. /**
  31157. * Returns the texture matrix used in most of the material.
  31158. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  31159. */
  31160. getTextureMatrix(): Matrix;
  31161. /**
  31162. * Occurs when the file being loaded is a .3dl LUT file.
  31163. */
  31164. private load3dlTexture();
  31165. /**
  31166. * Starts the loading process of the texture.
  31167. */
  31168. private loadTexture();
  31169. /**
  31170. * Clones the color gradind texture.
  31171. */
  31172. clone(): ColorGradingTexture;
  31173. /**
  31174. * Called during delayed load for textures.
  31175. */
  31176. delayLoad(): void;
  31177. /**
  31178. * Parses a color grading texture serialized by Babylon.
  31179. * @param parsedTexture The texture information being parsedTexture
  31180. * @param scene The scene to load the texture in
  31181. * @param rootUrl The root url of the data assets to load
  31182. * @return A color gradind texture
  31183. */
  31184. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  31185. /**
  31186. * Serializes the LUT texture to json format.
  31187. */
  31188. serialize(): any;
  31189. }
  31190. }
  31191. declare module BABYLON {
  31192. class CubeTexture extends BaseTexture {
  31193. url: string;
  31194. coordinatesMode: number;
  31195. /**
  31196. * Gets or sets the center of the bounding box associated with the cube texture
  31197. * It must define where the camera used to render the texture was set
  31198. */
  31199. boundingBoxPosition: Vector3;
  31200. private _boundingBoxSize;
  31201. /**
  31202. * Gets or sets the size of the bounding box associated with the cube texture
  31203. * When defined, the cubemap will switch to local mode
  31204. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31205. * @example https://www.babylonjs-playground.com/#RNASML
  31206. */
  31207. boundingBoxSize: Vector3;
  31208. protected _rotationY: number;
  31209. /**
  31210. * Gets texture matrix rotation angle around Y axis radians.
  31211. */
  31212. /**
  31213. * Sets texture matrix rotation angle around Y axis in radians.
  31214. */
  31215. rotationY: number;
  31216. private _noMipmap;
  31217. private _files;
  31218. private _extensions;
  31219. private _textureMatrix;
  31220. private _format;
  31221. private _prefiltered;
  31222. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  31223. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  31224. 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);
  31225. delayLoad(): void;
  31226. getReflectionTextureMatrix(): Matrix;
  31227. setReflectionTextureMatrix(value: Matrix): void;
  31228. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  31229. clone(): CubeTexture;
  31230. }
  31231. }
  31232. declare module BABYLON {
  31233. /**
  31234. * A class extending {BABYLON.Texture} allowing drawing on a texture
  31235. * @see http://doc.babylonjs.com/how_to/dynamictexture
  31236. */
  31237. class DynamicTexture extends Texture {
  31238. private _generateMipMaps;
  31239. private _canvas;
  31240. private _context;
  31241. private _engine;
  31242. /**
  31243. * Creates a {BABYLON.DynamicTexture}
  31244. * @param name defines the name of the texture
  31245. * @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
  31246. * @param scene defines the scene where you want the texture
  31247. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  31248. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  31249. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  31250. */
  31251. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  31252. /**
  31253. * Gets the current state of canRescale
  31254. */
  31255. readonly canRescale: boolean;
  31256. private _recreate(textureSize);
  31257. /**
  31258. * Scales the texture
  31259. * @param ratio the scale factor to apply to both width and height
  31260. */
  31261. scale(ratio: number): void;
  31262. /**
  31263. * Resizes the texture
  31264. * @param width the new width
  31265. * @param height the new height
  31266. */
  31267. scaleTo(width: number, height: number): void;
  31268. /**
  31269. * Gets the context of the canvas used by the texture
  31270. * @returns the canvas context of the dynamic texture
  31271. */
  31272. getContext(): CanvasRenderingContext2D;
  31273. /**
  31274. * Clears the texture
  31275. */
  31276. clear(): void;
  31277. /**
  31278. * Updates the texture
  31279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  31280. */
  31281. update(invertY?: boolean): void;
  31282. /**
  31283. * Draws text onto the texture
  31284. * @param text defines the text to be drawn
  31285. * @param x defines the placement of the text from the left
  31286. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  31287. * @param font defines the font to be used with font-style, font-size, font-name
  31288. * @param color defines the color used for the text
  31289. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  31290. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  31291. * @param update defines whether texture is immediately update (default is true)
  31292. */
  31293. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  31294. /**
  31295. * Clones the texture
  31296. * @returns the clone of the texture.
  31297. */
  31298. clone(): DynamicTexture;
  31299. /** @hidden */
  31300. }
  31301. }
  31302. declare module BABYLON {
  31303. /**
  31304. * This represents a texture coming from an HDR input.
  31305. *
  31306. * The only supported format is currently panorama picture stored in RGBE format.
  31307. * Example of such files can be found on HDRLib: http://hdrlib.com/
  31308. */
  31309. class HDRCubeTexture extends BaseTexture {
  31310. private static _facesMapping;
  31311. private _generateHarmonics;
  31312. private _noMipmap;
  31313. private _textureMatrix;
  31314. private _size;
  31315. private _onLoad;
  31316. private _onError;
  31317. /**
  31318. * The texture URL.
  31319. */
  31320. url: string;
  31321. /**
  31322. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  31323. */
  31324. coordinatesMode: number;
  31325. protected _isBlocking: boolean;
  31326. /**
  31327. * Gets wether or not the texture is blocking during loading.
  31328. */
  31329. /**
  31330. * Sets wether or not the texture is blocking during loading.
  31331. */
  31332. isBlocking: boolean;
  31333. protected _rotationY: number;
  31334. /**
  31335. * Gets texture matrix rotation angle around Y axis radians.
  31336. */
  31337. /**
  31338. * Sets texture matrix rotation angle around Y axis in radians.
  31339. */
  31340. rotationY: number;
  31341. /**
  31342. * Gets or sets the center of the bounding box associated with the cube texture
  31343. * It must define where the camera used to render the texture was set
  31344. */
  31345. boundingBoxPosition: Vector3;
  31346. private _boundingBoxSize;
  31347. /**
  31348. * Gets or sets the size of the bounding box associated with the cube texture
  31349. * When defined, the cubemap will switch to local mode
  31350. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31351. * @example https://www.babylonjs-playground.com/#RNASML
  31352. */
  31353. boundingBoxSize: Vector3;
  31354. /**
  31355. * Instantiates an HDRTexture from the following parameters.
  31356. *
  31357. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  31358. * @param scene The scene the texture will be used in
  31359. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  31360. * @param noMipmap Forces to not generate the mipmap if true
  31361. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  31362. * @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)
  31363. * @param reserved Reserved flag for internal use.
  31364. */
  31365. 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>);
  31366. /**
  31367. * Occurs when the file is raw .hdr file.
  31368. */
  31369. private loadTexture();
  31370. clone(): HDRCubeTexture;
  31371. delayLoad(): void;
  31372. getReflectionTextureMatrix(): Matrix;
  31373. setReflectionTextureMatrix(value: Matrix): void;
  31374. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  31375. serialize(): any;
  31376. }
  31377. }
  31378. declare module BABYLON {
  31379. /**
  31380. * Class used to store data associated with WebGL texture data for the engine
  31381. * This class should not be used directly
  31382. */
  31383. class InternalTexture implements IInternalTextureTracker {
  31384. /**
  31385. * The source of the texture data is unknown
  31386. */
  31387. static DATASOURCE_UNKNOWN: number;
  31388. /**
  31389. * Texture data comes from an URL
  31390. */
  31391. static DATASOURCE_URL: number;
  31392. /**
  31393. * Texture data is only used for temporary storage
  31394. */
  31395. static DATASOURCE_TEMP: number;
  31396. /**
  31397. * Texture data comes from raw data (ArrayBuffer)
  31398. */
  31399. static DATASOURCE_RAW: number;
  31400. /**
  31401. * Texture content is dynamic (video or dynamic texture)
  31402. */
  31403. static DATASOURCE_DYNAMIC: number;
  31404. /**
  31405. * Texture content is generated by rendering to it
  31406. */
  31407. static DATASOURCE_RENDERTARGET: number;
  31408. /**
  31409. * Texture content is part of a multi render target process
  31410. */
  31411. static DATASOURCE_MULTIRENDERTARGET: number;
  31412. /**
  31413. * Texture data comes from a cube data file
  31414. */
  31415. static DATASOURCE_CUBE: number;
  31416. /**
  31417. * Texture data comes from a raw cube data
  31418. */
  31419. static DATASOURCE_CUBERAW: number;
  31420. /**
  31421. * Texture data come from a prefiltered cube data file
  31422. */
  31423. static DATASOURCE_CUBEPREFILTERED: number;
  31424. /**
  31425. * Texture content is raw 3D data
  31426. */
  31427. static DATASOURCE_RAW3D: number;
  31428. /**
  31429. * Texture content is a depth texture
  31430. */
  31431. static DATASOURCE_DEPTHTEXTURE: number;
  31432. /**
  31433. * Defines if the texture is ready
  31434. */
  31435. isReady: boolean;
  31436. /**
  31437. * Defines if the texture is a cube texture
  31438. */
  31439. isCube: boolean;
  31440. /**
  31441. * Defines if the texture contains 3D data
  31442. */
  31443. is3D: boolean;
  31444. /**
  31445. * Gets the URL used to load this texture
  31446. */
  31447. url: string;
  31448. /**
  31449. * Gets the sampling mode of the texture
  31450. */
  31451. samplingMode: number;
  31452. /**
  31453. * Gets a boolean indicating if the texture needs mipmaps generation
  31454. */
  31455. generateMipMaps: boolean;
  31456. /**
  31457. * Gets the number of samples used by the texture (WebGL2+ only)
  31458. */
  31459. samples: number;
  31460. /**
  31461. * Gets the type of the texture
  31462. */
  31463. type: number;
  31464. /**
  31465. * Gets the format of the texture
  31466. */
  31467. format: number;
  31468. /**
  31469. * Observable called when the texture is loaded
  31470. */
  31471. onLoadedObservable: Observable<InternalTexture>;
  31472. /**
  31473. * Gets the width of the texture
  31474. */
  31475. width: number;
  31476. /**
  31477. * Gets the height of the texture
  31478. */
  31479. height: number;
  31480. /**
  31481. * Gets the depth of the texture
  31482. */
  31483. depth: number;
  31484. /**
  31485. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31486. */
  31487. baseWidth: number;
  31488. /**
  31489. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31490. */
  31491. baseHeight: number;
  31492. /**
  31493. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31494. */
  31495. baseDepth: number;
  31496. /**
  31497. * Gets a boolean indicating if the texture is inverted on Y axis
  31498. */
  31499. invertY: boolean;
  31500. /**
  31501. * Gets or set the previous tracker in the list
  31502. */
  31503. previous: Nullable<IInternalTextureTracker>;
  31504. /**
  31505. * Gets or set the next tracker in the list
  31506. */
  31507. next: Nullable<IInternalTextureTracker>;
  31508. /** @hidden */
  31509. /** @hidden */
  31510. /** @hidden */
  31511. /** @hidden */
  31512. /** @hidden */
  31513. /** @hidden */
  31514. /** @hidden */
  31515. /** @hidden */
  31516. /** @hidden */
  31517. /** @hidden */
  31518. /** @hidden */
  31519. /** @hidden */
  31520. /** @hidden */
  31521. /** @hidden */
  31522. /** @hidden */
  31523. /** @hidden */
  31524. /** @hidden */
  31525. /** @hidden */
  31526. /** @hidden */
  31527. /** @hidden */
  31528. /** @hidden */
  31529. /** @hidden */
  31530. /** @hidden */
  31531. /** @hidden */
  31532. /** @hidden */
  31533. /** @hidden */
  31534. /** @hidden */
  31535. /** @hidden */
  31536. /** @hidden */
  31537. /** @hidden */
  31538. /** @hidden */
  31539. /** @hidden */
  31540. /** @hidden */
  31541. /** @hidden */
  31542. private _engine;
  31543. /**
  31544. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  31545. */
  31546. readonly dataSource: number;
  31547. /**
  31548. * Creates a new InternalTexture
  31549. * @param engine defines the engine to use
  31550. * @param dataSource defines the type of data that will be used
  31551. */
  31552. constructor(engine: Engine, dataSource: number);
  31553. /**
  31554. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  31555. */
  31556. incrementReferences(): void;
  31557. /**
  31558. * Change the size of the texture (not the size of the content)
  31559. * @param width defines the new width
  31560. * @param height defines the new height
  31561. * @param depth defines the new depth (1 by default)
  31562. */
  31563. updateSize(width: int, height: int, depth?: int): void;
  31564. /** @hidden */
  31565. private _swapAndDie(target);
  31566. /**
  31567. * Dispose the current allocated resources
  31568. */
  31569. dispose(): void;
  31570. }
  31571. }
  31572. declare module BABYLON {
  31573. /**
  31574. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  31575. */
  31576. interface IInternalTextureTracker {
  31577. /**
  31578. * Gets or set the previous tracker in the list
  31579. */
  31580. previous: Nullable<IInternalTextureTracker>;
  31581. /**
  31582. * Gets or set the next tracker in the list
  31583. */
  31584. next: Nullable<IInternalTextureTracker>;
  31585. }
  31586. /**
  31587. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  31588. */
  31589. class DummyInternalTextureTracker {
  31590. /**
  31591. * Gets or set the previous tracker in the list
  31592. */
  31593. previous: Nullable<IInternalTextureTracker>;
  31594. /**
  31595. * Gets or set the next tracker in the list
  31596. */
  31597. next: Nullable<IInternalTextureTracker>;
  31598. }
  31599. }
  31600. declare module BABYLON {
  31601. class MirrorTexture extends RenderTargetTexture {
  31602. private scene;
  31603. mirrorPlane: Plane;
  31604. private _transformMatrix;
  31605. private _mirrorMatrix;
  31606. private _savedViewMatrix;
  31607. private _blurX;
  31608. private _blurY;
  31609. private _adaptiveBlurKernel;
  31610. private _blurKernelX;
  31611. private _blurKernelY;
  31612. private _blurRatio;
  31613. blurRatio: number;
  31614. adaptiveBlurKernel: number;
  31615. blurKernel: number;
  31616. blurKernelX: number;
  31617. blurKernelY: number;
  31618. private _autoComputeBlurKernel();
  31619. protected _onRatioRescale(): void;
  31620. private _updateGammaSpace();
  31621. private _imageProcessingConfigChangeObserver;
  31622. constructor(name: string, size: number | {
  31623. width: number;
  31624. height: number;
  31625. } | {
  31626. ratio: number;
  31627. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  31628. private _preparePostProcesses();
  31629. clone(): MirrorTexture;
  31630. serialize(): any;
  31631. dispose(): void;
  31632. }
  31633. }
  31634. declare module BABYLON {
  31635. interface IMultiRenderTargetOptions {
  31636. generateMipMaps?: boolean;
  31637. types?: number[];
  31638. samplingModes?: number[];
  31639. generateDepthBuffer?: boolean;
  31640. generateStencilBuffer?: boolean;
  31641. generateDepthTexture?: boolean;
  31642. textureCount?: number;
  31643. doNotChangeAspectRatio?: boolean;
  31644. defaultType?: number;
  31645. }
  31646. class MultiRenderTarget extends RenderTargetTexture {
  31647. private _internalTextures;
  31648. private _textures;
  31649. readonly isSupported: boolean;
  31650. private _multiRenderTargetOptions;
  31651. readonly textures: Texture[];
  31652. readonly depthTexture: Texture;
  31653. wrapU: number;
  31654. wrapV: number;
  31655. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  31656. private _createInternalTextures();
  31657. private _createTextures();
  31658. samples: number;
  31659. resize(size: any): void;
  31660. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  31661. dispose(): void;
  31662. releaseInternalTextures(): void;
  31663. }
  31664. }
  31665. declare module BABYLON {
  31666. class RawTexture extends Texture {
  31667. format: number;
  31668. private _engine;
  31669. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  31670. update(data: ArrayBufferView): void;
  31671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31672. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31673. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31674. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  31675. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  31676. }
  31677. }
  31678. declare module BABYLON {
  31679. /**
  31680. * Class used to store 3D textures containing user data
  31681. */
  31682. class RawTexture3D extends Texture {
  31683. /** Gets or sets the texture format to use*/
  31684. format: number;
  31685. private _engine;
  31686. /**
  31687. * Create a new RawTexture3D
  31688. * @param data defines the data of the texture
  31689. * @param width defines the width of the texture
  31690. * @param height defines the height of the texture
  31691. * @param depth defines the depth of the texture
  31692. * @param format defines the texture format to use
  31693. * @param scene defines the hosting scene
  31694. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  31695. * @param invertY defines if texture must be stored with Y axis inverted
  31696. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  31697. */
  31698. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  31699. /** Gets or sets the texture format to use*/
  31700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  31701. /**
  31702. * Update the texture with new data
  31703. * @param data defines the data to store in the texture
  31704. */
  31705. update(data: ArrayBufferView): void;
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. /**
  31710. * Creates a refraction texture used by refraction channel of the standard material.
  31711. * @param name the texture name
  31712. * @param size size of the underlying texture
  31713. * @param scene root scene
  31714. */
  31715. class RefractionTexture extends RenderTargetTexture {
  31716. refractionPlane: Plane;
  31717. depth: number;
  31718. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  31719. clone(): RefractionTexture;
  31720. serialize(): any;
  31721. }
  31722. }
  31723. declare module BABYLON {
  31724. class RenderTargetTexture extends Texture {
  31725. isCube: boolean;
  31726. private static _REFRESHRATE_RENDER_ONCE: number;
  31727. private static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  31728. private static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  31729. static readonly REFRESHRATE_RENDER_ONCE: number;
  31730. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  31731. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  31732. /**
  31733. * Use this predicate to dynamically define the list of mesh you want to render.
  31734. * If set, the renderList property will be overwritten.
  31735. */
  31736. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  31737. /**
  31738. * Use this list to define the list of mesh you want to render.
  31739. */
  31740. renderList: Nullable<Array<AbstractMesh>>;
  31741. renderParticles: boolean;
  31742. renderSprites: boolean;
  31743. coordinatesMode: number;
  31744. activeCamera: Nullable<Camera>;
  31745. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  31746. useCameraPostProcesses: boolean;
  31747. ignoreCameraViewport: boolean;
  31748. private _postProcessManager;
  31749. private _postProcesses;
  31750. private _resizeObserver;
  31751. /**
  31752. * An event triggered when the texture is unbind.
  31753. */
  31754. onBeforeBindObservable: Observable<RenderTargetTexture>;
  31755. /**
  31756. * An event triggered when the texture is unbind.
  31757. */
  31758. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  31759. private _onAfterUnbindObserver;
  31760. onAfterUnbind: () => void;
  31761. /**
  31762. * An event triggered before rendering the texture
  31763. */
  31764. onBeforeRenderObservable: Observable<number>;
  31765. private _onBeforeRenderObserver;
  31766. onBeforeRender: (faceIndex: number) => void;
  31767. /**
  31768. * An event triggered after rendering the texture
  31769. */
  31770. onAfterRenderObservable: Observable<number>;
  31771. private _onAfterRenderObserver;
  31772. onAfterRender: (faceIndex: number) => void;
  31773. /**
  31774. * An event triggered after the texture clear
  31775. */
  31776. onClearObservable: Observable<Engine>;
  31777. private _onClearObserver;
  31778. onClear: (Engine: Engine) => void;
  31779. clearColor: Color4;
  31780. protected _size: number | {
  31781. width: number;
  31782. height: number;
  31783. };
  31784. protected _initialSizeParameter: number | {
  31785. width: number;
  31786. height: number;
  31787. } | {
  31788. ratio: number;
  31789. };
  31790. protected _sizeRatio: Nullable<number>;
  31791. protected _renderingManager: RenderingManager;
  31792. protected _doNotChangeAspectRatio: boolean;
  31793. protected _currentRefreshId: number;
  31794. protected _refreshRate: number;
  31795. protected _textureMatrix: Matrix;
  31796. protected _samples: number;
  31797. protected _renderTargetOptions: RenderTargetCreationOptions;
  31798. readonly renderTargetOptions: RenderTargetCreationOptions;
  31799. protected _engine: Engine;
  31800. protected _onRatioRescale(): void;
  31801. /**
  31802. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  31803. * It must define where the camera used to render the texture is set
  31804. */
  31805. boundingBoxPosition: Vector3;
  31806. private _boundingBoxSize;
  31807. /**
  31808. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  31809. * When defined, the cubemap will switch to local mode
  31810. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31811. * @example https://www.babylonjs-playground.com/#RNASML
  31812. */
  31813. boundingBoxSize: Vector3;
  31814. /**
  31815. * In case the RTT has been created with a depth texture, get the associated
  31816. * depth texture.
  31817. * Otherwise, return null.
  31818. */
  31819. depthStencilTexture: Nullable<InternalTexture>;
  31820. /**
  31821. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  31822. * or used a shadow, depth texture...
  31823. * @param name The friendly name of the texture
  31824. * @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)
  31825. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  31826. * @param generateMipMaps True if mip maps need to be generated after render.
  31827. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  31828. * @param type The type of the buffer in the RTT (int, half float, float...)
  31829. * @param isCube True if a cube texture needs to be created
  31830. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  31831. * @param generateDepthBuffer True to generate a depth buffer
  31832. * @param generateStencilBuffer True to generate a stencil buffer
  31833. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  31834. */
  31835. constructor(name: string, size: number | {
  31836. width: number;
  31837. height: number;
  31838. } | {
  31839. ratio: number;
  31840. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  31841. /**
  31842. * Creates a depth stencil texture.
  31843. * This is only available in WebGL 2 or with the depth texture extension available.
  31844. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  31845. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  31846. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  31847. */
  31848. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  31849. private _processSizeParameter(size);
  31850. samples: number;
  31851. resetRefreshCounter(): void;
  31852. refreshRate: number;
  31853. addPostProcess(postProcess: PostProcess): void;
  31854. clearPostProcesses(dispose?: boolean): void;
  31855. removePostProcess(postProcess: PostProcess): void;
  31856. getRenderSize(): number;
  31857. getRenderWidth(): number;
  31858. getRenderHeight(): number;
  31859. readonly canRescale: boolean;
  31860. scale(ratio: number): void;
  31861. getReflectionTextureMatrix(): Matrix;
  31862. resize(size: number | {
  31863. width: number;
  31864. height: number;
  31865. } | {
  31866. ratio: number;
  31867. }): void;
  31868. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  31869. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  31870. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  31871. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  31872. /**
  31873. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  31874. * This allowed control for front to back rendering or reversly depending of the special needs.
  31875. *
  31876. * @param renderingGroupId The rendering group id corresponding to its index
  31877. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  31878. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  31879. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  31880. */
  31881. 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;
  31882. /**
  31883. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  31884. *
  31885. * @param renderingGroupId The rendering group id corresponding to its index
  31886. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  31887. */
  31888. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  31889. clone(): RenderTargetTexture;
  31890. serialize(): any;
  31891. disposeFramebufferObjects(): void;
  31892. dispose(): void;
  31893. /**
  31894. * Clear the info related to rendering groups preventing retention point in material dispose.
  31895. */
  31896. freeRenderingGroups(): void;
  31897. }
  31898. }
  31899. declare module BABYLON {
  31900. class Texture extends BaseTexture {
  31901. static NEAREST_SAMPLINGMODE: number;
  31902. static NEAREST_NEAREST_MIPLINEAR: number;
  31903. static BILINEAR_SAMPLINGMODE: number;
  31904. static LINEAR_LINEAR_MIPNEAREST: number;
  31905. static TRILINEAR_SAMPLINGMODE: number;
  31906. static LINEAR_LINEAR_MIPLINEAR: number;
  31907. static NEAREST_NEAREST_MIPNEAREST: number;
  31908. static NEAREST_LINEAR_MIPNEAREST: number;
  31909. static NEAREST_LINEAR_MIPLINEAR: number;
  31910. static NEAREST_LINEAR: number;
  31911. static NEAREST_NEAREST: number;
  31912. static LINEAR_NEAREST_MIPNEAREST: number;
  31913. static LINEAR_NEAREST_MIPLINEAR: number;
  31914. static LINEAR_LINEAR: number;
  31915. static LINEAR_NEAREST: number;
  31916. static EXPLICIT_MODE: number;
  31917. static SPHERICAL_MODE: number;
  31918. static PLANAR_MODE: number;
  31919. static CUBIC_MODE: number;
  31920. static PROJECTION_MODE: number;
  31921. static SKYBOX_MODE: number;
  31922. static INVCUBIC_MODE: number;
  31923. static EQUIRECTANGULAR_MODE: number;
  31924. static FIXED_EQUIRECTANGULAR_MODE: number;
  31925. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31926. static CLAMP_ADDRESSMODE: number;
  31927. static WRAP_ADDRESSMODE: number;
  31928. static MIRROR_ADDRESSMODE: number;
  31929. /**
  31930. * 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
  31931. */
  31932. static UseSerializedUrlIfAny: boolean;
  31933. url: Nullable<string>;
  31934. uOffset: number;
  31935. vOffset: number;
  31936. uScale: number;
  31937. vScale: number;
  31938. uAng: number;
  31939. vAng: number;
  31940. wAng: number;
  31941. readonly noMipmap: boolean;
  31942. private _noMipmap;
  31943. private _rowGenerationMatrix;
  31944. private _cachedTextureMatrix;
  31945. private _projectionModeMatrix;
  31946. private _t0;
  31947. private _t1;
  31948. private _t2;
  31949. private _cachedUOffset;
  31950. private _cachedVOffset;
  31951. private _cachedUScale;
  31952. private _cachedVScale;
  31953. private _cachedUAng;
  31954. private _cachedVAng;
  31955. private _cachedWAng;
  31956. private _cachedProjectionMatrixId;
  31957. private _cachedCoordinatesMode;
  31958. private _buffer;
  31959. private _deleteBuffer;
  31960. protected _format: Nullable<number>;
  31961. private _delayedOnLoad;
  31962. private _delayedOnError;
  31963. protected _onLoadObservable: Nullable<Observable<Texture>>;
  31964. protected _isBlocking: boolean;
  31965. isBlocking: boolean;
  31966. readonly samplingMode: number;
  31967. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  31968. updateURL(url: string): void;
  31969. delayLoad(): void;
  31970. updateSamplingMode(samplingMode: number): void;
  31971. private _prepareRowForTextureGeneration(x, y, z, t);
  31972. getTextureMatrix(): Matrix;
  31973. getReflectionTextureMatrix(): Matrix;
  31974. clone(): Texture;
  31975. readonly onLoadObservable: Observable<Texture>;
  31976. serialize(): any;
  31977. getClassName(): string;
  31978. dispose(): void;
  31979. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  31980. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  31981. 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;
  31982. }
  31983. }
  31984. declare module BABYLON {
  31985. /**
  31986. * Settings for finer control over video usage
  31987. */
  31988. interface VideoTextureSettings {
  31989. /**
  31990. * Applies `autoplay` to video, if specified
  31991. */
  31992. autoPlay?: boolean;
  31993. /**
  31994. * Applies `loop` to video, if specified
  31995. */
  31996. loop?: boolean;
  31997. /**
  31998. * Automatically updates internal texture from video at every frame in the render loop
  31999. */
  32000. autoUpdateTexture: boolean;
  32001. }
  32002. class VideoTexture extends Texture {
  32003. /**
  32004. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32005. */
  32006. readonly autoUpdateTexture: boolean;
  32007. /**
  32008. * The video instance used by the texture internally
  32009. */
  32010. readonly video: HTMLVideoElement;
  32011. private _generateMipMaps;
  32012. private _engine;
  32013. private _stillImageCaptured;
  32014. /**
  32015. * Creates a video texture.
  32016. * Sample : https://doc.babylonjs.com/how_to/video_texture
  32017. * @param {string | null} name optional name, will detect from video source, if not defined
  32018. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  32019. * @param {BABYLON.Scene} scene is obviously the current scene.
  32020. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32021. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  32022. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32023. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  32024. */
  32025. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32026. private _getName(src);
  32027. private _getVideo(src);
  32028. private _createInternalTexture;
  32029. private reset;
  32030. /**
  32031. * Internal method to initiate `update`.
  32032. */
  32033. /**
  32034. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32035. */
  32036. update(): void;
  32037. /**
  32038. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32039. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32040. */
  32041. updateTexture(isVisible: boolean): void;
  32042. protected _updateInternalTexture: (e?: Event | undefined) => void;
  32043. /**
  32044. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32045. * @param url New url.
  32046. */
  32047. updateURL(url: string): void;
  32048. dispose(): void;
  32049. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32050. minWidth: number;
  32051. maxWidth: number;
  32052. minHeight: number;
  32053. maxHeight: number;
  32054. deviceId: string;
  32055. }): void;
  32056. }
  32057. }
  32058. declare module BABYLON {
  32059. /**
  32060. * The Physically based material base class of BJS.
  32061. *
  32062. * This offers the main features of a standard PBR material.
  32063. * For more information, please refer to the documentation :
  32064. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32065. */
  32066. abstract class PBRBaseMaterial extends PushMaterial {
  32067. /**
  32068. * Intensity of the direct lights e.g. the four lights available in your scene.
  32069. * This impacts both the direct diffuse and specular highlights.
  32070. */
  32071. protected _directIntensity: number;
  32072. /**
  32073. * Intensity of the emissive part of the material.
  32074. * This helps controlling the emissive effect without modifying the emissive color.
  32075. */
  32076. protected _emissiveIntensity: number;
  32077. /**
  32078. * Intensity of the environment e.g. how much the environment will light the object
  32079. * either through harmonics for rough material or through the refelction for shiny ones.
  32080. */
  32081. protected _environmentIntensity: number;
  32082. /**
  32083. * This is a special control allowing the reduction of the specular highlights coming from the
  32084. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32085. */
  32086. protected _specularIntensity: number;
  32087. /**
  32088. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  32089. */
  32090. private _lightingInfos;
  32091. /**
  32092. * Debug Control allowing disabling the bump map on this material.
  32093. */
  32094. protected _disableBumpMap: boolean;
  32095. /**
  32096. * AKA Diffuse Texture in standard nomenclature.
  32097. */
  32098. protected _albedoTexture: BaseTexture;
  32099. /**
  32100. * AKA Occlusion Texture in other nomenclature.
  32101. */
  32102. protected _ambientTexture: BaseTexture;
  32103. /**
  32104. * AKA Occlusion Texture Intensity in other nomenclature.
  32105. */
  32106. protected _ambientTextureStrength: number;
  32107. /**
  32108. * Stores the alpha values in a texture.
  32109. */
  32110. protected _opacityTexture: BaseTexture;
  32111. /**
  32112. * Stores the reflection values in a texture.
  32113. */
  32114. protected _reflectionTexture: BaseTexture;
  32115. /**
  32116. * Stores the refraction values in a texture.
  32117. */
  32118. protected _refractionTexture: BaseTexture;
  32119. /**
  32120. * Stores the emissive values in a texture.
  32121. */
  32122. protected _emissiveTexture: BaseTexture;
  32123. /**
  32124. * AKA Specular texture in other nomenclature.
  32125. */
  32126. protected _reflectivityTexture: BaseTexture;
  32127. /**
  32128. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32129. */
  32130. protected _metallicTexture: BaseTexture;
  32131. /**
  32132. * Specifies the metallic scalar of the metallic/roughness workflow.
  32133. * Can also be used to scale the metalness values of the metallic texture.
  32134. */
  32135. protected _metallic: number;
  32136. /**
  32137. * Specifies the roughness scalar of the metallic/roughness workflow.
  32138. * Can also be used to scale the roughness values of the metallic texture.
  32139. */
  32140. protected _roughness: number;
  32141. /**
  32142. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32143. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32144. */
  32145. protected _microSurfaceTexture: BaseTexture;
  32146. /**
  32147. * Stores surface normal data used to displace a mesh in a texture.
  32148. */
  32149. protected _bumpTexture: BaseTexture;
  32150. /**
  32151. * Stores the pre-calculated light information of a mesh in a texture.
  32152. */
  32153. protected _lightmapTexture: BaseTexture;
  32154. /**
  32155. * The color of a material in ambient lighting.
  32156. */
  32157. protected _ambientColor: Color3;
  32158. /**
  32159. * AKA Diffuse Color in other nomenclature.
  32160. */
  32161. protected _albedoColor: Color3;
  32162. /**
  32163. * AKA Specular Color in other nomenclature.
  32164. */
  32165. protected _reflectivityColor: Color3;
  32166. /**
  32167. * The color applied when light is reflected from a material.
  32168. */
  32169. protected _reflectionColor: Color3;
  32170. /**
  32171. * The color applied when light is emitted from a material.
  32172. */
  32173. protected _emissiveColor: Color3;
  32174. /**
  32175. * AKA Glossiness in other nomenclature.
  32176. */
  32177. protected _microSurface: number;
  32178. /**
  32179. * source material index of refraction (IOR)' / 'destination material IOR.
  32180. */
  32181. protected _indexOfRefraction: number;
  32182. /**
  32183. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32184. */
  32185. protected _invertRefractionY: boolean;
  32186. /**
  32187. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32188. * Materials half opaque for instance using refraction could benefit from this control.
  32189. */
  32190. protected _linkRefractionWithTransparency: boolean;
  32191. /**
  32192. * Specifies that the material will use the light map as a show map.
  32193. */
  32194. protected _useLightmapAsShadowmap: boolean;
  32195. /**
  32196. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32197. * makes the reflect vector face the model (under horizon).
  32198. */
  32199. protected _useHorizonOcclusion: boolean;
  32200. /**
  32201. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32202. * too much the area relying on ambient texture to define their ambient occlusion.
  32203. */
  32204. protected _useRadianceOcclusion: boolean;
  32205. /**
  32206. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32207. */
  32208. protected _useAlphaFromAlbedoTexture: boolean;
  32209. /**
  32210. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32211. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32212. */
  32213. protected _useSpecularOverAlpha: boolean;
  32214. /**
  32215. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32216. */
  32217. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32218. /**
  32219. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32220. */
  32221. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32222. /**
  32223. * Specifies if the metallic texture contains the roughness information in its green channel.
  32224. */
  32225. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32226. /**
  32227. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32228. */
  32229. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32230. /**
  32231. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32232. */
  32233. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32234. /**
  32235. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32236. */
  32237. protected _useAmbientInGrayScale: boolean;
  32238. /**
  32239. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32240. * The material will try to infer what glossiness each pixel should be.
  32241. */
  32242. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32243. /**
  32244. * BJS is using an harcoded light falloff based on a manually sets up range.
  32245. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32246. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32247. */
  32248. protected _usePhysicalLightFalloff: boolean;
  32249. /**
  32250. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32251. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32252. */
  32253. protected _useRadianceOverAlpha: boolean;
  32254. /**
  32255. * Allows using an object space normal map (instead of tangent space).
  32256. */
  32257. protected _useObjectSpaceNormalMap: boolean;
  32258. /**
  32259. * Allows using the bump map in parallax mode.
  32260. */
  32261. protected _useParallax: boolean;
  32262. /**
  32263. * Allows using the bump map in parallax occlusion mode.
  32264. */
  32265. protected _useParallaxOcclusion: boolean;
  32266. /**
  32267. * Controls the scale bias of the parallax mode.
  32268. */
  32269. protected _parallaxScaleBias: number;
  32270. /**
  32271. * If sets to true, disables all the lights affecting the material.
  32272. */
  32273. protected _disableLighting: boolean;
  32274. /**
  32275. * Number of Simultaneous lights allowed on the material.
  32276. */
  32277. protected _maxSimultaneousLights: number;
  32278. /**
  32279. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32280. */
  32281. protected _invertNormalMapX: boolean;
  32282. /**
  32283. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32284. */
  32285. protected _invertNormalMapY: boolean;
  32286. /**
  32287. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32288. */
  32289. protected _twoSidedLighting: boolean;
  32290. /**
  32291. * Defines the alpha limits in alpha test mode.
  32292. */
  32293. protected _alphaCutOff: number;
  32294. /**
  32295. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32296. */
  32297. protected _forceAlphaTest: boolean;
  32298. /**
  32299. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32300. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32301. */
  32302. protected _useAlphaFresnel: boolean;
  32303. /**
  32304. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32305. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32306. */
  32307. protected _useLinearAlphaFresnel: boolean;
  32308. /**
  32309. * The transparency mode of the material.
  32310. */
  32311. protected _transparencyMode: Nullable<number>;
  32312. /**
  32313. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32314. * from cos thetav and roughness:
  32315. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32316. */
  32317. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32318. /**
  32319. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32320. */
  32321. protected _forceIrradianceInFragment: boolean;
  32322. /**
  32323. * Force normal to face away from face.
  32324. */
  32325. protected _forceNormalForward: boolean;
  32326. /**
  32327. * Enables specular anti aliasing in the PBR shader.
  32328. * It will both interacts on the Geometry for analytical and IBL lighting.
  32329. * It also prefilter the roughness map based on the bump values.
  32330. */
  32331. protected _enableSpecularAntiAliasing: boolean;
  32332. /**
  32333. * Default configuration related to image processing available in the PBR Material.
  32334. */
  32335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32336. /**
  32337. * Keep track of the image processing observer to allow dispose and replace.
  32338. */
  32339. private _imageProcessingObserver;
  32340. /**
  32341. * Attaches a new image processing configuration to the PBR Material.
  32342. * @param configuration
  32343. */
  32344. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32345. /**
  32346. * Stores the available render targets.
  32347. */
  32348. private _renderTargets;
  32349. /**
  32350. * Sets the global ambient color for the material used in lighting calculations.
  32351. */
  32352. private _globalAmbientColor;
  32353. /**
  32354. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32355. */
  32356. private _useLogarithmicDepth;
  32357. /**
  32358. * If set to true, no lighting calculations will be applied.
  32359. */
  32360. private _unlit;
  32361. /**
  32362. * Instantiates a new PBRMaterial instance.
  32363. *
  32364. * @param name The material name
  32365. * @param scene The scene the material will be use in.
  32366. */
  32367. constructor(name: string, scene: Scene);
  32368. /**
  32369. * Gets the name of the material class.
  32370. */
  32371. getClassName(): string;
  32372. /**
  32373. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32374. */
  32375. /**
  32376. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32377. */
  32378. useLogarithmicDepth: boolean;
  32379. /**
  32380. * Gets the current transparency mode.
  32381. */
  32382. /**
  32383. * Sets the transparency mode of the material.
  32384. */
  32385. transparencyMode: Nullable<number>;
  32386. /**
  32387. * Returns true if alpha blending should be disabled.
  32388. */
  32389. private readonly _disableAlphaBlending;
  32390. /**
  32391. * Specifies whether or not this material should be rendered in alpha blend mode.
  32392. */
  32393. needAlphaBlending(): boolean;
  32394. /**
  32395. * Specifies if the mesh will require alpha blending.
  32396. * @param mesh - BJS mesh.
  32397. */
  32398. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32399. /**
  32400. * Specifies whether or not this material should be rendered in alpha test mode.
  32401. */
  32402. needAlphaTesting(): boolean;
  32403. /**
  32404. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32405. */
  32406. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32407. /**
  32408. * Gets the texture used for the alpha test.
  32409. */
  32410. getAlphaTestTexture(): BaseTexture;
  32411. /**
  32412. * Stores the reflectivity values based on metallic roughness workflow.
  32413. */
  32414. private static _scaledReflectivity;
  32415. /**
  32416. * Specifies that the submesh is ready to be used.
  32417. * @param mesh - BJS mesh.
  32418. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32419. * @param useInstances - Specifies that instances should be used.
  32420. * @returns - boolean indicating that the submesh is ready or not.
  32421. */
  32422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32423. /**
  32424. * Specifies if the material uses metallic roughness workflow.
  32425. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32426. */
  32427. isMetallicWorkflow(): boolean;
  32428. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32429. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32430. /**
  32431. * Force shader compilation
  32432. */
  32433. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32434. clipPlane: boolean;
  32435. }>): void;
  32436. /**
  32437. * Initializes the uniform buffer layout for the shader.
  32438. */
  32439. buildUniformLayout(): void;
  32440. /**
  32441. * Unbinds the textures.
  32442. */
  32443. unbind(): void;
  32444. /**
  32445. * Binds the submesh data.
  32446. * @param world - The world matrix.
  32447. * @param mesh - The BJS mesh.
  32448. * @param subMesh - A submesh of the BJS mesh.
  32449. */
  32450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32451. /**
  32452. * Returns the animatable textures.
  32453. * @returns - Array of animatable textures.
  32454. */
  32455. getAnimatables(): IAnimatable[];
  32456. /**
  32457. * Returns the texture used for reflections.
  32458. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32459. */
  32460. private _getReflectionTexture();
  32461. /**
  32462. * Returns the texture used for refraction or null if none is used.
  32463. * @returns - Refection texture if present. If no refraction texture and refraction
  32464. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32465. */
  32466. private _getRefractionTexture();
  32467. /**
  32468. * Disposes the resources of the material.
  32469. * @param forceDisposeEffect - Forces the disposal of effects.
  32470. * @param forceDisposeTextures - Forces the disposal of all textures.
  32471. */
  32472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32473. }
  32474. }
  32475. declare module BABYLON {
  32476. /**
  32477. * The Physically based simple base material of BJS.
  32478. *
  32479. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32480. * It is used as the base class for both the specGloss and metalRough conventions.
  32481. */
  32482. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32483. /**
  32484. * Number of Simultaneous lights allowed on the material.
  32485. */
  32486. maxSimultaneousLights: number;
  32487. /**
  32488. * If sets to true, disables all the lights affecting the material.
  32489. */
  32490. disableLighting: boolean;
  32491. /**
  32492. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32493. */
  32494. environmentTexture: BaseTexture;
  32495. /**
  32496. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32497. */
  32498. invertNormalMapX: boolean;
  32499. /**
  32500. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32501. */
  32502. invertNormalMapY: boolean;
  32503. /**
  32504. * Normal map used in the model.
  32505. */
  32506. normalTexture: BaseTexture;
  32507. /**
  32508. * Emissivie color used to self-illuminate the model.
  32509. */
  32510. emissiveColor: Color3;
  32511. /**
  32512. * Emissivie texture used to self-illuminate the model.
  32513. */
  32514. emissiveTexture: BaseTexture;
  32515. /**
  32516. * Occlusion Channel Strenght.
  32517. */
  32518. occlusionStrength: number;
  32519. /**
  32520. * Occlusion Texture of the material (adding extra occlusion effects).
  32521. */
  32522. occlusionTexture: BaseTexture;
  32523. /**
  32524. * Defines the alpha limits in alpha test mode.
  32525. */
  32526. alphaCutOff: number;
  32527. /**
  32528. * Gets the current double sided mode.
  32529. */
  32530. /**
  32531. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32532. */
  32533. doubleSided: boolean;
  32534. lightmapTexture: BaseTexture;
  32535. useLightmapAsShadowmap: boolean;
  32536. /**
  32537. * Return the active textures of the material.
  32538. */
  32539. getActiveTextures(): BaseTexture[];
  32540. hasTexture(texture: BaseTexture): boolean;
  32541. /**
  32542. * Instantiates a new PBRMaterial instance.
  32543. *
  32544. * @param name The material name
  32545. * @param scene The scene the material will be use in.
  32546. */
  32547. constructor(name: string, scene: Scene);
  32548. getClassName(): string;
  32549. }
  32550. }
  32551. declare module BABYLON {
  32552. /**
  32553. * The Physically based material of BJS.
  32554. *
  32555. * This offers the main features of a standard PBR material.
  32556. * For more information, please refer to the documentation :
  32557. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32558. */
  32559. class PBRMaterial extends PBRBaseMaterial {
  32560. private static _PBRMATERIAL_OPAQUE;
  32561. /**
  32562. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32563. */
  32564. static readonly PBRMATERIAL_OPAQUE: number;
  32565. /**
  32566. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32567. */
  32568. private static _PBRMATERIAL_ALPHATEST;
  32569. /**
  32570. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32571. */
  32572. static readonly PBRMATERIAL_ALPHATEST: number;
  32573. /**
  32574. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32575. */
  32576. private static _PBRMATERIAL_ALPHABLEND;
  32577. /**
  32578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32579. */
  32580. static readonly PBRMATERIAL_ALPHABLEND: number;
  32581. /**
  32582. * 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.
  32583. * They are also discarded below the alpha cutoff threshold to improve performances.
  32584. */
  32585. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32586. /**
  32587. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32588. * They are also discarded below the alpha cutoff threshold to improve performances.
  32589. */
  32590. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32591. /**
  32592. * Intensity of the direct lights e.g. the four lights available in your scene.
  32593. * This impacts both the direct diffuse and specular highlights.
  32594. */
  32595. directIntensity: number;
  32596. /**
  32597. * Intensity of the emissive part of the material.
  32598. * This helps controlling the emissive effect without modifying the emissive color.
  32599. */
  32600. emissiveIntensity: number;
  32601. /**
  32602. * Intensity of the environment e.g. how much the environment will light the object
  32603. * either through harmonics for rough material or through the refelction for shiny ones.
  32604. */
  32605. environmentIntensity: number;
  32606. /**
  32607. * This is a special control allowing the reduction of the specular highlights coming from the
  32608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32609. */
  32610. specularIntensity: number;
  32611. /**
  32612. * Debug Control allowing disabling the bump map on this material.
  32613. */
  32614. disableBumpMap: boolean;
  32615. /**
  32616. * AKA Diffuse Texture in standard nomenclature.
  32617. */
  32618. albedoTexture: BaseTexture;
  32619. /**
  32620. * AKA Occlusion Texture in other nomenclature.
  32621. */
  32622. ambientTexture: BaseTexture;
  32623. /**
  32624. * AKA Occlusion Texture Intensity in other nomenclature.
  32625. */
  32626. ambientTextureStrength: number;
  32627. /**
  32628. * Stores the alpha values in a texture.
  32629. */
  32630. opacityTexture: BaseTexture;
  32631. /**
  32632. * Stores the reflection values in a texture.
  32633. */
  32634. reflectionTexture: Nullable<BaseTexture>;
  32635. /**
  32636. * Stores the emissive values in a texture.
  32637. */
  32638. emissiveTexture: BaseTexture;
  32639. /**
  32640. * AKA Specular texture in other nomenclature.
  32641. */
  32642. reflectivityTexture: BaseTexture;
  32643. /**
  32644. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32645. */
  32646. metallicTexture: BaseTexture;
  32647. /**
  32648. * Specifies the metallic scalar of the metallic/roughness workflow.
  32649. * Can also be used to scale the metalness values of the metallic texture.
  32650. */
  32651. metallic: number;
  32652. /**
  32653. * Specifies the roughness scalar of the metallic/roughness workflow.
  32654. * Can also be used to scale the roughness values of the metallic texture.
  32655. */
  32656. roughness: number;
  32657. /**
  32658. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32659. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32660. */
  32661. microSurfaceTexture: BaseTexture;
  32662. /**
  32663. * Stores surface normal data used to displace a mesh in a texture.
  32664. */
  32665. bumpTexture: BaseTexture;
  32666. /**
  32667. * Stores the pre-calculated light information of a mesh in a texture.
  32668. */
  32669. lightmapTexture: BaseTexture;
  32670. /**
  32671. * Stores the refracted light information in a texture.
  32672. */
  32673. refractionTexture: BaseTexture;
  32674. /**
  32675. * The color of a material in ambient lighting.
  32676. */
  32677. ambientColor: Color3;
  32678. /**
  32679. * AKA Diffuse Color in other nomenclature.
  32680. */
  32681. albedoColor: Color3;
  32682. /**
  32683. * AKA Specular Color in other nomenclature.
  32684. */
  32685. reflectivityColor: Color3;
  32686. /**
  32687. * The color reflected from the material.
  32688. */
  32689. reflectionColor: Color3;
  32690. /**
  32691. * The color emitted from the material.
  32692. */
  32693. emissiveColor: Color3;
  32694. /**
  32695. * AKA Glossiness in other nomenclature.
  32696. */
  32697. microSurface: number;
  32698. /**
  32699. * source material index of refraction (IOR)' / 'destination material IOR.
  32700. */
  32701. indexOfRefraction: number;
  32702. /**
  32703. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32704. */
  32705. invertRefractionY: boolean;
  32706. /**
  32707. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32708. * Materials half opaque for instance using refraction could benefit from this control.
  32709. */
  32710. linkRefractionWithTransparency: boolean;
  32711. useLightmapAsShadowmap: boolean;
  32712. /**
  32713. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32714. */
  32715. useAlphaFromAlbedoTexture: boolean;
  32716. /**
  32717. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32718. */
  32719. forceAlphaTest: boolean;
  32720. /**
  32721. * Defines the alpha limits in alpha test mode.
  32722. */
  32723. alphaCutOff: number;
  32724. /**
  32725. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32726. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32727. */
  32728. useSpecularOverAlpha: boolean;
  32729. /**
  32730. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32731. */
  32732. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32733. /**
  32734. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32735. */
  32736. useRoughnessFromMetallicTextureAlpha: boolean;
  32737. /**
  32738. * Specifies if the metallic texture contains the roughness information in its green channel.
  32739. */
  32740. useRoughnessFromMetallicTextureGreen: boolean;
  32741. /**
  32742. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32743. */
  32744. useMetallnessFromMetallicTextureBlue: boolean;
  32745. /**
  32746. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32747. */
  32748. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32749. /**
  32750. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32751. */
  32752. useAmbientInGrayScale: boolean;
  32753. /**
  32754. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32755. * The material will try to infer what glossiness each pixel should be.
  32756. */
  32757. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32758. /**
  32759. * BJS is using an harcoded light falloff based on a manually sets up range.
  32760. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32761. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32762. */
  32763. usePhysicalLightFalloff: boolean;
  32764. /**
  32765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32767. */
  32768. useRadianceOverAlpha: boolean;
  32769. /**
  32770. * Allows using an object space normal map (instead of tangent space).
  32771. */
  32772. useObjectSpaceNormalMap: boolean;
  32773. /**
  32774. * Allows using the bump map in parallax mode.
  32775. */
  32776. useParallax: boolean;
  32777. /**
  32778. * Allows using the bump map in parallax occlusion mode.
  32779. */
  32780. useParallaxOcclusion: boolean;
  32781. /**
  32782. * Controls the scale bias of the parallax mode.
  32783. */
  32784. parallaxScaleBias: number;
  32785. /**
  32786. * If sets to true, disables all the lights affecting the material.
  32787. */
  32788. disableLighting: boolean;
  32789. /**
  32790. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32791. */
  32792. forceIrradianceInFragment: boolean;
  32793. /**
  32794. * Number of Simultaneous lights allowed on the material.
  32795. */
  32796. maxSimultaneousLights: number;
  32797. /**
  32798. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32799. */
  32800. invertNormalMapX: boolean;
  32801. /**
  32802. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32803. */
  32804. invertNormalMapY: boolean;
  32805. /**
  32806. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32807. */
  32808. twoSidedLighting: boolean;
  32809. /**
  32810. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32811. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32812. */
  32813. useAlphaFresnel: boolean;
  32814. /**
  32815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32816. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32817. */
  32818. useLinearAlphaFresnel: boolean;
  32819. /**
  32820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32821. * And/Or occlude the blended part.
  32822. */
  32823. environmentBRDFTexture: Nullable<BaseTexture>;
  32824. /**
  32825. * Force normal to face away from face.
  32826. */
  32827. forceNormalForward: boolean;
  32828. /**
  32829. * Enables specular anti aliasing in the PBR shader.
  32830. * It will both interacts on the Geometry for analytical and IBL lighting.
  32831. * It also prefilter the roughness map based on the bump values.
  32832. */
  32833. enableSpecularAntiAliasing: boolean;
  32834. /**
  32835. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32836. * makes the reflect vector face the model (under horizon).
  32837. */
  32838. useHorizonOcclusion: boolean;
  32839. /**
  32840. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32841. * too much the area relying on ambient texture to define their ambient occlusion.
  32842. */
  32843. useRadianceOcclusion: boolean;
  32844. /**
  32845. * If set to true, no lighting calculations will be applied.
  32846. */
  32847. unlit: boolean;
  32848. /**
  32849. * Gets the image processing configuration used either in this material.
  32850. */
  32851. /**
  32852. * Sets the Default image processing configuration used either in the this material.
  32853. *
  32854. * If sets to null, the scene one is in use.
  32855. */
  32856. imageProcessingConfiguration: ImageProcessingConfiguration;
  32857. /**
  32858. * Gets wether the color curves effect is enabled.
  32859. */
  32860. /**
  32861. * Sets wether the color curves effect is enabled.
  32862. */
  32863. cameraColorCurvesEnabled: boolean;
  32864. /**
  32865. * Gets wether the color grading effect is enabled.
  32866. */
  32867. /**
  32868. * Gets wether the color grading effect is enabled.
  32869. */
  32870. cameraColorGradingEnabled: boolean;
  32871. /**
  32872. * Gets wether tonemapping is enabled or not.
  32873. */
  32874. /**
  32875. * Sets wether tonemapping is enabled or not
  32876. */
  32877. cameraToneMappingEnabled: boolean;
  32878. /**
  32879. * The camera exposure used on this material.
  32880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32881. * This corresponds to a photographic exposure.
  32882. */
  32883. /**
  32884. * The camera exposure used on this material.
  32885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32886. * This corresponds to a photographic exposure.
  32887. */
  32888. cameraExposure: number;
  32889. /**
  32890. * Gets The camera contrast used on this material.
  32891. */
  32892. /**
  32893. * Sets The camera contrast used on this material.
  32894. */
  32895. cameraContrast: number;
  32896. /**
  32897. * Gets the Color Grading 2D Lookup Texture.
  32898. */
  32899. /**
  32900. * Sets the Color Grading 2D Lookup Texture.
  32901. */
  32902. cameraColorGradingTexture: Nullable<BaseTexture>;
  32903. /**
  32904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32906. * 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;
  32907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32908. */
  32909. /**
  32910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32912. * 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;
  32913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32914. */
  32915. cameraColorCurves: Nullable<ColorCurves>;
  32916. /**
  32917. * Instantiates a new PBRMaterial instance.
  32918. *
  32919. * @param name The material name
  32920. * @param scene The scene the material will be use in.
  32921. */
  32922. constructor(name: string, scene: Scene);
  32923. /**
  32924. * Returns the name of this material class.
  32925. */
  32926. getClassName(): string;
  32927. /**
  32928. * Returns an array of the actively used textures.
  32929. * @returns - Array of BaseTextures
  32930. */
  32931. getActiveTextures(): BaseTexture[];
  32932. /**
  32933. * Checks to see if a texture is used in the material.
  32934. * @param texture - Base texture to use.
  32935. * @returns - Boolean specifying if a texture is used in the material.
  32936. */
  32937. hasTexture(texture: BaseTexture): boolean;
  32938. /**
  32939. * Makes a duplicate of the current material.
  32940. * @param name - name to use for the new material.
  32941. */
  32942. clone(name: string): PBRMaterial;
  32943. /**
  32944. * Serializes this PBR Material.
  32945. * @returns - An object with the serialized material.
  32946. */
  32947. serialize(): any;
  32948. /**
  32949. * Parses a PBR Material from a serialized object.
  32950. * @param source - Serialized object.
  32951. * @param scene - BJS scene instance.
  32952. * @param rootUrl - url for the scene object
  32953. * @returns - PBRMaterial
  32954. */
  32955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32956. }
  32957. }
  32958. declare module BABYLON {
  32959. /**
  32960. * The PBR material of BJS following the metal roughness convention.
  32961. *
  32962. * This fits to the PBR convention in the GLTF definition:
  32963. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32964. */
  32965. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32966. /**
  32967. * The base color has two different interpretations depending on the value of metalness.
  32968. * When the material is a metal, the base color is the specific measured reflectance value
  32969. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32970. * of the material.
  32971. */
  32972. baseColor: Color3;
  32973. /**
  32974. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32975. * well as opacity information in the alpha channel.
  32976. */
  32977. baseTexture: BaseTexture;
  32978. /**
  32979. * Specifies the metallic scalar value of the material.
  32980. * Can also be used to scale the metalness values of the metallic texture.
  32981. */
  32982. metallic: number;
  32983. /**
  32984. * Specifies the roughness scalar value of the material.
  32985. * Can also be used to scale the roughness values of the metallic texture.
  32986. */
  32987. roughness: number;
  32988. /**
  32989. * Texture containing both the metallic value in the B channel and the
  32990. * roughness value in the G channel to keep better precision.
  32991. */
  32992. metallicRoughnessTexture: BaseTexture;
  32993. /**
  32994. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32995. *
  32996. * @param name The material name
  32997. * @param scene The scene the material will be use in.
  32998. */
  32999. constructor(name: string, scene: Scene);
  33000. /**
  33001. * Return the currrent class name of the material.
  33002. */
  33003. getClassName(): string;
  33004. /**
  33005. * Return the active textures of the material.
  33006. */
  33007. getActiveTextures(): BaseTexture[];
  33008. /**
  33009. * Checks to see if a texture is used in the material.
  33010. * @param texture - Base texture to use.
  33011. * @returns - Boolean specifying if a texture is used in the material.
  33012. */
  33013. hasTexture(texture: BaseTexture): boolean;
  33014. /**
  33015. * Makes a duplicate of the current material.
  33016. * @param name - name to use for the new material.
  33017. */
  33018. clone(name: string): PBRMetallicRoughnessMaterial;
  33019. /**
  33020. * Serialize the material to a parsable JSON object.
  33021. */
  33022. serialize(): any;
  33023. /**
  33024. * Parses a JSON object correponding to the serialize function.
  33025. */
  33026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  33027. }
  33028. }
  33029. declare module BABYLON {
  33030. /**
  33031. * The PBR material of BJS following the specular glossiness convention.
  33032. *
  33033. * This fits to the PBR convention in the GLTF definition:
  33034. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  33035. */
  33036. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  33037. /**
  33038. * Specifies the diffuse color of the material.
  33039. */
  33040. diffuseColor: Color3;
  33041. /**
  33042. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  33043. * channel.
  33044. */
  33045. diffuseTexture: BaseTexture;
  33046. /**
  33047. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  33048. */
  33049. specularColor: Color3;
  33050. /**
  33051. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  33052. */
  33053. glossiness: number;
  33054. /**
  33055. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  33056. */
  33057. specularGlossinessTexture: BaseTexture;
  33058. /**
  33059. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  33060. *
  33061. * @param name The material name
  33062. * @param scene The scene the material will be use in.
  33063. */
  33064. constructor(name: string, scene: Scene);
  33065. /**
  33066. * Return the currrent class name of the material.
  33067. */
  33068. getClassName(): string;
  33069. /**
  33070. * Return the active textures of the material.
  33071. */
  33072. getActiveTextures(): BaseTexture[];
  33073. /**
  33074. * Checks to see if a texture is used in the material.
  33075. * @param texture - Base texture to use.
  33076. * @returns - Boolean specifying if a texture is used in the material.
  33077. */
  33078. hasTexture(texture: BaseTexture): boolean;
  33079. /**
  33080. * Makes a duplicate of the current material.
  33081. * @param name - name to use for the new material.
  33082. */
  33083. clone(name: string): PBRSpecularGlossinessMaterial;
  33084. /**
  33085. * Serialize the material to a parsable JSON object.
  33086. */
  33087. serialize(): any;
  33088. /**
  33089. * Parses a JSON object correponding to the serialize function.
  33090. */
  33091. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  33092. }
  33093. }
  33094. declare module BABYLON {
  33095. /**
  33096. * Particle emitter emitting particles from the inside of a box.
  33097. * It emits the particles randomly between 2 given directions.
  33098. */
  33099. class BoxParticleEmitter implements IParticleEmitterType {
  33100. /**
  33101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33102. */
  33103. direction1: Vector3;
  33104. /**
  33105. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33106. */
  33107. direction2: Vector3;
  33108. /**
  33109. * 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.
  33110. */
  33111. minEmitBox: Vector3;
  33112. /**
  33113. * 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.
  33114. */
  33115. maxEmitBox: Vector3;
  33116. /**
  33117. * Creates a new instance BoxParticleEmitter
  33118. */
  33119. constructor();
  33120. /**
  33121. * Called by the particle System when the direction is computed for the created particle.
  33122. * @param emitPower is the power of the particle (speed)
  33123. * @param worldMatrix is the world matrix of the particle system
  33124. * @param directionToUpdate is the direction vector to update with the result
  33125. * @param particle is the particle we are computed the direction for
  33126. */
  33127. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33128. /**
  33129. * Called by the particle System when the position is computed for the created particle.
  33130. * @param worldMatrix is the world matrix of the particle system
  33131. * @param positionToUpdate is the position vector to update with the result
  33132. * @param particle is the particle we are computed the position for
  33133. */
  33134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33135. /**
  33136. * Clones the current emitter and returns a copy of it
  33137. * @returns the new emitter
  33138. */
  33139. clone(): BoxParticleEmitter;
  33140. /**
  33141. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33142. * @param effect defines the update shader
  33143. */
  33144. applyToShader(effect: Effect): void;
  33145. /**
  33146. * Returns a string to use to update the GPU particles update shader
  33147. * @returns a string containng the defines string
  33148. */
  33149. getEffectDefines(): string;
  33150. /**
  33151. * Returns the string "BoxEmitter"
  33152. * @returns a string containing the class name
  33153. */
  33154. getClassName(): string;
  33155. /**
  33156. * Serializes the particle system to a JSON object.
  33157. * @returns the JSON object
  33158. */
  33159. serialize(): any;
  33160. /**
  33161. * Parse properties from a JSON object
  33162. * @param serializationObject defines the JSON object
  33163. */
  33164. parse(serializationObject: any): void;
  33165. }
  33166. }
  33167. declare module BABYLON {
  33168. /**
  33169. * Particle emitter emitting particles from the inside of a cone.
  33170. * It emits the particles alongside the cone volume from the base to the particle.
  33171. * The emission direction might be randomized.
  33172. */
  33173. class ConeParticleEmitter implements IParticleEmitterType {
  33174. /**
  33175. * The radius of the emission cone.
  33176. */
  33177. angle: number;
  33178. /**
  33179. * The cone base angle.
  33180. */
  33181. directionRandomizer: number;
  33182. private _radius;
  33183. private _height;
  33184. /**
  33185. * Gets the radius of the emission cone.
  33186. */
  33187. /**
  33188. * Sets the radius of the emission cone.
  33189. */
  33190. radius: number;
  33191. /**
  33192. * Creates a new instance ConeParticleEmitter
  33193. * @param radius the radius of the emission cone (1 by default)
  33194. * @param angles the cone base angle (PI by default)
  33195. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33196. */
  33197. constructor(radius?: number,
  33198. /**
  33199. * The radius of the emission cone.
  33200. */
  33201. angle?: number,
  33202. /**
  33203. * The cone base angle.
  33204. */
  33205. directionRandomizer?: number);
  33206. /**
  33207. * Called by the particle System when the direction is computed for the created particle.
  33208. * @param emitPower is the power of the particle (speed)
  33209. * @param worldMatrix is the world matrix of the particle system
  33210. * @param directionToUpdate is the direction vector to update with the result
  33211. * @param particle is the particle we are computed the direction for
  33212. */
  33213. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33214. /**
  33215. * Called by the particle System when the position is computed for the created particle.
  33216. * @param worldMatrix is the world matrix of the particle system
  33217. * @param positionToUpdate is the position vector to update with the result
  33218. * @param particle is the particle we are computed the position for
  33219. */
  33220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33221. /**
  33222. * Clones the current emitter and returns a copy of it
  33223. * @returns the new emitter
  33224. */
  33225. clone(): ConeParticleEmitter;
  33226. /**
  33227. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33228. * @param effect defines the update shader
  33229. */
  33230. applyToShader(effect: Effect): void;
  33231. /**
  33232. * Returns a string to use to update the GPU particles update shader
  33233. * @returns a string containng the defines string
  33234. */
  33235. getEffectDefines(): string;
  33236. /**
  33237. * Returns the string "BoxEmitter"
  33238. * @returns a string containing the class name
  33239. */
  33240. getClassName(): string;
  33241. /**
  33242. * Serializes the particle system to a JSON object.
  33243. * @returns the JSON object
  33244. */
  33245. serialize(): any;
  33246. /**
  33247. * Parse properties from a JSON object
  33248. * @param serializationObject defines the JSON object
  33249. */
  33250. parse(serializationObject: any): void;
  33251. }
  33252. }
  33253. declare module BABYLON {
  33254. /**
  33255. * Particle emitter represents a volume emitting particles.
  33256. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33257. */
  33258. interface IParticleEmitterType {
  33259. /**
  33260. * Called by the particle System when the direction is computed for the created particle.
  33261. * @param emitPower is the power of the particle (speed)
  33262. * @param worldMatrix is the world matrix of the particle system
  33263. * @param directionToUpdate is the direction vector to update with the result
  33264. * @param particle is the particle we are computed the direction for
  33265. */
  33266. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33267. /**
  33268. * Called by the particle System when the position is computed for the created particle.
  33269. * @param worldMatrix is the world matrix of the particle system
  33270. * @param positionToUpdate is the position vector to update with the result
  33271. * @param particle is the particle we are computed the position for
  33272. */
  33273. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33274. /**
  33275. * Clones the current emitter and returns a copy of it
  33276. * @returns the new emitter
  33277. */
  33278. clone(): IParticleEmitterType;
  33279. /**
  33280. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33281. * @param effect defines the update shader
  33282. */
  33283. applyToShader(effect: Effect): void;
  33284. /**
  33285. * Returns a string to use to update the GPU particles update shader
  33286. * @returns the effect defines string
  33287. */
  33288. getEffectDefines(): string;
  33289. /**
  33290. * Returns a string representing the class name
  33291. * @returns a string containing the class name
  33292. */
  33293. getClassName(): string;
  33294. /**
  33295. * Serializes the particle system to a JSON object.
  33296. * @returns the JSON object
  33297. */
  33298. serialize(): any;
  33299. /**
  33300. * Parse properties from a JSON object
  33301. * @param serializationObject defines the JSON object
  33302. */
  33303. parse(serializationObject: any): void;
  33304. }
  33305. }
  33306. declare module BABYLON {
  33307. /**
  33308. * Particle emitter emitting particles from the inside of a sphere.
  33309. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33310. */
  33311. class SphereParticleEmitter implements IParticleEmitterType {
  33312. /**
  33313. * The radius of the emission sphere.
  33314. */
  33315. radius: number;
  33316. /**
  33317. * How much to randomize the particle direction [0-1].
  33318. */
  33319. directionRandomizer: number;
  33320. /**
  33321. * Creates a new instance SphereParticleEmitter
  33322. * @param radius the radius of the emission sphere (1 by default)
  33323. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33324. */
  33325. constructor(
  33326. /**
  33327. * The radius of the emission sphere.
  33328. */
  33329. radius?: number,
  33330. /**
  33331. * How much to randomize the particle direction [0-1].
  33332. */
  33333. directionRandomizer?: number);
  33334. /**
  33335. * Called by the particle System when the direction is computed for the created particle.
  33336. * @param emitPower is the power of the particle (speed)
  33337. * @param worldMatrix is the world matrix of the particle system
  33338. * @param directionToUpdate is the direction vector to update with the result
  33339. * @param particle is the particle we are computed the direction for
  33340. */
  33341. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33342. /**
  33343. * Called by the particle System when the position is computed for the created particle.
  33344. * @param worldMatrix is the world matrix of the particle system
  33345. * @param positionToUpdate is the position vector to update with the result
  33346. * @param particle is the particle we are computed the position for
  33347. */
  33348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33349. /**
  33350. * Clones the current emitter and returns a copy of it
  33351. * @returns the new emitter
  33352. */
  33353. clone(): SphereParticleEmitter;
  33354. /**
  33355. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33356. * @param effect defines the update shader
  33357. */
  33358. applyToShader(effect: Effect): void;
  33359. /**
  33360. * Returns a string to use to update the GPU particles update shader
  33361. * @returns a string containng the defines string
  33362. */
  33363. getEffectDefines(): string;
  33364. /**
  33365. * Returns the string "SphereParticleEmitter"
  33366. * @returns a string containing the class name
  33367. */
  33368. getClassName(): string;
  33369. /**
  33370. * Serializes the particle system to a JSON object.
  33371. * @returns the JSON object
  33372. */
  33373. serialize(): any;
  33374. /**
  33375. * Parse properties from a JSON object
  33376. * @param serializationObject defines the JSON object
  33377. */
  33378. parse(serializationObject: any): void;
  33379. }
  33380. /**
  33381. * Particle emitter emitting particles from the inside of a sphere.
  33382. * It emits the particles randomly between two vectors.
  33383. */
  33384. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  33385. /**
  33386. * The min limit of the emission direction.
  33387. */
  33388. direction1: Vector3;
  33389. /**
  33390. * The max limit of the emission direction.
  33391. */
  33392. direction2: Vector3;
  33393. /**
  33394. * Creates a new instance SphereDirectedParticleEmitter
  33395. * @param radius the radius of the emission sphere (1 by default)
  33396. * @param direction1 the min limit of the emission direction (up vector by default)
  33397. * @param direction2 the max limit of the emission direction (up vector by default)
  33398. */
  33399. constructor(radius?: number,
  33400. /**
  33401. * The min limit of the emission direction.
  33402. */
  33403. direction1?: Vector3,
  33404. /**
  33405. * The max limit of the emission direction.
  33406. */
  33407. direction2?: Vector3);
  33408. /**
  33409. * Called by the particle System when the direction is computed for the created particle.
  33410. * @param emitPower is the power of the particle (speed)
  33411. * @param worldMatrix is the world matrix of the particle system
  33412. * @param directionToUpdate is the direction vector to update with the result
  33413. * @param particle is the particle we are computed the direction for
  33414. */
  33415. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33416. /**
  33417. * Clones the current emitter and returns a copy of it
  33418. * @returns the new emitter
  33419. */
  33420. clone(): SphereDirectedParticleEmitter;
  33421. /**
  33422. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33423. * @param effect defines the update shader
  33424. */
  33425. applyToShader(effect: Effect): void;
  33426. /**
  33427. * Returns a string to use to update the GPU particles update shader
  33428. * @returns a string containng the defines string
  33429. */
  33430. getEffectDefines(): string;
  33431. /**
  33432. * Returns the string "SphereDirectedParticleEmitter"
  33433. * @returns a string containing the class name
  33434. */
  33435. getClassName(): string;
  33436. /**
  33437. * Serializes the particle system to a JSON object.
  33438. * @returns the JSON object
  33439. */
  33440. serialize(): any;
  33441. /**
  33442. * Parse properties from a JSON object
  33443. * @param serializationObject defines the JSON object
  33444. */
  33445. parse(serializationObject: any): void;
  33446. }
  33447. }
  33448. declare var DracoDecoderModule: any;
  33449. declare var WebAssembly: any;
  33450. declare module BABYLON {
  33451. /**
  33452. * Configuration for Draco compression
  33453. */
  33454. interface IDracoCompressionConfiguration {
  33455. /**
  33456. * Configuration for the decoder.
  33457. */
  33458. decoder?: {
  33459. /**
  33460. * The url to the WebAssembly module.
  33461. */
  33462. wasmUrl?: string;
  33463. /**
  33464. * The url to the WebAssembly binary.
  33465. */
  33466. wasmBinaryUrl?: string;
  33467. /**
  33468. * The url to the fallback JavaScript module.
  33469. */
  33470. fallbackUrl?: string;
  33471. };
  33472. }
  33473. /**
  33474. * Draco compression (https://google.github.io/draco/)
  33475. */
  33476. class DracoCompression implements IDisposable {
  33477. private static _DecoderModulePromise;
  33478. /**
  33479. * The configuration.
  33480. */
  33481. static Configuration: IDracoCompressionConfiguration;
  33482. /**
  33483. * Returns true if the decoder is available.
  33484. */
  33485. static readonly DecoderAvailable: boolean;
  33486. /**
  33487. * Constructor
  33488. */
  33489. constructor();
  33490. /**
  33491. * Stop all async operations and release resources.
  33492. */
  33493. dispose(): void;
  33494. /**
  33495. * Decode Draco compressed mesh data to vertex data.
  33496. * @param data The array buffer view for the Draco compression data
  33497. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33498. * @returns A promise that resolves with the decoded vertex data
  33499. */
  33500. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33501. [kind: string]: number;
  33502. }): Promise<VertexData>;
  33503. private static _GetDecoderModule();
  33504. private static _LoadScriptAsync(url);
  33505. private static _LoadFileAsync(url);
  33506. }
  33507. }
  33508. declare module BABYLON {
  33509. class CannonJSPlugin implements IPhysicsEnginePlugin {
  33510. private _useDeltaForWorldStep;
  33511. world: any;
  33512. name: string;
  33513. private _physicsMaterials;
  33514. private _fixedTimeStep;
  33515. BJSCANNON: any;
  33516. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  33517. setGravity(gravity: Vector3): void;
  33518. setTimeStep(timeStep: number): void;
  33519. getTimeStep(): number;
  33520. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33522. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33523. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33524. private _processChildMeshes(mainImpostor);
  33525. removePhysicsBody(impostor: PhysicsImpostor): void;
  33526. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  33527. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  33528. private _addMaterial(name, friction, restitution);
  33529. private _checkWithEpsilon(value);
  33530. private _createShape(impostor);
  33531. private _createHeightmap(object, pointDepth?);
  33532. private _minus90X;
  33533. private _plus90X;
  33534. private _tmpPosition;
  33535. private _tmpDeltaPosition;
  33536. private _tmpUnityRotation;
  33537. private _updatePhysicsBodyTransformation(impostor);
  33538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33539. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33540. isSupported(): boolean;
  33541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33546. getBodyMass(impostor: PhysicsImpostor): number;
  33547. getBodyFriction(impostor: PhysicsImpostor): number;
  33548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33549. getBodyRestitution(impostor: PhysicsImpostor): number;
  33550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33551. sleepBody(impostor: PhysicsImpostor): void;
  33552. wakeUpBody(impostor: PhysicsImpostor): void;
  33553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33554. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  33555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  33556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33557. getRadius(impostor: PhysicsImpostor): number;
  33558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33559. dispose(): void;
  33560. private _extendNamespace();
  33561. }
  33562. }
  33563. declare module BABYLON {
  33564. class OimoJSPlugin implements IPhysicsEnginePlugin {
  33565. world: any;
  33566. name: string;
  33567. BJSOIMO: any;
  33568. constructor(iterations?: number);
  33569. setGravity(gravity: Vector3): void;
  33570. setTimeStep(timeStep: number): void;
  33571. getTimeStep(): number;
  33572. private _tmpImpostorsArray;
  33573. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33574. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33575. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33576. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33577. private _tmpPositionVector;
  33578. removePhysicsBody(impostor: PhysicsImpostor): void;
  33579. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  33580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  33581. isSupported(): boolean;
  33582. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33583. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33589. getBodyMass(impostor: PhysicsImpostor): number;
  33590. getBodyFriction(impostor: PhysicsImpostor): number;
  33591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33592. getBodyRestitution(impostor: PhysicsImpostor): number;
  33593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33594. sleepBody(impostor: PhysicsImpostor): void;
  33595. wakeUpBody(impostor: PhysicsImpostor): void;
  33596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33597. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33600. getRadius(impostor: PhysicsImpostor): number;
  33601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33602. dispose(): void;
  33603. }
  33604. }
  33605. declare module BABYLON {
  33606. /**
  33607. * This represents a set of one or more post processes in Babylon.
  33608. * A post process can be used to apply a shader to a texture after it is rendered.
  33609. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  33610. */
  33611. class PostProcessRenderEffect {
  33612. private _postProcesses;
  33613. private _getPostProcesses;
  33614. private _singleInstance;
  33615. private _cameras;
  33616. private _indicesForCamera;
  33617. /**
  33618. * Name of the effect
  33619. */
  33620. /**
  33621. * Instantiates a post process render effect.
  33622. * A post process can be used to apply a shader to a texture after it is rendered.
  33623. * @param engine The engine the effect is tied to
  33624. * @param name The name of the effect
  33625. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  33626. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  33627. */
  33628. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  33629. /**
  33630. * Checks if all the post processes in the effect are supported.
  33631. */
  33632. readonly isSupported: boolean;
  33633. /**
  33634. * Updates the current state of the effect
  33635. */
  33636. /**
  33637. * Attaches the effect on cameras
  33638. * @param cameras The camera to attach to.
  33639. */
  33640. /**
  33641. * Attaches the effect on cameras
  33642. * @param cameras The camera to attach to.
  33643. */
  33644. /**
  33645. * Detatches the effect on cameras
  33646. * @param cameras The camera to detatch from.
  33647. */
  33648. /**
  33649. * Detatches the effect on cameras
  33650. * @param cameras The camera to detatch from.
  33651. */
  33652. /**
  33653. * Enables the effect on given cameras
  33654. * @param cameras The camera to enable.
  33655. */
  33656. /**
  33657. * Enables the effect on given cameras
  33658. * @param cameras The camera to enable.
  33659. */
  33660. /**
  33661. * Disables the effect on the given cameras
  33662. * @param cameras The camera to disable.
  33663. */
  33664. /**
  33665. * Disables the effect on the given cameras
  33666. * @param cameras The camera to disable.
  33667. */
  33668. /**
  33669. * Gets a list of the post processes contained in the effect.
  33670. * @param camera The camera to get the post processes on.
  33671. * @returns The list of the post processes in the effect.
  33672. */
  33673. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  33674. }
  33675. }
  33676. declare module BABYLON {
  33677. class PostProcessRenderPipeline {
  33678. private engine;
  33679. private _renderEffects;
  33680. private _renderEffectsForIsolatedPass;
  33681. protected _cameras: Camera[];
  33682. constructor(engine: Engine, name: string);
  33683. getClassName(): string;
  33684. readonly isSupported: boolean;
  33685. addEffect(renderEffect: PostProcessRenderEffect): void;
  33686. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  33687. dispose(): void;
  33688. }
  33689. }
  33690. declare module BABYLON {
  33691. class PostProcessRenderPipelineManager {
  33692. private _renderPipelines;
  33693. constructor();
  33694. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  33695. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  33696. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  33697. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  33698. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  33699. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  33700. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  33701. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  33702. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  33703. update(): void;
  33704. dispose(): void;
  33705. }
  33706. }
  33707. declare module BABYLON {
  33708. /**
  33709. * Helper class dealing with the extraction of spherical polynomial dataArray
  33710. * from a cube map.
  33711. */
  33712. class CubeMapToSphericalPolynomialTools {
  33713. private static FileFaces;
  33714. /**
  33715. * Converts a texture to the according Spherical Polynomial data.
  33716. * This extracts the first 3 orders only as they are the only one used in the lighting.
  33717. *
  33718. * @param texture The texture to extract the information from.
  33719. * @return The Spherical Polynomial data.
  33720. */
  33721. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  33722. /**
  33723. * Converts a cubemap to the according Spherical Polynomial data.
  33724. * This extracts the first 3 orders only as they are the only one used in the lighting.
  33725. *
  33726. * @param cubeInfo The Cube map to extract the information from.
  33727. * @return The Spherical Polynomial data.
  33728. */
  33729. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  33730. }
  33731. }
  33732. declare module BABYLON {
  33733. /**
  33734. * Header information of HDR texture files.
  33735. */
  33736. interface HDRInfo {
  33737. /**
  33738. * The height of the texture in pixels.
  33739. */
  33740. height: number;
  33741. /**
  33742. * The width of the texture in pixels.
  33743. */
  33744. width: number;
  33745. /**
  33746. * The index of the beginning of the data in the binary file.
  33747. */
  33748. dataPosition: number;
  33749. }
  33750. /**
  33751. * This groups tools to convert HDR texture to native colors array.
  33752. */
  33753. class HDRTools {
  33754. private static Ldexp(mantissa, exponent);
  33755. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  33756. private static readStringLine(uint8array, startIndex);
  33757. /**
  33758. * Reads header information from an RGBE texture stored in a native array.
  33759. * More information on this format are available here:
  33760. * https://en.wikipedia.org/wiki/RGBE_image_format
  33761. *
  33762. * @param uint8array The binary file stored in native array.
  33763. * @return The header information.
  33764. */
  33765. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  33766. /**
  33767. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  33768. * This RGBE texture needs to store the information as a panorama.
  33769. *
  33770. * More information on this format are available here:
  33771. * https://en.wikipedia.org/wiki/RGBE_image_format
  33772. *
  33773. * @param buffer The binary file stored in an array buffer.
  33774. * @param size The expected size of the extracted cubemap.
  33775. * @return The Cube Map information.
  33776. */
  33777. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  33778. /**
  33779. * Returns the pixels data extracted from an RGBE texture.
  33780. * This pixels will be stored left to right up to down in the R G B order in one array.
  33781. *
  33782. * More information on this format are available here:
  33783. * https://en.wikipedia.org/wiki/RGBE_image_format
  33784. *
  33785. * @param uint8array The binary file stored in an array buffer.
  33786. * @param hdrInfo The header information of the file.
  33787. * @return The pixels data in RGB right to left up to down order.
  33788. */
  33789. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  33790. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  33791. }
  33792. }
  33793. declare module BABYLON {
  33794. /**
  33795. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  33796. */
  33797. interface CubeMapInfo {
  33798. /**
  33799. * The pixel array for the front face.
  33800. * This is stored in format, left to right, up to down format.
  33801. */
  33802. front: Nullable<ArrayBufferView>;
  33803. /**
  33804. * The pixel array for the back face.
  33805. * This is stored in format, left to right, up to down format.
  33806. */
  33807. back: Nullable<ArrayBufferView>;
  33808. /**
  33809. * The pixel array for the left face.
  33810. * This is stored in format, left to right, up to down format.
  33811. */
  33812. left: Nullable<ArrayBufferView>;
  33813. /**
  33814. * The pixel array for the right face.
  33815. * This is stored in format, left to right, up to down format.
  33816. */
  33817. right: Nullable<ArrayBufferView>;
  33818. /**
  33819. * The pixel array for the up face.
  33820. * This is stored in format, left to right, up to down format.
  33821. */
  33822. up: Nullable<ArrayBufferView>;
  33823. /**
  33824. * The pixel array for the down face.
  33825. * This is stored in format, left to right, up to down format.
  33826. */
  33827. down: Nullable<ArrayBufferView>;
  33828. /**
  33829. * The size of the cubemap stored.
  33830. *
  33831. * Each faces will be size * size pixels.
  33832. */
  33833. size: number;
  33834. /**
  33835. * The format of the texture.
  33836. *
  33837. * RGBA, RGB.
  33838. */
  33839. format: number;
  33840. /**
  33841. * The type of the texture data.
  33842. *
  33843. * UNSIGNED_INT, FLOAT.
  33844. */
  33845. type: number;
  33846. /**
  33847. * Specifies whether the texture is in gamma space.
  33848. */
  33849. gammaSpace: boolean;
  33850. }
  33851. /**
  33852. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  33853. */
  33854. class PanoramaToCubeMapTools {
  33855. private static FACE_FRONT;
  33856. private static FACE_BACK;
  33857. private static FACE_RIGHT;
  33858. private static FACE_LEFT;
  33859. private static FACE_DOWN;
  33860. private static FACE_UP;
  33861. /**
  33862. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  33863. *
  33864. * @param float32Array The source data.
  33865. * @param inputWidth The width of the input panorama.
  33866. * @param inputhHeight The height of the input panorama.
  33867. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  33868. * @return The cubemap data
  33869. */
  33870. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  33871. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  33872. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  33873. }
  33874. }
  33875. declare module BABYLON {
  33876. class CustomProceduralTexture extends ProceduralTexture {
  33877. private _animate;
  33878. private _time;
  33879. private _config;
  33880. private _texturePath;
  33881. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  33882. private loadJson(jsonUrl);
  33883. isReady(): boolean;
  33884. render(useCameraPostProcess?: boolean): void;
  33885. updateTextures(): void;
  33886. updateShaderUniforms(): void;
  33887. animate: boolean;
  33888. }
  33889. }
  33890. declare module BABYLON {
  33891. class ProceduralTexture extends Texture {
  33892. isCube: boolean;
  33893. private _size;
  33894. isEnabled: boolean;
  33895. private _currentRefreshId;
  33896. private _refreshRate;
  33897. onGenerated: () => void;
  33898. private _vertexBuffers;
  33899. private _indexBuffer;
  33900. private _effect;
  33901. private _uniforms;
  33902. private _samplers;
  33903. private _fragment;
  33904. ;
  33905. private _floats;
  33906. private _floatsArrays;
  33907. private _colors3;
  33908. private _colors4;
  33909. private _vectors2;
  33910. private _vectors3;
  33911. private _matrices;
  33912. private _fallbackTexture;
  33913. private _fallbackTextureUsed;
  33914. private _engine;
  33915. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  33916. private _createIndexBuffer();
  33917. reset(): void;
  33918. isReady(): boolean;
  33919. resetRefreshCounter(): void;
  33920. setFragment(fragment: any): void;
  33921. refreshRate: number;
  33922. getRenderSize(): number;
  33923. resize(size: number, generateMipMaps: boolean): void;
  33924. private _checkUniform(uniformName);
  33925. setTexture(name: string, texture: Texture): ProceduralTexture;
  33926. setFloat(name: string, value: number): ProceduralTexture;
  33927. setFloats(name: string, value: number[]): ProceduralTexture;
  33928. setColor3(name: string, value: Color3): ProceduralTexture;
  33929. setColor4(name: string, value: Color4): ProceduralTexture;
  33930. setVector2(name: string, value: Vector2): ProceduralTexture;
  33931. setVector3(name: string, value: Vector3): ProceduralTexture;
  33932. setMatrix(name: string, value: Matrix): ProceduralTexture;
  33933. render(useCameraPostProcess?: boolean): void;
  33934. clone(): ProceduralTexture;
  33935. dispose(): void;
  33936. }
  33937. }
  33938. declare module BABYLON {
  33939. /**
  33940. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  33941. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  33942. */
  33943. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  33944. private _scene;
  33945. private _originalCameras;
  33946. /**
  33947. * ID of the sharpen post process,
  33948. */
  33949. private readonly SharpenPostProcessId;
  33950. /**
  33951. * ID of the image processing post process;
  33952. */
  33953. readonly ImageProcessingPostProcessId: string;
  33954. /**
  33955. * ID of the Fast Approximate Anti-Aliasing post process;
  33956. */
  33957. readonly FxaaPostProcessId: string;
  33958. /**
  33959. * ID of the chromatic aberration post process,
  33960. */
  33961. private readonly ChromaticAberrationPostProcessId;
  33962. /**
  33963. * ID of the grain post process
  33964. */
  33965. private readonly GrainPostProcessId;
  33966. /**
  33967. * Sharpen post process which will apply a sharpen convolution to enhance edges
  33968. */
  33969. sharpen: SharpenPostProcess;
  33970. private _sharpenEffect;
  33971. private bloom;
  33972. /**
  33973. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  33974. */
  33975. depthOfField: DepthOfFieldEffect;
  33976. /**
  33977. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  33978. */
  33979. fxaa: FxaaPostProcess;
  33980. /**
  33981. * Image post processing pass used to perform operations such as tone mapping or color grading.
  33982. */
  33983. imageProcessing: ImageProcessingPostProcess;
  33984. /**
  33985. * Chromatic aberration post process which will shift rgb colors in the image
  33986. */
  33987. chromaticAberration: ChromaticAberrationPostProcess;
  33988. private _chromaticAberrationEffect;
  33989. /**
  33990. * Grain post process which add noise to the image
  33991. */
  33992. grain: GrainPostProcess;
  33993. private _grainEffect;
  33994. /**
  33995. * Animations which can be used to tweak settings over a period of time
  33996. */
  33997. animations: Animation[];
  33998. private _imageProcessingConfigurationObserver;
  33999. private _sharpenEnabled;
  34000. private _bloomEnabled;
  34001. private _depthOfFieldEnabled;
  34002. private _depthOfFieldBlurLevel;
  34003. private _fxaaEnabled;
  34004. private _imageProcessingEnabled;
  34005. private _defaultPipelineTextureType;
  34006. private _bloomScale;
  34007. private _chromaticAberrationEnabled;
  34008. private _grainEnabled;
  34009. private _buildAllowed;
  34010. /**
  34011. * Enable or disable the sharpen process from the pipeline
  34012. */
  34013. sharpenEnabled: boolean;
  34014. private _resizeObserver;
  34015. private _hardwareScaleLevel;
  34016. private _bloomKernel;
  34017. /**
  34018. * Specifies the size of the bloom blur kernel, relative to the final output size
  34019. */
  34020. bloomKernel: number;
  34021. /**
  34022. * Specifies the weight of the bloom in the final rendering
  34023. */
  34024. private _bloomWeight;
  34025. /**
  34026. * Specifies the luma threshold for the area that will be blurred by the bloom
  34027. */
  34028. private _bloomThreshold;
  34029. private _hdr;
  34030. /**
  34031. * The strength of the bloom.
  34032. */
  34033. bloomWeight: number;
  34034. /**
  34035. * The strength of the bloom.
  34036. */
  34037. bloomThreshold: number;
  34038. /**
  34039. * The scale of the bloom, lower value will provide better performance.
  34040. */
  34041. bloomScale: number;
  34042. /**
  34043. * Enable or disable the bloom from the pipeline
  34044. */
  34045. bloomEnabled: boolean;
  34046. private _rebuildBloom();
  34047. /**
  34048. * If the depth of field is enabled.
  34049. */
  34050. depthOfFieldEnabled: boolean;
  34051. /**
  34052. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34053. */
  34054. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34055. /**
  34056. * If the anti aliasing is enabled.
  34057. */
  34058. fxaaEnabled: boolean;
  34059. private _samples;
  34060. /**
  34061. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34062. */
  34063. samples: number;
  34064. /**
  34065. * If image processing is enabled.
  34066. */
  34067. imageProcessingEnabled: boolean;
  34068. /**
  34069. * Enable or disable the chromaticAberration process from the pipeline
  34070. */
  34071. chromaticAberrationEnabled: boolean;
  34072. /**
  34073. * Enable or disable the grain process from the pipeline
  34074. */
  34075. grainEnabled: boolean;
  34076. /**
  34077. * @constructor
  34078. * @param {string} name - The rendering pipeline name
  34079. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34080. * @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)
  34081. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34082. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  34083. */
  34084. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34085. /**
  34086. * Force the compilation of the entire pipeline.
  34087. */
  34088. prepare(): void;
  34089. private _hasCleared;
  34090. private _prevPostProcess;
  34091. private _prevPrevPostProcess;
  34092. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34093. private _buildPipeline();
  34094. private _disposePostProcesses(disposeNonRecreated?);
  34095. /**
  34096. * Dispose of the pipeline and stop all post processes
  34097. */
  34098. dispose(): void;
  34099. /**
  34100. * Serialize the rendering pipeline (Used when exporting)
  34101. * @returns the serialized object
  34102. */
  34103. serialize(): any;
  34104. /**
  34105. * Parse the serialized pipeline
  34106. * @param source Source pipeline.
  34107. * @param scene The scene to load the pipeline to.
  34108. * @param rootUrl The URL of the serialized pipeline.
  34109. * @returns An instantiated pipeline from the serialized object.
  34110. */
  34111. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34112. }
  34113. }
  34114. declare module BABYLON {
  34115. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34116. /**
  34117. * The chromatic aberration PostProcess id in the pipeline
  34118. */
  34119. LensChromaticAberrationEffect: string;
  34120. /**
  34121. * The highlights enhancing PostProcess id in the pipeline
  34122. */
  34123. HighlightsEnhancingEffect: string;
  34124. /**
  34125. * The depth-of-field PostProcess id in the pipeline
  34126. */
  34127. LensDepthOfFieldEffect: string;
  34128. private _scene;
  34129. private _depthTexture;
  34130. private _grainTexture;
  34131. private _chromaticAberrationPostProcess;
  34132. private _highlightsPostProcess;
  34133. private _depthOfFieldPostProcess;
  34134. private _edgeBlur;
  34135. private _grainAmount;
  34136. private _chromaticAberration;
  34137. private _distortion;
  34138. private _highlightsGain;
  34139. private _highlightsThreshold;
  34140. private _dofDistance;
  34141. private _dofAperture;
  34142. private _dofDarken;
  34143. private _dofPentagon;
  34144. private _blurNoise;
  34145. /**
  34146. * @constructor
  34147. *
  34148. * Effect parameters are as follow:
  34149. * {
  34150. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34151. * edge_blur: number; // from 0 to x (1 for realism)
  34152. * distortion: number; // from 0 to x (1 for realism)
  34153. * grain_amount: number; // from 0 to 1
  34154. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34155. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34156. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34157. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34158. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34159. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34160. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34161. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34162. * }
  34163. * Note: if an effect parameter is unset, effect is disabled
  34164. *
  34165. * @param {string} name - The rendering pipeline name
  34166. * @param {object} parameters - An object containing all parameters (see above)
  34167. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34168. * @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)
  34169. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34170. */
  34171. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34172. setEdgeBlur(amount: number): void;
  34173. disableEdgeBlur(): void;
  34174. setGrainAmount(amount: number): void;
  34175. disableGrain(): void;
  34176. setChromaticAberration(amount: number): void;
  34177. disableChromaticAberration(): void;
  34178. setEdgeDistortion(amount: number): void;
  34179. disableEdgeDistortion(): void;
  34180. setFocusDistance(amount: number): void;
  34181. disableDepthOfField(): void;
  34182. setAperture(amount: number): void;
  34183. setDarkenOutOfFocus(amount: number): void;
  34184. enablePentagonBokeh(): void;
  34185. disablePentagonBokeh(): void;
  34186. enableNoiseBlur(): void;
  34187. disableNoiseBlur(): void;
  34188. setHighlightsGain(amount: number): void;
  34189. setHighlightsThreshold(amount: number): void;
  34190. disableHighlights(): void;
  34191. /**
  34192. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34193. */
  34194. dispose(disableDepthRender?: boolean): void;
  34195. private _createChromaticAberrationPostProcess(ratio);
  34196. private _createHighlightsPostProcess(ratio);
  34197. private _createDepthOfFieldPostProcess(ratio);
  34198. private _createGrainTexture();
  34199. }
  34200. }
  34201. declare module BABYLON {
  34202. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34203. /**
  34204. * The PassPostProcess id in the pipeline that contains the original scene color
  34205. */
  34206. SSAOOriginalSceneColorEffect: string;
  34207. /**
  34208. * The SSAO PostProcess id in the pipeline
  34209. */
  34210. SSAORenderEffect: string;
  34211. /**
  34212. * The horizontal blur PostProcess id in the pipeline
  34213. */
  34214. SSAOBlurHRenderEffect: string;
  34215. /**
  34216. * The vertical blur PostProcess id in the pipeline
  34217. */
  34218. SSAOBlurVRenderEffect: string;
  34219. /**
  34220. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34221. */
  34222. SSAOCombineRenderEffect: string;
  34223. /**
  34224. * The output strength of the SSAO post-process. Default value is 1.0.
  34225. */
  34226. totalStrength: number;
  34227. /**
  34228. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34229. */
  34230. maxZ: number;
  34231. /**
  34232. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34233. */
  34234. minZAspect: number;
  34235. /**
  34236. * Number of samples used for the SSAO calculations. Default value is 8
  34237. */
  34238. private _samples;
  34239. /**
  34240. * Ratio object used for SSAO ratio and blur ratio
  34241. */
  34242. private _ratio;
  34243. /**
  34244. * Dynamically generated sphere sampler.
  34245. */
  34246. private _sampleSphere;
  34247. /**
  34248. * Blur filter offsets
  34249. */
  34250. private _samplerOffsets;
  34251. samples: number;
  34252. /**
  34253. * Are we using bilateral blur ?
  34254. */
  34255. private _expensiveBlur;
  34256. expensiveBlur: boolean;
  34257. /**
  34258. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34259. */
  34260. radius: number;
  34261. /**
  34262. * The base color of the SSAO post-process
  34263. * The final result is "base + ssao" between [0, 1]
  34264. */
  34265. base: number;
  34266. /**
  34267. * Support test.
  34268. */
  34269. static readonly IsSupported: boolean;
  34270. private _scene;
  34271. private _depthTexture;
  34272. private _normalTexture;
  34273. private _randomTexture;
  34274. private _originalColorPostProcess;
  34275. private _ssaoPostProcess;
  34276. private _blurHPostProcess;
  34277. private _blurVPostProcess;
  34278. private _ssaoCombinePostProcess;
  34279. private _firstUpdate;
  34280. /**
  34281. * @constructor
  34282. * @param {string} name - The rendering pipeline name
  34283. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34284. * @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 }
  34285. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34286. */
  34287. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34288. /**
  34289. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34290. */
  34291. dispose(disableGeometryBufferRenderer?: boolean): void;
  34292. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34293. private _generateHemisphere();
  34294. private _createSSAOPostProcess(ratio);
  34295. private _createSSAOCombinePostProcess(ratio);
  34296. private _createRandomTexture();
  34297. /**
  34298. * Serialize the rendering pipeline (Used when exporting)
  34299. * @returns the serialized object
  34300. */
  34301. serialize(): any;
  34302. /**
  34303. * Parse the serialized pipeline
  34304. * @param source Source pipeline.
  34305. * @param scene The scene to load the pipeline to.
  34306. * @param rootUrl The URL of the serialized pipeline.
  34307. * @returns An instantiated pipeline from the serialized object.
  34308. */
  34309. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34310. }
  34311. }
  34312. declare module BABYLON {
  34313. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34314. /**
  34315. * The PassPostProcess id in the pipeline that contains the original scene color
  34316. */
  34317. SSAOOriginalSceneColorEffect: string;
  34318. /**
  34319. * The SSAO PostProcess id in the pipeline
  34320. */
  34321. SSAORenderEffect: string;
  34322. /**
  34323. * The horizontal blur PostProcess id in the pipeline
  34324. */
  34325. SSAOBlurHRenderEffect: string;
  34326. /**
  34327. * The vertical blur PostProcess id in the pipeline
  34328. */
  34329. SSAOBlurVRenderEffect: string;
  34330. /**
  34331. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34332. */
  34333. SSAOCombineRenderEffect: string;
  34334. /**
  34335. * The output strength of the SSAO post-process. Default value is 1.0.
  34336. */
  34337. totalStrength: number;
  34338. /**
  34339. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34340. */
  34341. radius: number;
  34342. /**
  34343. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34344. * Must not be equal to fallOff and superior to fallOff.
  34345. * Default value is 0.975
  34346. */
  34347. area: number;
  34348. /**
  34349. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34350. * Must not be equal to area and inferior to area.
  34351. * Default value is 0.0
  34352. */
  34353. fallOff: number;
  34354. /**
  34355. * The base color of the SSAO post-process
  34356. * The final result is "base + ssao" between [0, 1]
  34357. */
  34358. base: number;
  34359. private _scene;
  34360. private _depthTexture;
  34361. private _randomTexture;
  34362. private _originalColorPostProcess;
  34363. private _ssaoPostProcess;
  34364. private _blurHPostProcess;
  34365. private _blurVPostProcess;
  34366. private _ssaoCombinePostProcess;
  34367. private _firstUpdate;
  34368. /**
  34369. * @constructor
  34370. * @param {string} name - The rendering pipeline name
  34371. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34372. * @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 }
  34373. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34374. */
  34375. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34376. /**
  34377. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34378. */
  34379. dispose(disableDepthRender?: boolean): void;
  34380. private _createBlurPostProcess(ratio);
  34381. private _createSSAOPostProcess(ratio);
  34382. private _createSSAOCombinePostProcess(ratio);
  34383. private _createRandomTexture();
  34384. }
  34385. }
  34386. declare module BABYLON {
  34387. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34388. /**
  34389. * Public members
  34390. */
  34391. originalPostProcess: Nullable<PostProcess>;
  34392. downSampleX4PostProcess: Nullable<PostProcess>;
  34393. brightPassPostProcess: Nullable<PostProcess>;
  34394. blurHPostProcesses: PostProcess[];
  34395. blurVPostProcesses: PostProcess[];
  34396. textureAdderPostProcess: Nullable<PostProcess>;
  34397. volumetricLightPostProcess: Nullable<PostProcess>;
  34398. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34399. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  34400. volumetricLightMergePostProces: Nullable<PostProcess>;
  34401. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  34402. luminancePostProcess: Nullable<PostProcess>;
  34403. luminanceDownSamplePostProcesses: PostProcess[];
  34404. hdrPostProcess: Nullable<PostProcess>;
  34405. textureAdderFinalPostProcess: Nullable<PostProcess>;
  34406. lensFlareFinalPostProcess: Nullable<PostProcess>;
  34407. hdrFinalPostProcess: Nullable<PostProcess>;
  34408. lensFlarePostProcess: Nullable<PostProcess>;
  34409. lensFlareComposePostProcess: Nullable<PostProcess>;
  34410. motionBlurPostProcess: Nullable<PostProcess>;
  34411. depthOfFieldPostProcess: Nullable<PostProcess>;
  34412. brightThreshold: number;
  34413. blurWidth: number;
  34414. horizontalBlur: boolean;
  34415. exposure: number;
  34416. lensTexture: Nullable<Texture>;
  34417. volumetricLightCoefficient: number;
  34418. volumetricLightPower: number;
  34419. volumetricLightBlurScale: number;
  34420. sourceLight: Nullable<SpotLight | DirectionalLight>;
  34421. hdrMinimumLuminance: number;
  34422. hdrDecreaseRate: number;
  34423. hdrIncreaseRate: number;
  34424. lensColorTexture: Nullable<Texture>;
  34425. lensFlareStrength: number;
  34426. lensFlareGhostDispersal: number;
  34427. lensFlareHaloWidth: number;
  34428. lensFlareDistortionStrength: number;
  34429. lensStarTexture: Nullable<Texture>;
  34430. lensFlareDirtTexture: Nullable<Texture>;
  34431. depthOfFieldDistance: number;
  34432. depthOfFieldBlurWidth: number;
  34433. motionStrength: number;
  34434. animations: Animation[];
  34435. /**
  34436. * Private members
  34437. */
  34438. private _scene;
  34439. private _currentDepthOfFieldSource;
  34440. private _basePostProcess;
  34441. private _hdrCurrentLuminance;
  34442. private _floatTextureType;
  34443. private _ratio;
  34444. private _bloomEnabled;
  34445. private _depthOfFieldEnabled;
  34446. private _vlsEnabled;
  34447. private _lensFlareEnabled;
  34448. private _hdrEnabled;
  34449. private _motionBlurEnabled;
  34450. private _motionBlurSamples;
  34451. private _volumetricLightStepsCount;
  34452. BloomEnabled: boolean;
  34453. DepthOfFieldEnabled: boolean;
  34454. LensFlareEnabled: boolean;
  34455. HDREnabled: boolean;
  34456. VLSEnabled: boolean;
  34457. MotionBlurEnabled: boolean;
  34458. volumetricLightStepsCount: number;
  34459. motionBlurSamples: number;
  34460. /**
  34461. * @constructor
  34462. * @param {string} name - The rendering pipeline name
  34463. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34464. * @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)
  34465. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  34466. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34467. */
  34468. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  34469. private _buildPipeline();
  34470. private _createDownSampleX4PostProcess(scene, ratio);
  34471. private _createBrightPassPostProcess(scene, ratio);
  34472. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  34473. private _createTextureAdderPostProcess(scene, ratio);
  34474. private _createVolumetricLightPostProcess(scene, ratio);
  34475. private _createLuminancePostProcesses(scene, textureType);
  34476. private _createHdrPostProcess(scene, ratio);
  34477. private _createLensFlarePostProcess(scene, ratio);
  34478. private _createDepthOfFieldPostProcess(scene, ratio);
  34479. private _createMotionBlurPostProcess(scene, ratio);
  34480. private _getDepthTexture();
  34481. private _disposePostProcesses();
  34482. /**
  34483. * Dispose of the pipeline and stop all post processes
  34484. */
  34485. dispose(): void;
  34486. /**
  34487. * Serialize the rendering pipeline (Used when exporting)
  34488. * @returns the serialized object
  34489. */
  34490. serialize(): any;
  34491. /**
  34492. * Parse the serialized pipeline
  34493. * @param source Source pipeline.
  34494. * @param scene The scene to load the pipeline to.
  34495. * @param rootUrl The URL of the serialized pipeline.
  34496. * @returns An instantiated pipeline from the serialized object.
  34497. */
  34498. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  34499. static LuminanceSteps: number;
  34500. }
  34501. }
  34502. declare module BABYLON.GUI {
  34503. interface IFocusableControl {
  34504. onFocus(): void;
  34505. onBlur(): void;
  34506. processKeyboard(evt: KeyboardEvent): void;
  34507. }
  34508. class AdvancedDynamicTexture extends DynamicTexture {
  34509. private _isDirty;
  34510. private _renderObserver;
  34511. private _resizeObserver;
  34512. private _preKeyboardObserver;
  34513. private _pointerMoveObserver;
  34514. private _pointerObserver;
  34515. private _canvasPointerOutObserver;
  34516. private _background;
  34517. ;
  34518. ;
  34519. ;
  34520. private _isFullscreen;
  34521. private _fullscreenViewport;
  34522. private _idealWidth;
  34523. private _idealHeight;
  34524. private _useSmallestIdeal;
  34525. private _renderAtIdealSize;
  34526. private _focusedControl;
  34527. private _blockNextFocusCheck;
  34528. private _renderScale;
  34529. renderScale: number;
  34530. background: string;
  34531. idealWidth: number;
  34532. idealHeight: number;
  34533. useSmallestIdeal: boolean;
  34534. renderAtIdealSize: boolean;
  34535. readonly layer: Nullable<Layer>;
  34536. readonly rootContainer: Container;
  34537. focusedControl: Nullable<IFocusableControl>;
  34538. isForeground: boolean;
  34539. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  34540. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  34541. markAsDirty(): void;
  34542. addControl(control: Control): AdvancedDynamicTexture;
  34543. removeControl(control: Control): AdvancedDynamicTexture;
  34544. dispose(): void;
  34545. private _onResize();
  34546. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  34547. private _checkUpdate(camera);
  34548. private _render();
  34549. private _doPicking(x, y, type, pointerId, buttonIndex);
  34550. , control: Control): void;
  34551. attach(): void;
  34552. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  34553. moveFocusToControl(control: IFocusableControl): void;
  34554. private _manageFocus();
  34555. private _attachToOnPointerOut(scene);
  34556. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  34557. /**
  34558. * FullScreenUI is created in a layer. This allows it to be treated like any other layer.
  34559. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  34560. * When the GUI is not Created as FullscreenUI it does not respect the layerMask.
  34561. * layerMask is set through advancedTexture.layer.layerMask
  34562. * @param name name for the Texture
  34563. * @param foreground render in foreground (default is true)
  34564. * @param scene scene to be rendered in
  34565. * @param sampling method for scaling to fit screen
  34566. * @returns AdvancedDynamicTexture
  34567. */
  34568. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  34569. }
  34570. }
  34571. declare module BABYLON.GUI {
  34572. class Measure {
  34573. left: number;
  34574. top: number;
  34575. width: number;
  34576. height: number;
  34577. constructor(left: number, top: number, width: number, height: number);
  34578. copyFrom(other: Measure): void;
  34579. isEqualsTo(other: Measure): boolean;
  34580. static Empty(): Measure;
  34581. }
  34582. }
  34583. declare module BABYLON.GUI {
  34584. class Vector2WithInfo extends Vector2 {
  34585. buttonIndex: number;
  34586. constructor(source: Vector2, buttonIndex?: number);
  34587. }
  34588. class Matrix2D {
  34589. m: Float32Array;
  34590. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  34591. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  34592. determinant(): number;
  34593. invertToRef(result: Matrix2D): Matrix2D;
  34594. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  34595. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  34596. static Identity(): Matrix2D;
  34597. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  34598. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  34599. static RotationToRef(angle: number, result: Matrix2D): void;
  34600. private static _TempPreTranslationMatrix;
  34601. private static _TempPostTranslationMatrix;
  34602. private static _TempRotationMatrix;
  34603. private static _TempScalingMatrix;
  34604. private static _TempCompose0;
  34605. private static _TempCompose1;
  34606. private static _TempCompose2;
  34607. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  34608. }
  34609. }
  34610. declare module BABYLON.GUI {
  34611. class ValueAndUnit {
  34612. unit: number;
  34613. negativeValueAllowed: boolean;
  34614. private _value;
  34615. ignoreAdaptiveScaling: boolean;
  34616. constructor(value: number, unit?: number, negativeValueAllowed?: boolean);
  34617. readonly isPercentage: boolean;
  34618. readonly isPixel: boolean;
  34619. readonly internalValue: number;
  34620. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  34621. getValue(host: AdvancedDynamicTexture): number;
  34622. toString(host: AdvancedDynamicTexture): string;
  34623. fromString(source: string | number): boolean;
  34624. private static _Regex;
  34625. private static _UNITMODE_PERCENTAGE;
  34626. private static _UNITMODE_PIXEL;
  34627. static readonly UNITMODE_PERCENTAGE: number;
  34628. static readonly UNITMODE_PIXEL: number;
  34629. }
  34630. }
  34631. declare module BABYLON.GUI {
  34632. class MultiLinePoint {
  34633. private _multiLine;
  34634. private _x;
  34635. private _y;
  34636. private _control;
  34637. private _mesh;
  34638. private _controlObserver;
  34639. private _meshObserver;
  34640. constructor(multiLine: MultiLine);
  34641. x: string | number;
  34642. y: string | number;
  34643. control: Nullable<Control>;
  34644. mesh: Nullable<AbstractMesh>;
  34645. translate(): Vector2;
  34646. private _translatePoint();
  34647. dispose(): void;
  34648. }
  34649. }
  34650. declare module BABYLON.GUI {
  34651. class Control {
  34652. name: string | undefined;
  34653. private _alpha;
  34654. private _alphaSet;
  34655. private _zIndex;
  34656. parent: Nullable<Container>;
  34657. private _fontFamily;
  34658. private _fontStyle;
  34659. private _fontSize;
  34660. private _font;
  34661. protected _fontOffset: {
  34662. ascent: number;
  34663. height: number;
  34664. descent: number;
  34665. };
  34666. private _color;
  34667. protected _horizontalAlignment: number;
  34668. protected _verticalAlignment: number;
  34669. private _isDirty;
  34670. protected _cachedParentMeasure: Measure;
  34671. private _paddingLeft;
  34672. private _paddingRight;
  34673. private _paddingTop;
  34674. private _paddingBottom;
  34675. private _scaleX;
  34676. private _scaleY;
  34677. private _rotation;
  34678. private _transformCenterX;
  34679. private _transformCenterY;
  34680. private _transformMatrix;
  34681. protected _invertTransformMatrix: Matrix2D;
  34682. protected _transformedPosition: Vector2;
  34683. private _onlyMeasureMode;
  34684. private _isMatrixDirty;
  34685. private _cachedOffsetX;
  34686. private _cachedOffsetY;
  34687. private _isVisible;
  34688. private _fontSet;
  34689. private _dummyVector2;
  34690. private _downCount;
  34691. private _enterCount;
  34692. private _doNotRender;
  34693. private _downPointerIds;
  34694. isHitTestVisible: boolean;
  34695. isPointerBlocker: boolean;
  34696. isFocusInvisible: boolean;
  34697. shadowOffsetX: number;
  34698. shadowOffsetY: number;
  34699. shadowBlur: number;
  34700. shadowColor: string;
  34701. protected _linkOffsetX: ValueAndUnit;
  34702. protected _linkOffsetY: ValueAndUnit;
  34703. readonly typeName: string;
  34704. /**
  34705. * An event triggered when the pointer move over the control.
  34706. */
  34707. onPointerMoveObservable: Observable<Vector2>;
  34708. /**
  34709. * An event triggered when the pointer move out of the control.
  34710. */
  34711. onPointerOutObservable: Observable<Control>;
  34712. /**
  34713. * An event triggered when the pointer taps the control
  34714. */
  34715. onPointerDownObservable: Observable<Vector2WithInfo>;
  34716. /**
  34717. * An event triggered when pointer up
  34718. */
  34719. onPointerUpObservable: Observable<Vector2WithInfo>;
  34720. /**
  34721. * An event triggered when a control is clicked on
  34722. */
  34723. onPointerClickObservable: Observable<Vector2WithInfo>;
  34724. /**
  34725. * An event triggered when pointer enters the control
  34726. */
  34727. onPointerEnterObservable: Observable<Control>;
  34728. /**
  34729. * An event triggered when the control is marked as dirty
  34730. */
  34731. onDirtyObservable: Observable<Control>;
  34732. /**
  34733. * An event triggered after the control is drawn
  34734. */
  34735. onAfterDrawObservable: Observable<Control>;
  34736. /** Gets or set information about font offsets (used to render and align text) */
  34737. fontOffset: {
  34738. ascent: number;
  34739. height: number;
  34740. descent: number;
  34741. };
  34742. alpha: number;
  34743. scaleX: number;
  34744. scaleY: number;
  34745. rotation: number;
  34746. transformCenterY: number;
  34747. transformCenterX: number;
  34748. horizontalAlignment: number;
  34749. verticalAlignment: number;
  34750. width: string | number;
  34751. readonly widthInPixels: number;
  34752. height: string | number;
  34753. readonly heightInPixels: number;
  34754. fontFamily: string;
  34755. fontStyle: string;
  34756. /** @hidden */
  34757. protected readonly _isFontSizeInPercentage: boolean;
  34758. readonly fontSizeInPixels: number;
  34759. fontSize: string | number;
  34760. color: string;
  34761. zIndex: number;
  34762. notRenderable: boolean;
  34763. isVisible: boolean;
  34764. readonly isDirty: boolean;
  34765. paddingLeft: string | number;
  34766. readonly paddingLeftInPixels: number;
  34767. paddingRight: string | number;
  34768. readonly paddingRightInPixels: number;
  34769. paddingTop: string | number;
  34770. readonly paddingTopInPixels: number;
  34771. paddingBottom: string | number;
  34772. readonly paddingBottomInPixels: number;
  34773. left: string | number;
  34774. readonly leftInPixels: number;
  34775. top: string | number;
  34776. readonly topInPixels: number;
  34777. linkOffsetX: string | number;
  34778. readonly linkOffsetXInPixels: number;
  34779. linkOffsetY: string | number;
  34780. readonly linkOffsetYInPixels: number;
  34781. readonly centerX: number;
  34782. readonly centerY: number;
  34783. constructor(name?: string | undefined);
  34784. protected _getTypeName(): string;
  34785. /** @hidden */
  34786. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  34787. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  34788. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  34789. moveToVector3(position: Vector3, scene: Scene): void;
  34790. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  34791. protected _transform(context: CanvasRenderingContext2D): void;
  34792. protected _applyStates(context: CanvasRenderingContext2D): void;
  34793. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  34794. protected _clip(context: CanvasRenderingContext2D): void;
  34795. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34796. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34797. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34798. contains(x: number, y: number): boolean;
  34799. forcePointerUp(pointerId?: Nullable<number>): void;
  34800. private _prepareFont();
  34801. dispose(): void;
  34802. private static _HORIZONTAL_ALIGNMENT_LEFT;
  34803. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  34804. private static _HORIZONTAL_ALIGNMENT_CENTER;
  34805. private static _VERTICAL_ALIGNMENT_TOP;
  34806. private static _VERTICAL_ALIGNMENT_BOTTOM;
  34807. private static _VERTICAL_ALIGNMENT_CENTER;
  34808. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  34809. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  34810. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  34811. static readonly VERTICAL_ALIGNMENT_TOP: number;
  34812. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  34813. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  34814. private static _FontHeightSizes;
  34815. private static _GetFontOffset(font: string): {
  34816. ascent: number;
  34817. height: number;
  34818. descent: number;
  34819. };
  34820. static AddHeader(control: Control, text: string, size: string | number, options: {
  34821. isHorizontal: boolean;
  34822. controlFirst: boolean;
  34823. }): StackPanel;
  34824. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  34825. }
  34826. }
  34827. declare module BABYLON.GUI {
  34828. class Container extends Control {
  34829. name: string | undefined;
  34830. protected _children: Control[];
  34831. protected _measureForChildren: Measure;
  34832. protected _background: string;
  34833. protected _adaptWidthToChildren: boolean;
  34834. protected _adaptHeightToChildren: boolean;
  34835. adaptHeightToChildren: boolean;
  34836. adaptWidthToChildren: boolean;
  34837. background: string;
  34838. readonly children: Control[];
  34839. constructor(name?: string | undefined);
  34840. protected _getTypeName(): string;
  34841. getChildByName(name: string): Nullable<Control>;
  34842. getChildByType(name: string, type: string): Nullable<Control>;
  34843. containsControl(control: Control): boolean;
  34844. addControl(control: Control): Container;
  34845. removeControl(control: Control): Container;
  34846. protected _localDraw(context: CanvasRenderingContext2D): void;
  34847. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  34848. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34849. dispose(): void;
  34850. }
  34851. }
  34852. declare module BABYLON.GUI {
  34853. class StackPanel extends Container {
  34854. name: string | undefined;
  34855. private _isVertical;
  34856. private _manualWidth;
  34857. private _manualHeight;
  34858. private _doNotTrackManualChanges;
  34859. private _tempMeasureStore;
  34860. isVertical: boolean;
  34861. width: string | number;
  34862. height: string | number;
  34863. constructor(name?: string | undefined);
  34864. protected _getTypeName(): string;
  34865. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34866. }
  34867. }
  34868. declare module BABYLON.GUI {
  34869. class Rectangle extends Container {
  34870. name: string | undefined;
  34871. private _thickness;
  34872. private _cornerRadius;
  34873. thickness: number;
  34874. cornerRadius: number;
  34875. constructor(name?: string | undefined);
  34876. protected _getTypeName(): string;
  34877. protected _localDraw(context: CanvasRenderingContext2D): void;
  34878. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34879. private _drawRoundedRect(context, offset?);
  34880. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  34881. }
  34882. }
  34883. declare module BABYLON.GUI {
  34884. class Ellipse extends Container {
  34885. name: string | undefined;
  34886. private _thickness;
  34887. thickness: number;
  34888. constructor(name?: string | undefined);
  34889. protected _getTypeName(): string;
  34890. protected _localDraw(context: CanvasRenderingContext2D): void;
  34891. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34892. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  34893. }
  34894. }
  34895. declare module BABYLON.GUI {
  34896. class Line extends Control {
  34897. name: string | undefined;
  34898. private _lineWidth;
  34899. private _x1;
  34900. private _y1;
  34901. private _x2;
  34902. private _y2;
  34903. private _dash;
  34904. private _connectedControl;
  34905. private _connectedControlDirtyObserver;
  34906. dash: Array<number>;
  34907. connectedControl: Control;
  34908. x1: string | number;
  34909. y1: string | number;
  34910. x2: string | number;
  34911. y2: string | number;
  34912. lineWidth: number;
  34913. horizontalAlignment: number;
  34914. verticalAlignment: number;
  34915. private readonly _effectiveX2;
  34916. private readonly _effectiveY2;
  34917. constructor(name?: string | undefined);
  34918. protected _getTypeName(): string;
  34919. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  34920. /**
  34921. * Move one end of the line given 3D cartesian coordinates.
  34922. * @param position Targeted world position
  34923. * @param scene Scene
  34924. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  34925. */
  34926. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  34927. /**
  34928. * Move one end of the line to a position in screen absolute space.
  34929. * @param projectedPosition Position in screen absolute space (X, Y)
  34930. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  34931. */
  34932. }
  34933. }
  34934. declare module BABYLON.GUI {
  34935. class Slider extends Control {
  34936. name: string | undefined;
  34937. private _thumbWidth;
  34938. private _minimum;
  34939. private _maximum;
  34940. private _value;
  34941. private _background;
  34942. private _borderColor;
  34943. private _barOffset;
  34944. private _isThumbCircle;
  34945. private _isThumbClamped;
  34946. onValueChangedObservable: Observable<number>;
  34947. borderColor: string;
  34948. background: string;
  34949. barOffset: string | number;
  34950. readonly barOffsetInPixels: number;
  34951. thumbWidth: string | number;
  34952. readonly thumbWidthInPixels: number;
  34953. minimum: number;
  34954. maximum: number;
  34955. value: number;
  34956. isThumbCircle: boolean;
  34957. isThumbClamped: boolean;
  34958. constructor(name?: string | undefined);
  34959. protected _getTypeName(): string;
  34960. private _pointerIsDown;
  34961. private _updateValueFromPointer(x, y);
  34962. }
  34963. }
  34964. declare module BABYLON.GUI {
  34965. class Checkbox extends Control {
  34966. name: string | undefined;
  34967. private _isChecked;
  34968. private _background;
  34969. private _checkSizeRatio;
  34970. private _thickness;
  34971. thickness: number;
  34972. onIsCheckedChangedObservable: Observable<boolean>;
  34973. checkSizeRatio: number;
  34974. background: string;
  34975. isChecked: boolean;
  34976. constructor(name?: string | undefined);
  34977. protected _getTypeName(): string;
  34978. }
  34979. }
  34980. declare module BABYLON.GUI {
  34981. class RadioButton extends Control {
  34982. name: string | undefined;
  34983. private _isChecked;
  34984. private _background;
  34985. private _checkSizeRatio;
  34986. private _thickness;
  34987. thickness: number;
  34988. group: string;
  34989. onIsCheckedChangedObservable: Observable<boolean>;
  34990. checkSizeRatio: number;
  34991. background: string;
  34992. isChecked: boolean;
  34993. constructor(name?: string | undefined);
  34994. protected _getTypeName(): string;
  34995. }
  34996. }
  34997. declare module BABYLON.GUI {
  34998. class TextBlock extends Control {
  34999. /**
  35000. * Defines the name of the control
  35001. */
  35002. name: string | undefined;
  35003. private _text;
  35004. private _textWrapping;
  35005. private _textHorizontalAlignment;
  35006. private _textVerticalAlignment;
  35007. private _lines;
  35008. private _resizeToFit;
  35009. private _lineSpacing;
  35010. private _outlineWidth;
  35011. private _outlineColor;
  35012. /**
  35013. * An event triggered after the text is changed
  35014. */
  35015. onTextChangedObservable: Observable<TextBlock>;
  35016. /**
  35017. * An event triggered after the text was broken up into lines
  35018. */
  35019. onLinesReadyObservable: Observable<TextBlock>;
  35020. /**
  35021. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  35022. */
  35023. readonly lines: any[];
  35024. /**
  35025. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  35026. */
  35027. /**
  35028. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  35029. */
  35030. resizeToFit: boolean;
  35031. /**
  35032. * Gets or sets a boolean indicating if text must be wrapped
  35033. */
  35034. /**
  35035. * Gets or sets a boolean indicating if text must be wrapped
  35036. */
  35037. textWrapping: boolean;
  35038. /**
  35039. * Gets or sets text to display
  35040. */
  35041. /**
  35042. * Gets or sets text to display
  35043. */
  35044. text: string;
  35045. /**
  35046. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  35047. */
  35048. /**
  35049. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  35050. */
  35051. textHorizontalAlignment: number;
  35052. /**
  35053. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  35054. */
  35055. /**
  35056. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  35057. */
  35058. textVerticalAlignment: number;
  35059. /**
  35060. * Gets or sets line spacing value
  35061. */
  35062. /**
  35063. * Gets or sets line spacing value
  35064. */
  35065. lineSpacing: string | number;
  35066. /**
  35067. * Gets or sets outlineWidth of the text to display
  35068. */
  35069. /**
  35070. * Gets or sets outlineWidth of the text to display
  35071. */
  35072. outlineWidth: number;
  35073. /**
  35074. * Gets or sets outlineColor of the text to display
  35075. */
  35076. /**
  35077. * Gets or sets outlineColor of the text to display
  35078. */
  35079. outlineColor: string;
  35080. /**
  35081. * Creates a new TextBlock object
  35082. * @param name defines the name of the control
  35083. * @param text defines the text to display (emptry string by default)
  35084. */
  35085. constructor(
  35086. /**
  35087. * Defines the name of the control
  35088. */
  35089. name?: string | undefined, text?: string);
  35090. protected _getTypeName(): string;
  35091. private _drawText(text, textWidth, y, context);
  35092. /** @hidden */
  35093. protected _applyStates(context: CanvasRenderingContext2D): void;
  35094. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  35095. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  35096. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  35097. protected _renderLines(context: CanvasRenderingContext2D): void;
  35098. dispose(): void;
  35099. }
  35100. }
  35101. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  35102. declare module BABYLON.GUI {
  35103. class Image extends Control {
  35104. name: string | undefined;
  35105. private _domImage;
  35106. private _imageWidth;
  35107. private _imageHeight;
  35108. private _loaded;
  35109. private _stretch;
  35110. private _source;
  35111. private _autoScale;
  35112. private _sourceLeft;
  35113. private _sourceTop;
  35114. private _sourceWidth;
  35115. private _sourceHeight;
  35116. private _cellWidth;
  35117. private _cellHeight;
  35118. private _cellId;
  35119. sourceLeft: number;
  35120. sourceTop: number;
  35121. sourceWidth: number;
  35122. sourceHeight: number;
  35123. autoScale: boolean;
  35124. stretch: number;
  35125. domImage: HTMLImageElement;
  35126. private _onImageLoaded();
  35127. source: Nullable<string>;
  35128. cellWidth: number;
  35129. cellHeight: number;
  35130. cellId: number;
  35131. constructor(name?: string | undefined, url?: Nullable<string>);
  35132. protected _getTypeName(): string;
  35133. synchronizeSizeWithContent(): void;
  35134. private static _STRETCH_NONE;
  35135. private static _STRETCH_FILL;
  35136. private static _STRETCH_UNIFORM;
  35137. private static _STRETCH_EXTEND;
  35138. static readonly STRETCH_NONE: number;
  35139. static readonly STRETCH_FILL: number;
  35140. static readonly STRETCH_UNIFORM: number;
  35141. static readonly STRETCH_EXTEND: number;
  35142. }
  35143. }
  35144. declare module BABYLON.GUI {
  35145. class Button extends Rectangle {
  35146. name: string | undefined;
  35147. pointerEnterAnimation: () => void;
  35148. pointerOutAnimation: () => void;
  35149. pointerDownAnimation: () => void;
  35150. pointerUpAnimation: () => void;
  35151. constructor(name?: string | undefined);
  35152. protected _getTypeName(): string;
  35153. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  35154. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  35155. static CreateSimpleButton(name: string, text: string): Button;
  35156. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  35157. }
  35158. }
  35159. declare module BABYLON.GUI {
  35160. class ColorPicker extends Control {
  35161. name: string | undefined;
  35162. private _colorWheelCanvas;
  35163. private _value;
  35164. private _tmpColor;
  35165. private _pointerStartedOnSquare;
  35166. private _pointerStartedOnWheel;
  35167. private _squareLeft;
  35168. private _squareTop;
  35169. private _squareSize;
  35170. private _h;
  35171. private _s;
  35172. private _v;
  35173. onValueChangedObservable: Observable<Color3>;
  35174. value: Color3;
  35175. width: string | number;
  35176. height: string | number;
  35177. size: string | number;
  35178. constructor(name?: string | undefined);
  35179. protected _getTypeName(): string;
  35180. private _updateSquareProps();
  35181. private _drawGradientSquare(hueValue, left, top, width, height, context);
  35182. private _drawCircle(centerX, centerY, radius, context);
  35183. private _createColorWheelCanvas(radius, thickness);
  35184. private _RGBtoHSV(color, result);
  35185. private _HSVtoRGB(hue, saturation, value, result);
  35186. private _pointerIsDown;
  35187. private _updateValueFromPointer(x, y);
  35188. private _isPointOnSquare(coordinates);
  35189. private _isPointOnWheel(coordinates);
  35190. }
  35191. }
  35192. declare module BABYLON.GUI {
  35193. class InputText extends Control implements IFocusableControl {
  35194. name: string | undefined;
  35195. private _text;
  35196. private _placeholderText;
  35197. private _background;
  35198. private _focusedBackground;
  35199. private _placeholderColor;
  35200. private _thickness;
  35201. private _margin;
  35202. private _autoStretchWidth;
  35203. private _maxWidth;
  35204. private _isFocused;
  35205. private _blinkTimeout;
  35206. private _blinkIsEven;
  35207. private _cursorOffset;
  35208. private _scrollLeft;
  35209. private _textWidth;
  35210. private _clickedCoordinate;
  35211. promptMessage: string;
  35212. onTextChangedObservable: Observable<InputText>;
  35213. onFocusObservable: Observable<InputText>;
  35214. onBlurObservable: Observable<InputText>;
  35215. maxWidth: string | number;
  35216. readonly maxWidthInPixels: number;
  35217. margin: string;
  35218. readonly marginInPixels: number;
  35219. autoStretchWidth: boolean;
  35220. thickness: number;
  35221. focusedBackground: string;
  35222. background: string;
  35223. placeholderColor: string;
  35224. placeholderText: string;
  35225. text: string;
  35226. width: string | number;
  35227. constructor(name?: string | undefined, text?: string);
  35228. onBlur(): void;
  35229. onFocus(): void;
  35230. protected _getTypeName(): string;
  35231. processKey(keyCode: number, key?: string): void;
  35232. processKeyboard(evt: KeyboardEvent): void;
  35233. dispose(): void;
  35234. }
  35235. }
  35236. declare module BABYLON.GUI {
  35237. class KeyPropertySet {
  35238. width?: string;
  35239. height?: string;
  35240. paddingLeft?: string;
  35241. paddingRight?: string;
  35242. paddingTop?: string;
  35243. paddingBottom?: string;
  35244. color?: string;
  35245. background?: string;
  35246. }
  35247. class VirtualKeyboard extends StackPanel {
  35248. onKeyPressObservable: Observable<string>;
  35249. defaultButtonWidth: string;
  35250. defaultButtonHeight: string;
  35251. defaultButtonPaddingLeft: string;
  35252. defaultButtonPaddingRight: string;
  35253. defaultButtonPaddingTop: string;
  35254. defaultButtonPaddingBottom: string;
  35255. defaultButtonColor: string;
  35256. defaultButtonBackground: string;
  35257. shiftButtonColor: string;
  35258. selectedShiftThickness: number;
  35259. shiftState: number;
  35260. protected _getTypeName(): string;
  35261. private _createKey(key, propertySet);
  35262. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  35263. applyShiftState(shiftState: number): void;
  35264. private _connectedInputText;
  35265. private _onFocusObserver;
  35266. private _onBlurObserver;
  35267. private _onKeyPressObserver;
  35268. readonly connectedInputText: Nullable<InputText>;
  35269. connect(input: InputText): void;
  35270. disconnect(): void;
  35271. static CreateDefaultLayout(): VirtualKeyboard;
  35272. }
  35273. }
  35274. declare module BABYLON.GUI {
  35275. class MultiLine extends Control {
  35276. name: string | undefined;
  35277. private _lineWidth;
  35278. private _dash;
  35279. private _points;
  35280. private _minX;
  35281. private _minY;
  35282. private _maxX;
  35283. private _maxY;
  35284. constructor(name?: string | undefined);
  35285. dash: Array<number>;
  35286. getAt(index: number): MultiLinePoint;
  35287. onPointUpdate: () => void;
  35288. add(...items: (AbstractMesh | Control | {
  35289. x: string | number;
  35290. y: string | number;
  35291. })[]): MultiLinePoint[];
  35292. push(item?: (AbstractMesh | Control | {
  35293. x: string | number;
  35294. y: string | number;
  35295. })): MultiLinePoint;
  35296. remove(value: number | MultiLinePoint): void;
  35297. lineWidth: number;
  35298. horizontalAlignment: number;
  35299. verticalAlignment: number;
  35300. protected _getTypeName(): string;
  35301. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  35302. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  35303. dispose(): void;
  35304. }
  35305. }
  35306. declare module BABYLON {
  35307. /**
  35308. * Mode that determines the coordinate system to use.
  35309. */
  35310. enum GLTFLoaderCoordinateSystemMode {
  35311. /**
  35312. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  35313. */
  35314. AUTO = 0,
  35315. /**
  35316. * Sets the useRightHandedSystem flag on the scene.
  35317. */
  35318. FORCE_RIGHT_HANDED = 1,
  35319. }
  35320. /**
  35321. * Mode that determines what animations will start.
  35322. */
  35323. enum GLTFLoaderAnimationStartMode {
  35324. /**
  35325. * No animation will start.
  35326. */
  35327. NONE = 0,
  35328. /**
  35329. * The first animation will start.
  35330. */
  35331. FIRST = 1,
  35332. /**
  35333. * All animations will start.
  35334. */
  35335. ALL = 2,
  35336. }
  35337. /**
  35338. * Interface that contains the data for the glTF asset.
  35339. */
  35340. interface IGLTFLoaderData {
  35341. /**
  35342. * JSON that represents the glTF.
  35343. */
  35344. json: Object;
  35345. /**
  35346. * The BIN chunk of a binary glTF
  35347. */
  35348. bin: Nullable<ArrayBufferView>;
  35349. }
  35350. /**
  35351. * Interface for extending the loader.
  35352. */
  35353. interface IGLTFLoaderExtension {
  35354. /**
  35355. * The name of this extension.
  35356. */
  35357. readonly name: string;
  35358. /**
  35359. * Defines whether this extension is enabled.
  35360. */
  35361. enabled: boolean;
  35362. }
  35363. /**
  35364. * Loader state.
  35365. */
  35366. enum GLTFLoaderState {
  35367. /**
  35368. * The asset is loading.
  35369. */
  35370. LOADING = 0,
  35371. /**
  35372. * The asset is ready for rendering.
  35373. */
  35374. READY = 1,
  35375. /**
  35376. * The asset is completely loaded.
  35377. */
  35378. COMPLETE = 2,
  35379. }
  35380. /**
  35381. * Loader interface.
  35382. */
  35383. interface IGLTFLoader extends IDisposable {
  35384. /**
  35385. * Mode that determines the coordinate system to use.
  35386. */
  35387. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  35388. /**
  35389. * Mode that determines what animations will start.
  35390. */
  35391. animationStartMode: GLTFLoaderAnimationStartMode;
  35392. /**
  35393. * Defines if the loader should compile materials.
  35394. */
  35395. compileMaterials: boolean;
  35396. /**
  35397. * Defines if the loader should also compile materials with clip planes.
  35398. */
  35399. useClipPlane: boolean;
  35400. /**
  35401. * Defines if the loader should compile shadow generators.
  35402. */
  35403. compileShadowGenerators: boolean;
  35404. /**
  35405. * Defines if the Alpha blended materials are only applied as coverage.
  35406. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  35407. * If true, no extra effects are applied to transparent pixels.
  35408. */
  35409. transparencyAsCoverage: boolean;
  35410. /**
  35411. * Function called before loading a url referenced by the asset.
  35412. */
  35413. preprocessUrlAsync: (url: string) => Promise<string>;
  35414. /**
  35415. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  35416. */
  35417. onMeshLoadedObservable: Observable<AbstractMesh>;
  35418. /**
  35419. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  35420. */
  35421. onTextureLoadedObservable: Observable<BaseTexture>;
  35422. /**
  35423. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  35424. */
  35425. onMaterialLoadedObservable: Observable<Material>;
  35426. /**
  35427. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  35428. */
  35429. onCameraLoadedObservable: Observable<Camera>;
  35430. /**
  35431. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  35432. * For assets with LODs, raised when all of the LODs are complete.
  35433. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  35434. */
  35435. onCompleteObservable: Observable<IGLTFLoader>;
  35436. /**
  35437. * Observable raised after the loader is disposed.
  35438. */
  35439. onDisposeObservable: Observable<IGLTFLoader>;
  35440. /**
  35441. * Observable raised after a loader extension is created.
  35442. * Set additional options for a loader extension in this event.
  35443. */
  35444. onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  35445. /**
  35446. * Loader state or null if the loader is not active.
  35447. */
  35448. state: Nullable<GLTFLoaderState>;
  35449. /**
  35450. * Imports meshes from the given data and adds them to the scene.
  35451. */
  35452. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{
  35453. meshes: AbstractMesh[];
  35454. particleSystems: ParticleSystem[];
  35455. skeletons: Skeleton[];
  35456. animationGroups: AnimationGroup[];
  35457. }>;
  35458. /**
  35459. * Loads all objects from the given data and adds them to the scene.
  35460. */
  35461. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>;
  35462. }
  35463. /**
  35464. * File loader for loading glTF files into a scene.
  35465. */
  35466. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  35467. /**
  35468. * Factory function that creates a glTF 1.0 loader
  35469. */
  35470. static CreateGLTFLoaderV1: () => IGLTFLoader;
  35471. /**
  35472. * Factory function that creates a glTF 2.0 loader
  35473. */
  35474. static CreateGLTFLoaderV2: () => IGLTFLoader;
  35475. /**
  35476. * Raised when the asset has been parsed
  35477. */
  35478. onParsedObservable: Observable<IGLTFLoaderData>;
  35479. private _onParsedObserver;
  35480. /**
  35481. * Raised when the asset has been parsed
  35482. */
  35483. onParsed: (loaderData: IGLTFLoaderData) => void;
  35484. /**
  35485. * 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.
  35486. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  35487. * Defaults to true.
  35488. */
  35489. static IncrementalLoading: boolean;
  35490. /**
  35491. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  35492. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  35493. */
  35494. static HomogeneousCoordinates: boolean;
  35495. /**
  35496. * The coordinate system mode. Defaults to AUTO.
  35497. */
  35498. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  35499. /**
  35500. * The animation start mode. Defaults to FIRST.
  35501. */
  35502. animationStartMode: GLTFLoaderAnimationStartMode;
  35503. /**
  35504. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  35505. */
  35506. compileMaterials: boolean;
  35507. /**
  35508. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  35509. */
  35510. useClipPlane: boolean;
  35511. /**
  35512. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  35513. */
  35514. compileShadowGenerators: boolean;
  35515. /**
  35516. * Defines if the Alpha blended materials are only applied as coverage.
  35517. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  35518. * If true, no extra effects are applied to transparent pixels.
  35519. */
  35520. transparencyAsCoverage: boolean;
  35521. /**
  35522. * Function called before loading a url referenced by the asset.
  35523. */
  35524. preprocessUrlAsync: (url: string) => Promise<string>;
  35525. /**
  35526. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  35527. */
  35528. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  35529. private _onMeshLoadedObserver;
  35530. /**
  35531. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  35532. */
  35533. onMeshLoaded: (mesh: AbstractMesh) => void;
  35534. /**
  35535. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  35536. */
  35537. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  35538. private _onTextureLoadedObserver;
  35539. /**
  35540. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  35541. */
  35542. onTextureLoaded: (texture: BaseTexture) => void;
  35543. /**
  35544. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  35545. */
  35546. readonly onMaterialLoadedObservable: Observable<Material>;
  35547. private _onMaterialLoadedObserver;
  35548. /**
  35549. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  35550. */
  35551. onMaterialLoaded: (material: Material) => void;
  35552. /**
  35553. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  35554. */
  35555. readonly onCameraLoadedObservable: Observable<Camera>;
  35556. private _onCameraLoadedObserver;
  35557. /**
  35558. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  35559. */
  35560. onCameraLoaded: (camera: Camera) => void;
  35561. /**
  35562. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  35563. * For assets with LODs, raised when all of the LODs are complete.
  35564. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  35565. */
  35566. readonly onCompleteObservable: Observable<GLTFFileLoader>;
  35567. private _onCompleteObserver;
  35568. /**
  35569. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  35570. */
  35571. onComplete: () => void;
  35572. /**
  35573. * Observable raised after the loader is disposed.
  35574. */
  35575. readonly onDisposeObservable: Observable<GLTFFileLoader>;
  35576. private _onDisposeObserver;
  35577. /**
  35578. * Callback raised after the loader is disposed.
  35579. */
  35580. onDispose: () => void;
  35581. /**
  35582. * Observable raised after a loader extension is created.
  35583. * Set additional options for a loader extension in this event.
  35584. */
  35585. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  35586. private _onExtensionLoadedObserver;
  35587. /**
  35588. * Callback raised after a loader extension is created.
  35589. */
  35590. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  35591. /**
  35592. * Returns a promise that resolves when the asset is completely loaded.
  35593. * @returns a promise that resolves when the asset is completely loaded.
  35594. */
  35595. whenCompleteAsync(): Promise<void>;
  35596. /**
  35597. * The loader state or null if the loader is not active.
  35598. */
  35599. readonly loaderState: Nullable<GLTFLoaderState>;
  35600. private _loader;
  35601. /**
  35602. * Name of the loader ("gltf")
  35603. */
  35604. name: string;
  35605. /**
  35606. * Supported file extensions of the loader (.gltf, .glb)
  35607. */
  35608. extensions: ISceneLoaderPluginExtensions;
  35609. /**
  35610. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  35611. */
  35612. dispose(): void;
  35613. /**
  35614. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  35615. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  35616. * @param scene the scene the meshes should be added to
  35617. * @param data the glTF data to load
  35618. * @param rootUrl root url to load from
  35619. * @param onProgress event that fires when loading progress has occured
  35620. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  35621. */
  35622. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  35623. meshes: AbstractMesh[];
  35624. particleSystems: ParticleSystem[];
  35625. skeletons: Skeleton[];
  35626. animationGroups: AnimationGroup[];
  35627. }>;
  35628. /**
  35629. * Imports all objects from the loaded glTF data and adds them to the scene
  35630. * @param scene the scene the objects should be added to
  35631. * @param data the glTF data to load
  35632. * @param rootUrl root url to load from
  35633. * @param onProgress event that fires when loading progress has occured
  35634. * @returns a promise which completes when objects have been loaded to the scene
  35635. */
  35636. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  35637. /**
  35638. * Load into an asset container.
  35639. * @param scene The scene to load into
  35640. * @param data The data to import
  35641. * @param rootUrl The root url for scene and resources
  35642. * @param onProgress The callback when the load progresses
  35643. * @returns The loaded asset container
  35644. */
  35645. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  35646. /**
  35647. * If the data string can be loaded directly.
  35648. * @param data string contianing the file data
  35649. * @returns if the data can be loaded directly
  35650. */
  35651. canDirectLoad(data: string): boolean;
  35652. /**
  35653. * Rewrites a url by combining a root url and response url.
  35654. */
  35655. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  35656. /**
  35657. * Instantiates a glTF file loader plugin.
  35658. * @returns the created plugin
  35659. */
  35660. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  35661. private _parse(data);
  35662. private _getLoader(loaderData);
  35663. private static _parseBinary(data);
  35664. private static _parseV1(binaryReader);
  35665. private static _parseV2(binaryReader);
  35666. private static _parseVersion(version);
  35667. private static _compareVersion(a, b);
  35668. private static _decodeBufferToText(buffer);
  35669. }
  35670. }
  35671. declare module BABYLON.GLTF2 {
  35672. /** @hidden */
  35673. interface _IArrayItem {
  35674. }
  35675. /** @hidden */
  35676. class _ArrayItem {
  35677. /** @hidden */
  35678. static Assign(values?: _IArrayItem[]): void;
  35679. }
  35680. }
  35681. declare module BABYLON.GLTF2 {
  35682. /** @hidden */
  35683. interface _ILoaderAccessor extends IAccessor, _IArrayItem {
  35684. }
  35685. /** @hidden */
  35686. interface _ILoaderAnimationChannel extends IAnimationChannel, _IArrayItem {
  35687. }
  35688. /** @hidden */
  35689. interface _ILoaderAnimationSamplerData {
  35690. input: Float32Array;
  35691. interpolation: AnimationSamplerInterpolation;
  35692. output: Float32Array;
  35693. }
  35694. /** @hidden */
  35695. interface _ILoaderAnimationSampler extends IAnimationSampler, _IArrayItem {
  35696. }
  35697. /** @hidden */
  35698. interface _ILoaderAnimation extends IAnimation, _IArrayItem {
  35699. channels: _ILoaderAnimationChannel[];
  35700. samplers: _ILoaderAnimationSampler[];
  35701. }
  35702. /** @hidden */
  35703. interface _ILoaderBuffer extends IBuffer, _IArrayItem {
  35704. }
  35705. /** @hidden */
  35706. interface _ILoaderBufferView extends IBufferView, _IArrayItem {
  35707. }
  35708. /** @hidden */
  35709. interface _ILoaderCamera extends ICamera, _IArrayItem {
  35710. }
  35711. /** @hidden */
  35712. interface _ILoaderImage extends IImage, _IArrayItem {
  35713. }
  35714. /** @hidden */
  35715. interface _ILoaderMaterial extends IMaterial, _IArrayItem {
  35716. ;
  35717. };
  35718. }
  35719. /** @hidden */
  35720. interface _ILoaderMesh extends IMesh, _IArrayItem {
  35721. primitives: _ILoaderMeshPrimitive[];
  35722. }
  35723. /** @hidden */
  35724. interface _ILoaderMeshPrimitive extends IMeshPrimitive, _IArrayItem {
  35725. }
  35726. /** @hidden */
  35727. interface _ILoaderNode extends INode, _IArrayItem {
  35728. }
  35729. /** @hidden */
  35730. interface _ILoaderSamplerData {
  35731. noMipMaps: boolean;
  35732. samplingMode: number;
  35733. wrapU: number;
  35734. wrapV: number;
  35735. }
  35736. /** @hidden */
  35737. interface _ILoaderSampler extends ISampler, _IArrayItem {
  35738. }
  35739. /** @hidden */
  35740. interface _ILoaderScene extends IScene, _IArrayItem {
  35741. }
  35742. /** @hidden */
  35743. interface _ILoaderSkin extends ISkin, _IArrayItem {
  35744. }
  35745. /** @hidden */
  35746. interface _ILoaderTexture extends ITexture, _IArrayItem {
  35747. }
  35748. /** @hidden */
  35749. interface _ILoaderGLTF extends IGLTF {
  35750. accessors?: _ILoaderAccessor[];
  35751. animations?: _ILoaderAnimation[];
  35752. buffers?: _ILoaderBuffer[];
  35753. bufferViews?: _ILoaderBufferView[];
  35754. cameras?: _ILoaderCamera[];
  35755. images?: _ILoaderImage[];
  35756. materials?: _ILoaderMaterial[];
  35757. meshes?: _ILoaderMesh[];
  35758. nodes?: _ILoaderNode[];
  35759. samplers?: _ILoaderSampler[];
  35760. scenes?: _ILoaderScene[];
  35761. skins?: _ILoaderSkin[];
  35762. textures?: _ILoaderTexture[];
  35763. }
  35764. }
  35765. /**
  35766. * Defines the module used to import/export glTF 2.0 assets
  35767. */
  35768. declare module BABYLON.GLTF2 {
  35769. /**
  35770. * Loader for loading a glTF 2.0 asset
  35771. */
  35772. class GLTFLoader implements IGLTFLoader {
  35773. /** @hidden */
  35774. /** @hidden */
  35775. /** @hidden */
  35776. private _disposed;
  35777. private _state;
  35778. private _extensions;
  35779. private _rootUrl;
  35780. private _rootBabylonMesh;
  35781. private _defaultSampler;
  35782. private _defaultBabylonMaterials;
  35783. private _progressCallback?;
  35784. private _requests;
  35785. private static _ExtensionNames;
  35786. private static _ExtensionFactories;
  35787. /** @hidden */
  35788. private static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void;
  35789. /**
  35790. * Mode that determines the coordinate system to use.
  35791. */
  35792. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  35793. /**
  35794. * Mode that determines what animations will start.
  35795. */
  35796. animationStartMode: GLTFLoaderAnimationStartMode;
  35797. /**
  35798. * Defines if the loader should compile materials.
  35799. */
  35800. compileMaterials: boolean;
  35801. /**
  35802. * Defines if the loader should also compile materials with clip planes.
  35803. */
  35804. useClipPlane: boolean;
  35805. /**
  35806. * Defines if the loader should compile shadow generators.
  35807. */
  35808. compileShadowGenerators: boolean;
  35809. /**
  35810. * Defines if the Alpha blended materials are only applied as coverage.
  35811. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  35812. * If true, no extra effects are applied to transparent pixels.
  35813. */
  35814. transparencyAsCoverage: boolean;
  35815. /**
  35816. * Function called before loading a url referenced by the asset.
  35817. */
  35818. preprocessUrlAsync: (url: string) => Promise<string>;
  35819. /**
  35820. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  35821. */
  35822. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  35823. /**
  35824. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  35825. */
  35826. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  35827. /**
  35828. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  35829. */
  35830. readonly onMaterialLoadedObservable: Observable<Material>;
  35831. /**
  35832. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  35833. */
  35834. readonly onCameraLoadedObservable: Observable<Camera>;
  35835. /**
  35836. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  35837. * For assets with LODs, raised when all of the LODs are complete.
  35838. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  35839. */
  35840. readonly onCompleteObservable: Observable<IGLTFLoader>;
  35841. /**
  35842. * Observable raised after the loader is disposed.
  35843. */
  35844. readonly onDisposeObservable: Observable<IGLTFLoader>;
  35845. /**
  35846. * Observable raised after a loader extension is created.
  35847. * Set additional options for a loader extension in this event.
  35848. */
  35849. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  35850. /**
  35851. * Loader state or null if the loader is not active.
  35852. */
  35853. readonly state: Nullable<GLTFLoaderState>;
  35854. /**
  35855. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  35856. */
  35857. dispose(): void;
  35858. /**
  35859. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  35860. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  35861. * @param scene the scene the meshes should be added to
  35862. * @param data the glTF data to load
  35863. * @param rootUrl root url to load from
  35864. * @param onProgress event that fires when loading progress has occured
  35865. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  35866. */
  35867. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  35868. meshes: AbstractMesh[];
  35869. particleSystems: ParticleSystem[];
  35870. skeletons: Skeleton[];
  35871. animationGroups: AnimationGroup[];
  35872. }>;
  35873. /**
  35874. * Imports all objects from the loaded glTF data and adds them to the scene
  35875. * @param scene the scene the objects should be added to
  35876. * @param data the glTF data to load
  35877. * @param rootUrl root url to load from
  35878. * @param onProgress event that fires when loading progress has occured
  35879. * @returns a promise which completes when objects have been loaded to the scene
  35880. */
  35881. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  35882. private _loadAsync(nodes, scene, data, rootUrl, onProgress?);
  35883. private _loadData(data);
  35884. private _setupData();
  35885. private _loadExtensions();
  35886. private _checkExtensions();
  35887. private _createRootNode();
  35888. private _loadNodesAsync(nodes);
  35889. /** @hidden */
  35890. private _forEachPrimitive(node, callback);
  35891. private _getMeshes();
  35892. private _getSkeletons();
  35893. private _getAnimationGroups();
  35894. private _startAnimations();
  35895. /** @hidden */
  35896. private _loadMeshAsync(context, node, mesh, babylonMesh);
  35897. private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh);
  35898. private _loadVertexDataAsync(context, primitive, babylonMesh);
  35899. private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
  35900. private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry);
  35901. private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget);
  35902. private static _LoadTransform(node, babylonNode);
  35903. private _loadSkinAsync(context, node, mesh, skin);
  35904. private _loadBones(context, skin);
  35905. private _loadBone(node, skin, babylonBones);
  35906. private _loadSkinInverseBindMatricesDataAsync(context, skin);
  35907. private _updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
  35908. private _getNodeMatrix(node);
  35909. private _loadCamera(context, camera, babylonMesh);
  35910. private _loadAnimationsAsync();
  35911. private _loadAnimationAsync(context, animation);
  35912. private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup);
  35913. private _loadAnimationSamplerAsync(context, sampler);
  35914. private _loadBufferAsync(context, buffer);
  35915. /** @hidden */
  35916. private _loadIndicesAccessorAsync(context, accessor);
  35917. private _loadFloatAccessorAsync(context, accessor);
  35918. /** @hidden */
  35919. private _loadVertexAccessorAsync(context, accessor, kind);
  35920. private _getDefaultMaterial(drawMode);
  35921. private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial);
  35922. /** @hidden */
  35923. /** @hidden */
  35924. /** @hidden */
  35925. /** @hidden */
  35926. /** @hidden */
  35927. private _loadSampler(context, sampler);
  35928. private _loadImageAsync(context, image);
  35929. /** @hidden */
  35930. private _onProgress();
  35931. /** @hidden */
  35932. private static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  35933. private static _GetTextureWrapMode(context, mode);
  35934. private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
  35935. private static _GetTypedArray(context, componentType, bufferView, byteOffset, length);
  35936. private static _GetNumComponents(context, type);
  35937. private static _ValidateUri(uri);
  35938. private static _GetDrawMode(context, mode);
  35939. private _compileMaterialsAsync();
  35940. private _compileShadowGeneratorsAsync();
  35941. private _clear();
  35942. /** @hidden */
  35943. }
  35944. }
  35945. declare module BABYLON.GLTF2 {
  35946. /**
  35947. * Abstract class that can be implemented to extend existing glTF loader behavior.
  35948. */
  35949. abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable {
  35950. enabled: boolean;
  35951. readonly abstract name: string;
  35952. protected _loader: GLTFLoader;
  35953. constructor(loader: GLTFLoader);
  35954. dispose(): void;
  35955. /** Override this method to modify the default behavior for loading scenes. */
  35956. protected _loadSceneAsync(context: string, node: _ILoaderScene): Nullable<Promise<void>>;
  35957. /** Override this method to modify the default behavior for loading nodes. */
  35958. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  35959. /** Override this method to modify the default behavior for loading mesh primitive vertex data. */
  35960. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  35961. /** Override this method to modify the default behavior for loading materials. */
  35962. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  35963. /** Override this method to modify the default behavior for loading uris. */
  35964. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  35965. /** Helper method called by a loader extension to load an glTF extension. */
  35966. protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (extensionContext: string, extension: TProperty) => Promise<TResult>): Nullable<Promise<TResult>>;
  35967. /** Helper method called by the loader to allow extensions to override loading scenes. */
  35968. private static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  35969. /** Helper method called by the loader to allow extensions to override loading nodes. */
  35970. private static _LoadNodeAsync(loader: GLTFLoader, context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  35971. /** Helper method called by the loader to allow extensions to override loading mesh primitive vertex data. */
  35972. private static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  35973. /** Helper method called by the loader to allow extensions to override loading materials. */
  35974. private static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: _ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  35975. /** Helper method called by the loader to allow extensions to override loading uris. */
  35976. private static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  35977. }
  35978. }
  35979. /**
  35980. * Defines the module of the glTF 2.0 loader extensions.
  35981. */
  35982. declare module BABYLON.GLTF2.Extensions {
  35983. }
  35984. declare module BABYLON.GLTF2.Extensions {
  35985. /**
  35986. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  35987. */
  35988. class MSFT_lod extends GLTFLoaderExtension {
  35989. readonly name: string;
  35990. /**
  35991. * Maximum number of LODs to load, starting from the lowest LOD.
  35992. */
  35993. maxLODsToLoad: number;
  35994. private _loadingNodeLOD;
  35995. private _loadNodeSignals;
  35996. private _loadingMaterialLOD;
  35997. private _loadMaterialSignals;
  35998. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  35999. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  36000. protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  36001. /**
  36002. * Gets an array of LOD properties from lowest to highest.
  36003. */
  36004. private _getLODs<T>(context, property, array, ids);
  36005. }
  36006. }
  36007. declare module BABYLON.GLTF2.Extensions {
  36008. /** @hidden */
  36009. class MSFT_minecraftMesh extends GLTFLoaderExtension {
  36010. readonly name: string;
  36011. constructor(loader: GLTFLoader);
  36012. private _onMaterialLoaded;
  36013. }
  36014. }
  36015. declare module BABYLON.GLTF2.Extensions {
  36016. /** @hidden */
  36017. class MSFT_sRGBFactors extends GLTFLoaderExtension {
  36018. readonly name: string;
  36019. constructor(loader: GLTFLoader);
  36020. private _onMaterialLoaded;
  36021. }
  36022. }
  36023. declare module BABYLON.GLTF2.Extensions {
  36024. /**
  36025. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  36026. */
  36027. class KHR_draco_mesh_compression extends GLTFLoaderExtension {
  36028. readonly name: string;
  36029. private _dracoCompression;
  36030. constructor(loader: GLTFLoader);
  36031. dispose(): void;
  36032. protected _loadVertexDataAsync(context: string, primitive: _ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  36033. }
  36034. }
  36035. declare module BABYLON.GLTF2.Extensions {
  36036. /**
  36037. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  36038. */
  36039. class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
  36040. readonly name: string;
  36041. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  36042. private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial);
  36043. }
  36044. }
  36045. declare module BABYLON.GLTF2.Extensions {
  36046. /**
  36047. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  36048. */
  36049. class KHR_materials_unlit extends GLTFLoaderExtension {
  36050. readonly name: string;
  36051. protected _loadMaterialAsync(context: string, material: _ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<void>>;
  36052. private _loadUnlitPropertiesAsync(context, material, babylonMaterial);
  36053. }
  36054. }
  36055. declare module BABYLON.GLTF2.Extensions {
  36056. /**
  36057. * [Specification](https://github.com/MiiBond/glTF/tree/khr_lights_v1/extensions/Khronos/KHR_lights) (Experimental)
  36058. */
  36059. class KHR_lights extends GLTFLoaderExtension {
  36060. readonly name: string;
  36061. protected _loadSceneAsync(context: string, scene: _ILoaderScene): Nullable<Promise<void>>;
  36062. protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;
  36063. private readonly _lights;
  36064. }
  36065. }
  36066. declare module BABYLON {
  36067. /**
  36068. * Holds a collection of exporter options and parameters
  36069. */
  36070. interface IExporterOptions {
  36071. /**
  36072. * Function which indicates whether a babylon mesh should be exported or not
  36073. * @param mesh source Babylon mesh. It is used to check whether it should be exported to glTF or not
  36074. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  36075. */
  36076. shouldExportMesh?(mesh: AbstractMesh): boolean;
  36077. /**
  36078. * The sample rate to bake animation curves
  36079. */
  36080. animationSampleRate?: number;
  36081. }
  36082. /**
  36083. * Class for generating glTF data from a Babylon scene.
  36084. */
  36085. class GLTF2Export {
  36086. /**
  36087. * Exports the geometry of the scene to .gltf file format
  36088. * @param scene Babylon scene with scene hierarchy information
  36089. * @param filePrefix File prefix to use when generating the glTF file
  36090. * @param options Exporter options
  36091. * @returns Returns an object with a .gltf file and associates texture names
  36092. * as keys and their data and paths as values
  36093. */
  36094. static GLTF(scene: Scene, filePrefix: string, options?: IExporterOptions): Nullable<GLTFData>;
  36095. /**
  36096. * Exports the geometry of the scene to .glb file format
  36097. * @param scene Babylon scene with scene hierarchy information
  36098. * @param filePrefix File prefix to use when generating glb file
  36099. * @param options Exporter options
  36100. * @returns Returns an object with a .glb filename as key and data as value
  36101. */
  36102. static GLB(scene: Scene, filePrefix: string, options?: IExporterOptions): Nullable<GLTFData>;
  36103. }
  36104. }
  36105. /**
  36106. * Module for the Babylon glTF 2.0 exporter. Should ONLY be used internally
  36107. * @hidden
  36108. */
  36109. declare module BABYLON.GLTF2 {
  36110. /**
  36111. * Converts Babylon Scene into glTF 2.0.
  36112. * @hidden
  36113. */
  36114. class _Exporter {
  36115. /**
  36116. * Stores all generated buffer views, which represents views into the main glTF buffer data
  36117. */
  36118. private bufferViews;
  36119. /**
  36120. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  36121. */
  36122. private accessors;
  36123. /**
  36124. * Stores all the generated nodes, which contains transform and/or mesh information per node
  36125. */
  36126. private nodes;
  36127. /**
  36128. * Stores the glTF asset information, which represents the glTF version and this file generator
  36129. */
  36130. private asset;
  36131. /**
  36132. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  36133. */
  36134. private scenes;
  36135. /**
  36136. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  36137. */
  36138. private meshes;
  36139. /**
  36140. * Stores all the generated material information, which represents the appearance of each primitive
  36141. */
  36142. private materials;
  36143. /**
  36144. * Stores all the generated texture information, which is referenced by glTF materials
  36145. */
  36146. private textures;
  36147. /**
  36148. * Stores all the generated image information, which is referenced by glTF textures
  36149. */
  36150. private images;
  36151. /**
  36152. * Stores all the generated animation samplers, which is referenced by glTF animations
  36153. */
  36154. /**
  36155. * Stores the animations for glTF models
  36156. */
  36157. private animations;
  36158. /**
  36159. * Stores the total amount of bytes stored in the glTF buffer
  36160. */
  36161. private totalByteLength;
  36162. /**
  36163. * Stores a reference to the Babylon scene containing the source geometry and material information
  36164. */
  36165. private babylonScene;
  36166. /**
  36167. * Stores a map of the image data, where the key is the file name and the value
  36168. * is the image data
  36169. */
  36170. private imageData;
  36171. /**
  36172. * Stores a map of the unique id of a node to its index in the node array
  36173. */
  36174. private nodeMap;
  36175. /**
  36176. * Specifies if the Babylon scene should be converted to right-handed on export
  36177. */
  36178. private convertToRightHandedSystem;
  36179. /**
  36180. * Baked animation sample rate
  36181. */
  36182. private animationSampleRate;
  36183. private shouldExportMesh;
  36184. /**
  36185. * Creates a glTF Exporter instance, which can accept optional exporter options
  36186. * @param babylonScene Babylon scene object
  36187. * @param options Options to modify the behavior of the exporter
  36188. */
  36189. constructor(babylonScene: Scene, options?: IExporterOptions);
  36190. /**
  36191. * Writes mesh attribute data to a data buffer
  36192. * Returns the bytelength of the data
  36193. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  36194. * @param meshAttributeArray Array containing the attribute data
  36195. * @param binaryWriter The buffer to write the binary data to
  36196. * @returns Byte length of the attribute data
  36197. */
  36198. private writeAttributeData(vertexBufferKind, meshAttributeArray, binaryWriter);
  36199. /**
  36200. * Generates glTF json data
  36201. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  36202. * @param glTFPrefix Text to use when prefixing a glTF file
  36203. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  36204. * @returns json data as string
  36205. */
  36206. private generateJSON(shouldUseGlb, glTFPrefix?, prettyPrint?);
  36207. /**
  36208. * Generates data for .gltf and .bin files based on the glTF prefix string
  36209. * @param glTFPrefix Text to use when prefixing a glTF file
  36210. * @returns GLTFData with glTF file data
  36211. */
  36212. /**
  36213. * Creates a binary buffer for glTF
  36214. * @returns array buffer for binary data
  36215. */
  36216. private generateBinary();
  36217. /**
  36218. * Pads the number to a multiple of 4
  36219. * @param num number to pad
  36220. * @returns padded number
  36221. */
  36222. private _getPadding(num);
  36223. /**
  36224. * Generates a glb file from the json and binary data
  36225. * Returns an object with the glb file name as the key and data as the value
  36226. * @param glTFPrefix
  36227. * @returns object with glb filename as key and data as value
  36228. */
  36229. /**
  36230. * Sets the TRS for each node
  36231. * @param node glTF Node for storing the transformation data
  36232. * @param babylonMesh Babylon mesh used as the source for the transformation data
  36233. */
  36234. private setNodeTransformation(node, babylonMesh);
  36235. /**
  36236. * Creates a bufferview based on the vertices type for the Babylon mesh
  36237. * @param kind Indicates the type of vertices data
  36238. * @param babylonMesh The Babylon mesh to get the vertices data from
  36239. * @param binaryWriter The buffer to write the bufferview data to
  36240. */
  36241. private createBufferViewKind(kind, babylonMesh, binaryWriter, byteStride);
  36242. /**
  36243. * Sets data for the primitive attributes of each submesh
  36244. * @param mesh glTF Mesh object to store the primitive attribute information
  36245. * @param babylonMesh Babylon mesh to get the primitive attribute data from
  36246. * @param binaryWriter Buffer to write the attribute data to
  36247. */
  36248. private setPrimitiveAttributes(mesh, babylonMesh, binaryWriter);
  36249. /**
  36250. * Creates a glTF scene based on the array of meshes
  36251. * Returns the the total byte offset
  36252. * @param babylonScene Babylon scene to get the mesh data from
  36253. * @param binaryWriter Buffer to write binary data to
  36254. * @returns bytelength + byteoffset
  36255. */
  36256. private createScene(babylonScene, binaryWriter);
  36257. /**
  36258. * Creates a mapping of Node unique id to node index and handles animations
  36259. * @param scene Babylon Scene
  36260. * @param binaryWriter Buffer to write binary data to
  36261. * @returns Node mapping of unique id to index
  36262. */
  36263. private createNodeMapAndAnimations(scene, binaryWriter);
  36264. /**
  36265. * Creates a glTF node from a Babylon mesh
  36266. * @param babylonMesh Source Babylon mesh
  36267. * @param binaryWriter Buffer for storing geometry data
  36268. * @returns glTF node
  36269. */
  36270. private createNode(babylonMesh, binaryWriter);
  36271. }
  36272. /**
  36273. * @hidden
  36274. *
  36275. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  36276. */
  36277. class _BinaryWriter {
  36278. /**
  36279. * Array buffer which stores all binary data
  36280. */
  36281. private _arrayBuffer;
  36282. /**
  36283. * View of the array buffer
  36284. */
  36285. private _dataView;
  36286. /**
  36287. * byte offset of data in array buffer
  36288. */
  36289. private _byteOffset;
  36290. /**
  36291. * Initialize binary writer with an initial byte length
  36292. * @param byteLength Initial byte length of the array buffer
  36293. */
  36294. constructor(byteLength: number);
  36295. /**
  36296. * Resize the array buffer to the specified byte length
  36297. * @param byteLength
  36298. */
  36299. private resizeBuffer(byteLength);
  36300. /**
  36301. * Get an array buffer with the length of the byte offset
  36302. * @returns ArrayBuffer resized to the byte offset
  36303. */
  36304. getArrayBuffer(): ArrayBuffer;
  36305. /**
  36306. * Get the byte offset of the array buffer
  36307. * @returns byte offset
  36308. */
  36309. getByteOffset(): number;
  36310. /**
  36311. * Stores an UInt8 in the array buffer
  36312. * @param entry
  36313. */
  36314. setUInt8(entry: number): void;
  36315. /**
  36316. * Stores a Float32 in the array buffer
  36317. * @param entry
  36318. */
  36319. setFloat32(entry: number): void;
  36320. /**
  36321. * Stores an UInt32 in the array buffer
  36322. * @param entry
  36323. */
  36324. setUInt32(entry: number): void;
  36325. }
  36326. }
  36327. declare module BABYLON {
  36328. /**
  36329. * Class for holding and downloading glTF file data
  36330. */
  36331. class GLTFData {
  36332. /**
  36333. * Object which contains the file name as the key and its data as the value
  36334. */
  36335. glTFFiles: {
  36336. [fileName: string]: string | Blob;
  36337. };
  36338. /**
  36339. * Initializes the glTF file object
  36340. */
  36341. constructor();
  36342. /**
  36343. * Downloads the glTF data as files based on their names and data
  36344. */
  36345. downloadFiles(): void;
  36346. }
  36347. }
  36348. declare module BABYLON.GLTF2 {
  36349. /**
  36350. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  36351. * @hidden
  36352. */
  36353. class _GLTFMaterial {
  36354. /**
  36355. * Represents the dielectric specular values for R, G and B
  36356. */
  36357. private static readonly _dielectricSpecular;
  36358. /**
  36359. * Allows the maximum specular power to be defined for material calculations
  36360. */
  36361. private static _maxSpecularPower;
  36362. /**
  36363. * Numeric tolerance value
  36364. */
  36365. private static _epsilon;
  36366. /**
  36367. * Specifies if two colors are approximately equal in value
  36368. * @param color1 first color to compare to
  36369. * @param color2 second color to compare to
  36370. * @param epsilon threshold value
  36371. */
  36372. private static FuzzyEquals(color1, color2, epsilon);
  36373. /**
  36374. * Gets the materials from a Babylon scene and converts them to glTF materials
  36375. * @param scene babylonjs scene
  36376. * @param mimeType texture mime type
  36377. * @param images array of images
  36378. * @param textures array of textures
  36379. * @param materials array of materials
  36380. * @param imageData mapping of texture names to base64 textures
  36381. * @param hasTextureCoords specifies if texture coordinates are present on the material
  36382. */
  36383. private static _ConvertMaterialsToGLTF(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], materials: IMaterial[], imageData: {
  36384. [fileName: string]: {
  36385. data: Uint8Array;
  36386. mimeType: ImageMimeType;
  36387. };
  36388. }, hasTextureCoords: boolean): void;
  36389. /**
  36390. * Makes a copy of the glTF material without the texture parameters
  36391. * @param originalMaterial original glTF material
  36392. * @returns glTF material without texture parameters
  36393. */
  36394. private static _StripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  36395. /**
  36396. * Specifies if the material has any texture parameters present
  36397. * @param material glTF Material
  36398. * @returns boolean specifying if texture parameters are present
  36399. */
  36400. private static _HasTexturesPresent(material: IMaterial): boolean;
  36401. /**
  36402. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  36403. * @param babylonStandardMaterial
  36404. * @returns glTF Metallic Roughness Material representation
  36405. */
  36406. private static _ConvertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  36407. /**
  36408. * Computes the metallic factor
  36409. * @param diffuse diffused value
  36410. * @param specular specular value
  36411. * @param oneMinusSpecularStrength one minus the specular strength
  36412. * @returns metallic value
  36413. */
  36414. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  36415. /**
  36416. * Gets the glTF alpha mode from the Babylon Material
  36417. * @param babylonMaterial Babylon Material
  36418. * @returns The Babylon alpha mode value
  36419. */
  36420. private static _GetAlphaMode(babylonMaterial: Material): Nullable<MaterialAlphaMode>;
  36421. /**
  36422. * Converts a Babylon Standard Material to a glTF Material
  36423. * @param babylonStandardMaterial BJS Standard Material
  36424. * @param mimeType mime type to use for the textures
  36425. * @param images array of glTF image interfaces
  36426. * @param textures array of glTF texture interfaces
  36427. * @param materials array of glTF material interfaces
  36428. * @param imageData map of image file name to data
  36429. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  36430. */
  36431. private static _ConvertStandardMaterial(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], materials: IMaterial[], imageData: {
  36432. [fileName: string]: {
  36433. data: Uint8Array;
  36434. mimeType: ImageMimeType;
  36435. };
  36436. }, hasTextureCoords: boolean): void;
  36437. /**
  36438. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  36439. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  36440. * @param mimeType mime type to use for the textures
  36441. * @param images array of glTF image interfaces
  36442. * @param textures array of glTF texture interfaces
  36443. * @param materials array of glTF material interfaces
  36444. * @param imageData map of image file name to data
  36445. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  36446. */
  36447. private static _ConvertPBRMetallicRoughnessMaterial(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], materials: IMaterial[], imageData: {
  36448. [fileName: string]: {
  36449. data: Uint8Array;
  36450. mimeType: ImageMimeType;
  36451. };
  36452. }, hasTextureCoords: boolean): void;
  36453. /**
  36454. * Converts an image typed array buffer to a base64 image
  36455. * @param buffer typed array buffer
  36456. * @param width width of the image
  36457. * @param height height of the image
  36458. * @param mimeType mimetype of the image
  36459. * @returns base64 image string
  36460. */
  36461. private static _CreateBase64FromCanvas(buffer, width, height, mimeType);
  36462. /**
  36463. * Generates a white texture based on the specified width and height
  36464. * @param width width of the texture in pixels
  36465. * @param height height of the texture in pixels
  36466. * @param scene babylonjs scene
  36467. * @returns white texture
  36468. */
  36469. private static _CreateWhiteTexture(width, height, scene);
  36470. /**
  36471. * 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
  36472. * @param texture1 first texture to resize
  36473. * @param texture2 second texture to resize
  36474. * @param scene babylonjs scene
  36475. * @returns resized textures or null
  36476. */
  36477. private static _ResizeTexturesToSameDimensions(texture1, texture2, scene);
  36478. /**
  36479. * Convert Specular Glossiness Textures to Metallic Roughness
  36480. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  36481. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  36482. * @param diffuseTexture texture used to store diffuse information
  36483. * @param specularGlossinessTexture texture used to store specular and glossiness information
  36484. * @param factors specular glossiness material factors
  36485. * @param mimeType the mime type to use for the texture
  36486. * @returns pbr metallic roughness interface or null
  36487. */
  36488. private static _ConvertSpecularGlossinessTexturesToMetallicRoughness(diffuseTexture, specularGlossinessTexture, factors, mimeType);
  36489. /**
  36490. * Converts specular glossiness material properties to metallic roughness
  36491. * @param specularGlossiness interface with specular glossiness material properties
  36492. * @returns interface with metallic roughness material properties
  36493. */
  36494. private static _ConvertSpecularGlossinessToMetallicRoughness(specularGlossiness);
  36495. /**
  36496. * Calculates the surface reflectance, independent of lighting conditions
  36497. * @param color Color source to calculate brightness from
  36498. * @returns number representing the perceived brightness, or zero if color is undefined
  36499. */
  36500. private static _GetPerceivedBrightness(color);
  36501. /**
  36502. * Returns the maximum color component value
  36503. * @param color
  36504. * @returns maximum color component value, or zero if color is null or undefined
  36505. */
  36506. private static _GetMaxComponent(color);
  36507. /**
  36508. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  36509. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  36510. * @param mimeType mime type to use for the textures
  36511. * @param images array of glTF image interfaces
  36512. * @param textures array of glTF texture interfaces
  36513. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  36514. * @param imageData map of image file name to data
  36515. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  36516. * @returns glTF PBR Metallic Roughness factors
  36517. */
  36518. private static _ConvertMetalRoughFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  36519. /**
  36520. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  36521. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  36522. * @param mimeType mime type to use for the textures
  36523. * @param images array of glTF image interfaces
  36524. * @param textures array of glTF texture interfaces
  36525. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  36526. * @param imageData map of image file name to data
  36527. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  36528. * @returns glTF PBR Metallic Roughness factors
  36529. */
  36530. private static _ConvertSpecGlossFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
  36531. /**
  36532. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  36533. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  36534. * @param mimeType mime type to use for the textures
  36535. * @param images array of glTF image interfaces
  36536. * @param textures array of glTF texture interfaces
  36537. * @param materials array of glTF material interfaces
  36538. * @param imageData map of image file name to data
  36539. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  36540. */
  36541. private static _ConvertPBRMaterial(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], materials: IMaterial[], imageData: {
  36542. [fileName: string]: {
  36543. data: Uint8Array;
  36544. mimeType: ImageMimeType;
  36545. };
  36546. }, hasTextureCoords: boolean): void;
  36547. private static GetPixelsFromTexture(babylonTexture);
  36548. /**
  36549. * Extracts a texture from a Babylon texture into file data and glTF data
  36550. * @param babylonTexture Babylon texture to extract
  36551. * @param mimeType Mime Type of the babylonTexture
  36552. * @param images Array of glTF images
  36553. * @param textures Array of glTF textures
  36554. * @param imageData map of image file name and data
  36555. * @return glTF texture info, or null if the texture format is not supported
  36556. */
  36557. private static _ExportTexture(babylonTexture, mimeType, images, textures, imageData);
  36558. /**
  36559. * Builds a texture from base64 string
  36560. * @param base64Texture base64 texture string
  36561. * @param textureName Name to use for the texture
  36562. * @param mimeType image mime type for the texture
  36563. * @param images array of images
  36564. * @param textures array of textures
  36565. * @param imageData map of image data
  36566. * @returns glTF texture info, or null if the texture format is not supported
  36567. */
  36568. private static _GetTextureInfoFromBase64(base64Texture, textureName, mimeType, images, textures, imageData);
  36569. }
  36570. }
  36571. declare module BABYLON.GLTF2 {
  36572. /**
  36573. * @hidden
  36574. * Interface to store animation data.
  36575. */
  36576. interface _IAnimationData {
  36577. /**
  36578. * Keyframe data.
  36579. */
  36580. inputs: number[];
  36581. /**
  36582. * Value data.
  36583. */
  36584. outputs: number[][];
  36585. /**
  36586. * Animation interpolation data.
  36587. */
  36588. samplerInterpolation: AnimationSamplerInterpolation;
  36589. /**
  36590. * Minimum keyframe value.
  36591. */
  36592. inputsMin: number;
  36593. /**
  36594. * Maximum keyframe value.
  36595. */
  36596. inputsMax: number;
  36597. }
  36598. /**
  36599. * @hidden
  36600. */
  36601. interface _IAnimationInfo {
  36602. /**
  36603. * The target channel for the animation
  36604. */
  36605. animationChannelTargetPath: AnimationChannelTargetPath;
  36606. /**
  36607. * The glTF accessor type for the data.
  36608. */
  36609. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  36610. /**
  36611. * Specifies if quaternions should be used.
  36612. */
  36613. useQuaternion: boolean;
  36614. }
  36615. /**
  36616. * @hidden
  36617. * Utility class for generating glTF animation data from BabylonJS.
  36618. */
  36619. class _GLTFAnimation {
  36620. /**
  36621. *
  36622. * Creates glTF channel animation from BabylonJS animation.
  36623. * @param babylonMesh - BabylonJS mesh.
  36624. * @param animation - animation.
  36625. * @param animationChannelTargetPath - The target animation channel.
  36626. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  36627. * @param useQuaternion - Specifies if quaternions are used.
  36628. * @returns nullable IAnimationData
  36629. */
  36630. private static _CreateNodeAnimation(babylonMesh: BABYLON.Mesh, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  36631. private static _DeduceAnimationInfo(animation);
  36632. /**
  36633. *
  36634. * @param babylonMesh
  36635. * @param runtimeGLTFAnimation
  36636. * @param idleGLTFAnimations
  36637. * @param nodeMap
  36638. * @param nodes
  36639. * @param binaryWriter
  36640. * @param bufferViews
  36641. * @param accessors
  36642. * @param convertToRightHandedSystem
  36643. */
  36644. private static _CreateNodeAnimationFromMeshAnimations(babylonMesh: Mesh, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  36645. [key: number]: number;
  36646. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  36647. /**
  36648. *
  36649. * @param babylonScene
  36650. * @param glTFAnimations
  36651. * @param nodeMap
  36652. * @param nodes
  36653. * @param binaryWriter
  36654. * @param bufferViews
  36655. * @param accessors
  36656. * @param convertToRightHandedSystem
  36657. */
  36658. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  36659. [key: number]: number;
  36660. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  36661. private static AddAnimation(name, glTFAnimation, babylonMesh, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, useQuaternion, animationSampleRate);
  36662. /**
  36663. * Create a baked animation
  36664. * @param babylonMesh BabylonJS mesh
  36665. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  36666. * @param animationChannelTargetPath animation target channel
  36667. * @param minFrame minimum animation frame
  36668. * @param maxFrame maximum animation frame
  36669. * @param fps frames per second of the animation
  36670. * @param inputs input key frames of the animation
  36671. * @param outputs output key frame data of the animation
  36672. * @param convertToRightHandedSystem converts the values to right-handed
  36673. * @param useQuaternion specifies if quaternions should be used
  36674. */
  36675. private static _CreateBakedAnimation(babylonMesh, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, convertToRightHandedSystem, useQuaternion);
  36676. private static _ConvertFactorToVector3OrQuaternion(factor, babylonMesh, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  36677. private static _SetInterpolatedValue(babylonMesh, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  36678. /**
  36679. * Creates linear animation from the animation key frames
  36680. * @param babylonMesh BabylonJS mesh
  36681. * @param animation BabylonJS animation
  36682. * @param animationChannelTargetPath The target animation channel
  36683. * @param frameDelta The difference between the last and first frame of the animation
  36684. * @param inputs Array to store the key frame times
  36685. * @param outputs Array to store the key frame data
  36686. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  36687. * @param useQuaternion Specifies if quaternions are used in the animation
  36688. */
  36689. private static _CreateLinearOrStepAnimation(babylonMesh, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  36690. /**
  36691. * Creates cubic spline animation from the animation key frames
  36692. * @param babylonMesh BabylonJS mesh
  36693. * @param animation BabylonJS animation
  36694. * @param animationChannelTargetPath The target animation channel
  36695. * @param frameDelta The difference between the last and first frame of the animation
  36696. * @param inputs Array to store the key frame times
  36697. * @param outputs Array to store the key frame data
  36698. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  36699. * @param useQuaternion Specifies if quaternions are used in the animation
  36700. */
  36701. private static _CreateCubicSplineAnimation(babylonMesh, animation, animationChannelTargetPath, frameDelta, inputs, outputs, convertToRightHandedSystem, useQuaternion);
  36702. private static _GetBasePositionRotationOrScale(babylonMesh, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
  36703. /**
  36704. * Adds a key frame value
  36705. * @param keyFrame
  36706. * @param animation
  36707. * @param outputs
  36708. * @param animationChannelTargetPath
  36709. * @param basePositionRotationOrScale
  36710. * @param convertToRightHandedSystem
  36711. * @param useQuaternion
  36712. */
  36713. private static _AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonMesh, convertToRightHandedSystem, useQuaternion);
  36714. private static _DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion);
  36715. /**
  36716. * Adds an input tangent or output tangent to the output data
  36717. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  36718. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  36719. * @param outputs The animation data by keyframe
  36720. * @param animationChannelTargetPath The target animation channel
  36721. * @param interpolation The interpolation type
  36722. * @param keyFrame The key frame with the animation data
  36723. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  36724. * @param useQuaternion Specifies if quaternions are used
  36725. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  36726. */
  36727. private static AddSplineTangent(tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, frameDelta, useQuaternion, convertToRightHandedSystem);
  36728. /**
  36729. * Get the minimum and maximum key frames' frame values
  36730. * @param keyFrames animation key frames
  36731. * @returns the minimum and maximum key frame value
  36732. */
  36733. private static calculateMinMaxKeyFrames(keyFrames);
  36734. }
  36735. }
  36736. declare module BABYLON.GLTF2 {
  36737. /**
  36738. * @hidden
  36739. */
  36740. class _GLTFUtilities {
  36741. /**
  36742. * Creates a buffer view based on the supplied arguments
  36743. * @param bufferIndex index value of the specified buffer
  36744. * @param byteOffset byte offset value
  36745. * @param byteLength byte length of the bufferView
  36746. * @param byteStride byte distance between conequential elements
  36747. * @param name name of the buffer view
  36748. * @returns bufferView for glTF
  36749. */
  36750. static CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  36751. /**
  36752. * Creates an accessor based on the supplied arguments
  36753. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  36754. * @param name The name of the accessor
  36755. * @param type The type of the accessor
  36756. * @param componentType The datatype of components in the attribute
  36757. * @param count The number of attributes referenced by this accessor
  36758. * @param byteOffset The offset relative to the start of the bufferView in bytes
  36759. * @param min Minimum value of each component in this attribute
  36760. * @param max Maximum value of each component in this attribute
  36761. * @returns accessor for glTF
  36762. */
  36763. static CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  36764. /**
  36765. * Calculates the minimum and maximum values of an array of position floats
  36766. * @param positions Positions array of a mesh
  36767. * @param vertexStart Starting vertex offset to calculate min and max values
  36768. * @param vertexCount Number of vertices to check for min and max values
  36769. * @returns min number array and max number array
  36770. */
  36771. static CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  36772. min: number[];
  36773. max: number[];
  36774. };
  36775. /**
  36776. * Converts a new right-handed Vector3
  36777. * @param vector vector3 array
  36778. * @returns right-handed Vector3
  36779. */
  36780. static GetRightHandedVector3(vector: Vector3): Vector3;
  36781. /**
  36782. * Converts a Vector3 to right-handed
  36783. * @param vector Vector3 to convert to right-handed
  36784. */
  36785. static GetRightHandedVector3FromRef(vector: Vector3): void;
  36786. /**
  36787. * Converts a Vector4 to right-handed
  36788. * @param vector Vector4 to convert to right-handed
  36789. */
  36790. static GetRightHandedVector4FromRef(vector: Vector4): void;
  36791. /**
  36792. * Converts a Quaternion to right-handed
  36793. * @param quaternion Source quaternion to convert to right-handed
  36794. */
  36795. static GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  36796. }
  36797. }
  36798. /**
  36799. * @ignoreChildren
  36800. * @ignore
  36801. */
  36802. declare module "babylonjs-gltf2interface" {
  36803. export = BABYLON.GLTF2;
  36804. }
  36805. /**
  36806. * Moduel for glTF 2.0 Interface
  36807. */
  36808. declare module BABYLON.GLTF2 {
  36809. /**
  36810. * The datatype of the components in the attribute
  36811. */
  36812. const enum AccessorComponentType {
  36813. /**
  36814. * Byte
  36815. */
  36816. BYTE = 5120,
  36817. /**
  36818. * Unsigned Byte
  36819. */
  36820. UNSIGNED_BYTE = 5121,
  36821. /**
  36822. * Short
  36823. */
  36824. SHORT = 5122,
  36825. /**
  36826. * Unsigned Short
  36827. */
  36828. UNSIGNED_SHORT = 5123,
  36829. /**
  36830. * Unsigned Int
  36831. */
  36832. UNSIGNED_INT = 5125,
  36833. /**
  36834. * Float
  36835. */
  36836. FLOAT = 5126,
  36837. }
  36838. /**
  36839. * Specifies if the attirbute is a scalar, vector, or matrix
  36840. */
  36841. const enum AccessorType {
  36842. /**
  36843. * Scalar
  36844. */
  36845. SCALAR = "SCALAR",
  36846. /**
  36847. * Vector2
  36848. */
  36849. VEC2 = "VEC2",
  36850. /**
  36851. * Vector3
  36852. */
  36853. VEC3 = "VEC3",
  36854. /**
  36855. * Vector4
  36856. */
  36857. VEC4 = "VEC4",
  36858. /**
  36859. * Matrix2x2
  36860. */
  36861. MAT2 = "MAT2",
  36862. /**
  36863. * Matrix3x3
  36864. */
  36865. MAT3 = "MAT3",
  36866. /**
  36867. * Matrix4x4
  36868. */
  36869. MAT4 = "MAT4",
  36870. }
  36871. /**
  36872. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  36873. */
  36874. const enum AnimationChannelTargetPath {
  36875. /**
  36876. * Translation
  36877. */
  36878. TRANSLATION = "translation",
  36879. /**
  36880. * Rotation
  36881. */
  36882. ROTATION = "rotation",
  36883. /**
  36884. * Scale
  36885. */
  36886. SCALE = "scale",
  36887. /**
  36888. * Weights
  36889. */
  36890. WEIGHTS = "weights",
  36891. }
  36892. /**
  36893. * Interpolation algorithm
  36894. */
  36895. const enum AnimationSamplerInterpolation {
  36896. /**
  36897. * The animated values are linearly interpolated between keyframes
  36898. */
  36899. LINEAR = "LINEAR",
  36900. /**
  36901. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  36902. */
  36903. STEP = "STEP",
  36904. /**
  36905. * The animation's interpolation is computed using a cubic spline with specified tangents
  36906. */
  36907. CUBICSPLINE = "CUBICSPLINE",
  36908. }
  36909. /**
  36910. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  36911. */
  36912. const enum CameraType {
  36913. /**
  36914. * A perspective camera containing properties to create a perspective projection matrix
  36915. */
  36916. PERSPECTIVE = "perspective",
  36917. /**
  36918. * An orthographic camera containing properties to create an orthographic projection matrix
  36919. */
  36920. ORTHOGRAPHIC = "orthographic",
  36921. }
  36922. /**
  36923. * The mime-type of the image
  36924. */
  36925. const enum ImageMimeType {
  36926. /**
  36927. * JPEG Mime-type
  36928. */
  36929. JPEG = "image/jpeg",
  36930. /**
  36931. * PNG Mime-type
  36932. */
  36933. PNG = "image/png",
  36934. }
  36935. /**
  36936. * The alpha rendering mode of the material
  36937. */
  36938. const enum MaterialAlphaMode {
  36939. /**
  36940. * The alpha value is ignored and the rendered output is fully opaque
  36941. */
  36942. OPAQUE = "OPAQUE",
  36943. /**
  36944. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  36945. */
  36946. MASK = "MASK",
  36947. /**
  36948. * 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)
  36949. */
  36950. BLEND = "BLEND",
  36951. }
  36952. /**
  36953. * The type of the primitives to render
  36954. */
  36955. const enum MeshPrimitiveMode {
  36956. /**
  36957. * Points
  36958. */
  36959. POINTS = 0,
  36960. /**
  36961. * Lines
  36962. */
  36963. LINES = 1,
  36964. /**
  36965. * Line Loop
  36966. */
  36967. LINE_LOOP = 2,
  36968. /**
  36969. * Line Strip
  36970. */
  36971. LINE_STRIP = 3,
  36972. /**
  36973. * Triangles
  36974. */
  36975. TRIANGLES = 4,
  36976. /**
  36977. * Triangle Strip
  36978. */
  36979. TRIANGLE_STRIP = 5,
  36980. /**
  36981. * Triangle Fan
  36982. */
  36983. TRIANGLE_FAN = 6,
  36984. }
  36985. /**
  36986. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  36987. */
  36988. const enum TextureMagFilter {
  36989. /**
  36990. * Nearest
  36991. */
  36992. NEAREST = 9728,
  36993. /**
  36994. * Linear
  36995. */
  36996. LINEAR = 9729,
  36997. }
  36998. /**
  36999. * Minification filter. All valid values correspond to WebGL enums
  37000. */
  37001. const enum TextureMinFilter {
  37002. /**
  37003. * Nearest
  37004. */
  37005. NEAREST = 9728,
  37006. /**
  37007. * Linear
  37008. */
  37009. LINEAR = 9729,
  37010. /**
  37011. * Nearest Mip-Map Nearest
  37012. */
  37013. NEAREST_MIPMAP_NEAREST = 9984,
  37014. /**
  37015. * Linear Mipmap Nearest
  37016. */
  37017. LINEAR_MIPMAP_NEAREST = 9985,
  37018. /**
  37019. * Nearest Mipmap Linear
  37020. */
  37021. NEAREST_MIPMAP_LINEAR = 9986,
  37022. /**
  37023. * Linear Mipmap Linear
  37024. */
  37025. LINEAR_MIPMAP_LINEAR = 9987,
  37026. }
  37027. /**
  37028. * S (U) wrapping mode. All valid values correspond to WebGL enums
  37029. */
  37030. const enum TextureWrapMode {
  37031. /**
  37032. * Clamp to Edge
  37033. */
  37034. CLAMP_TO_EDGE = 33071,
  37035. /**
  37036. * Mirrored Repeat
  37037. */
  37038. MIRRORED_REPEAT = 33648,
  37039. /**
  37040. * Repeat
  37041. */
  37042. REPEAT = 10497,
  37043. }
  37044. /**
  37045. * glTF Property
  37046. */
  37047. interface IProperty {
  37048. /**
  37049. * Dictionary object with extension-specific objects
  37050. */
  37051. extensions?: {
  37052. [key: string]: any;
  37053. };
  37054. /**
  37055. * Application-Specific data
  37056. */
  37057. extras?: any;
  37058. }
  37059. /**
  37060. * glTF Child of Root Property
  37061. */
  37062. interface IChildRootProperty extends IProperty {
  37063. /**
  37064. * The user-defined name of this object
  37065. */
  37066. name?: string;
  37067. }
  37068. /**
  37069. * Indices of those attributes that deviate from their initialization value
  37070. */
  37071. interface IAccessorSparseIndices extends IProperty {
  37072. /**
  37073. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  37074. */
  37075. bufferView: number;
  37076. /**
  37077. * The offset relative to the start of the bufferView in bytes. Must be aligned
  37078. */
  37079. byteOffset?: number;
  37080. /**
  37081. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  37082. */
  37083. componentType: AccessorComponentType;
  37084. }
  37085. /**
  37086. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  37087. */
  37088. interface IAccessorSparseValues extends IProperty {
  37089. /**
  37090. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  37091. */
  37092. bufferView: number;
  37093. /**
  37094. * The offset relative to the start of the bufferView in bytes. Must be aligned
  37095. */
  37096. byteOffset?: number;
  37097. }
  37098. /**
  37099. * Sparse storage of attributes that deviate from their initialization value
  37100. */
  37101. interface IAccessorSparse extends IProperty {
  37102. /**
  37103. * The number of attributes encoded in this sparse accessor
  37104. */
  37105. count: number;
  37106. /**
  37107. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  37108. */
  37109. indices: IAccessorSparseIndices;
  37110. /**
  37111. * 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
  37112. */
  37113. values: IAccessorSparseValues;
  37114. }
  37115. /**
  37116. * 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
  37117. */
  37118. interface IAccessor extends IChildRootProperty {
  37119. /**
  37120. * The index of the bufferview
  37121. */
  37122. bufferView?: number;
  37123. /**
  37124. * The offset relative to the start of the bufferView in bytes
  37125. */
  37126. byteOffset?: number;
  37127. /**
  37128. * The datatype of components in the attribute
  37129. */
  37130. componentType: AccessorComponentType;
  37131. /**
  37132. * Specifies whether integer data values should be normalized
  37133. */
  37134. normalized?: boolean;
  37135. /**
  37136. * The number of attributes referenced by this accessor
  37137. */
  37138. count: number;
  37139. /**
  37140. * Specifies if the attribute is a scalar, vector, or matrix
  37141. */
  37142. type: AccessorType;
  37143. /**
  37144. * Maximum value of each component in this attribute
  37145. */
  37146. max?: number[];
  37147. /**
  37148. * Minimum value of each component in this attribute
  37149. */
  37150. min?: number[];
  37151. /**
  37152. * Sparse storage of attributes that deviate from their initialization value
  37153. */
  37154. sparse?: IAccessorSparse;
  37155. }
  37156. /**
  37157. * Targets an animation's sampler at a node's property
  37158. */
  37159. interface IAnimationChannel extends IProperty {
  37160. /**
  37161. * The index of a sampler in this animation used to compute the value for the target
  37162. */
  37163. sampler: number;
  37164. /**
  37165. * The index of the node and TRS property to target
  37166. */
  37167. target: IAnimationChannelTarget;
  37168. }
  37169. /**
  37170. * The index of the node and TRS property that an animation channel targets
  37171. */
  37172. interface IAnimationChannelTarget extends IProperty {
  37173. /**
  37174. * The index of the node to target
  37175. */
  37176. node: number;
  37177. /**
  37178. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  37179. */
  37180. path: AnimationChannelTargetPath;
  37181. }
  37182. /**
  37183. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  37184. */
  37185. interface IAnimationSampler extends IProperty {
  37186. /**
  37187. * The index of an accessor containing keyframe input values, e.g., time
  37188. */
  37189. input: number;
  37190. /**
  37191. * Interpolation algorithm
  37192. */
  37193. interpolation?: AnimationSamplerInterpolation;
  37194. /**
  37195. * The index of an accessor, containing keyframe output values
  37196. */
  37197. output: number;
  37198. }
  37199. /**
  37200. * A keyframe animation
  37201. */
  37202. interface IAnimation extends IChildRootProperty {
  37203. /**
  37204. * An array of channels, each of which targets an animation's sampler at a node's property
  37205. */
  37206. channels: IAnimationChannel[];
  37207. /**
  37208. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  37209. */
  37210. samplers: IAnimationSampler[];
  37211. }
  37212. /**
  37213. * Metadata about the glTF asset
  37214. */
  37215. interface IAsset extends IChildRootProperty {
  37216. /**
  37217. * A copyright message suitable for display to credit the content creator
  37218. */
  37219. copyright?: string;
  37220. /**
  37221. * Tool that generated this glTF model. Useful for debugging
  37222. */
  37223. generator?: string;
  37224. /**
  37225. * The glTF version that this asset targets
  37226. */
  37227. version: string;
  37228. /**
  37229. * The minimum glTF version that this asset targets
  37230. */
  37231. minVersion?: string;
  37232. }
  37233. /**
  37234. * A buffer points to binary geometry, animation, or skins
  37235. */
  37236. interface IBuffer extends IChildRootProperty {
  37237. /**
  37238. * 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
  37239. */
  37240. uri?: string;
  37241. /**
  37242. * The length of the buffer in bytes
  37243. */
  37244. byteLength: number;
  37245. }
  37246. /**
  37247. * A view into a buffer generally representing a subset of the buffer
  37248. */
  37249. interface IBufferView extends IChildRootProperty {
  37250. /**
  37251. * The index of the buffer
  37252. */
  37253. buffer: number;
  37254. /**
  37255. * The offset into the buffer in bytes
  37256. */
  37257. byteOffset?: number;
  37258. /**
  37259. * The lenth of the bufferView in bytes
  37260. */
  37261. byteLength: number;
  37262. /**
  37263. * The stride, in bytes
  37264. */
  37265. byteStride?: number;
  37266. }
  37267. /**
  37268. * An orthographic camera containing properties to create an orthographic projection matrix
  37269. */
  37270. interface ICameraOrthographic extends IProperty {
  37271. /**
  37272. * The floating-point horizontal magnification of the view. Must not be zero
  37273. */
  37274. xmag: number;
  37275. /**
  37276. * The floating-point vertical magnification of the view. Must not be zero
  37277. */
  37278. ymag: number;
  37279. /**
  37280. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  37281. */
  37282. zfar: number;
  37283. /**
  37284. * The floating-point distance to the near clipping plane
  37285. */
  37286. znear: number;
  37287. }
  37288. /**
  37289. * A perspective camera containing properties to create a perspective projection matrix
  37290. */
  37291. interface ICameraPerspective extends IProperty {
  37292. /**
  37293. * The floating-point aspect ratio of the field of view
  37294. */
  37295. aspectRatio?: number;
  37296. /**
  37297. * The floating-point vertical field of view in radians
  37298. */
  37299. yfov: number;
  37300. /**
  37301. * The floating-point distance to the far clipping plane
  37302. */
  37303. zfar?: number;
  37304. /**
  37305. * The floating-point distance to the near clipping plane
  37306. */
  37307. znear: number;
  37308. }
  37309. /**
  37310. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  37311. */
  37312. interface ICamera extends IChildRootProperty {
  37313. /**
  37314. * An orthographic camera containing properties to create an orthographic projection matrix
  37315. */
  37316. orthographic?: ICameraOrthographic;
  37317. /**
  37318. * A perspective camera containing properties to create a perspective projection matrix
  37319. */
  37320. perspective?: ICameraPerspective;
  37321. /**
  37322. * Specifies if the camera uses a perspective or orthographic projection
  37323. */
  37324. type: CameraType;
  37325. }
  37326. /**
  37327. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  37328. */
  37329. interface IImage extends IChildRootProperty {
  37330. /**
  37331. * 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
  37332. */
  37333. uri?: string;
  37334. /**
  37335. * The image's MIME type
  37336. */
  37337. mimeType?: ImageMimeType;
  37338. /**
  37339. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  37340. */
  37341. bufferView?: number;
  37342. }
  37343. /**
  37344. * Material Normal Texture Info
  37345. */
  37346. interface IMaterialNormalTextureInfo extends ITextureInfo {
  37347. /**
  37348. * The scalar multiplier applied to each normal vector of the normal texture
  37349. */
  37350. scale?: number;
  37351. }
  37352. /**
  37353. * Material Occlusion Texture Info
  37354. */
  37355. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  37356. /**
  37357. * A scalar multiplier controlling the amount of occlusion applied
  37358. */
  37359. strength?: number;
  37360. }
  37361. /**
  37362. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  37363. */
  37364. interface IMaterialPbrMetallicRoughness {
  37365. /**
  37366. * The material's base color factor
  37367. */
  37368. baseColorFactor?: number[];
  37369. /**
  37370. * The base color texture
  37371. */
  37372. baseColorTexture?: ITextureInfo;
  37373. /**
  37374. * The metalness of the material
  37375. */
  37376. metallicFactor?: number;
  37377. /**
  37378. * The roughness of the material
  37379. */
  37380. roughnessFactor?: number;
  37381. /**
  37382. * The metallic-roughness texture
  37383. */
  37384. metallicRoughnessTexture?: ITextureInfo;
  37385. }
  37386. /**
  37387. * The material appearance of a primitive
  37388. */
  37389. interface IMaterial extends IChildRootProperty {
  37390. /**
  37391. * 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
  37392. */
  37393. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  37394. /**
  37395. * The normal map texture
  37396. */
  37397. normalTexture?: IMaterialNormalTextureInfo;
  37398. /**
  37399. * The occlusion map texture
  37400. */
  37401. occlusionTexture?: IMaterialOcclusionTextureInfo;
  37402. /**
  37403. * The emissive map texture
  37404. */
  37405. emissiveTexture?: ITextureInfo;
  37406. /**
  37407. * 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
  37408. */
  37409. emissiveFactor?: number[];
  37410. /**
  37411. * The alpha rendering mode of the material
  37412. */
  37413. alphaMode?: MaterialAlphaMode;
  37414. /**
  37415. * The alpha cutoff value of the material
  37416. */
  37417. alphaCutoff?: number;
  37418. /**
  37419. * Specifies whether the material is double sided
  37420. */
  37421. doubleSided?: boolean;
  37422. }
  37423. /**
  37424. * Geometry to be rendered with the given material
  37425. */
  37426. interface IMeshPrimitive extends IProperty {
  37427. /**
  37428. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  37429. */
  37430. attributes: {
  37431. [name: string]: number;
  37432. };
  37433. /**
  37434. * The index of the accessor that contains the indices
  37435. */
  37436. indices?: number;
  37437. /**
  37438. * The index of the material to apply to this primitive when rendering
  37439. */
  37440. material?: number;
  37441. /**
  37442. * The type of primitives to render. All valid values correspond to WebGL enums
  37443. */
  37444. mode?: MeshPrimitiveMode;
  37445. /**
  37446. * 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
  37447. */
  37448. targets?: {
  37449. [name: string]: number;
  37450. }[];
  37451. }
  37452. /**
  37453. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  37454. */
  37455. interface IMesh extends IChildRootProperty {
  37456. /**
  37457. * An array of primitives, each defining geometry to be rendered with a material
  37458. */
  37459. primitives: IMeshPrimitive[];
  37460. /**
  37461. * Array of weights to be applied to the Morph Targets
  37462. */
  37463. weights?: number[];
  37464. }
  37465. /**
  37466. * A node in the node hierarchy
  37467. */
  37468. interface INode extends IChildRootProperty {
  37469. /**
  37470. * The index of the camera referenced by this node
  37471. */
  37472. camera?: number;
  37473. /**
  37474. * The indices of this node's children
  37475. */
  37476. children?: number[];
  37477. /**
  37478. * The index of the skin referenced by this node
  37479. */
  37480. skin?: number;
  37481. /**
  37482. * A floating-point 4x4 transformation matrix stored in column-major order
  37483. */
  37484. matrix?: number[];
  37485. /**
  37486. * The index of the mesh in this node
  37487. */
  37488. mesh?: number;
  37489. /**
  37490. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  37491. */
  37492. rotation?: number[];
  37493. /**
  37494. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  37495. */
  37496. scale?: number[];
  37497. /**
  37498. * The node's translation along the x, y, and z axes
  37499. */
  37500. translation?: number[];
  37501. /**
  37502. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  37503. */
  37504. weights?: number[];
  37505. }
  37506. /**
  37507. * Texture sampler properties for filtering and wrapping modes
  37508. */
  37509. interface ISampler extends IChildRootProperty {
  37510. /**
  37511. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  37512. */
  37513. magFilter?: TextureMagFilter;
  37514. /**
  37515. * Minification filter. All valid values correspond to WebGL enums
  37516. */
  37517. minFilter?: TextureMinFilter;
  37518. /**
  37519. * S (U) wrapping mode. All valid values correspond to WebGL enums
  37520. */
  37521. wrapS?: TextureWrapMode;
  37522. /**
  37523. * T (V) wrapping mode. All valid values correspond to WebGL enums
  37524. */
  37525. wrapT?: TextureWrapMode;
  37526. }
  37527. /**
  37528. * The root nodes of a scene
  37529. */
  37530. interface IScene extends IChildRootProperty {
  37531. /**
  37532. * The indices of each root node
  37533. */
  37534. nodes: number[];
  37535. }
  37536. /**
  37537. * Joints and matrices defining a skin
  37538. */
  37539. interface ISkin extends IChildRootProperty {
  37540. /**
  37541. * 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
  37542. */
  37543. inverseBindMatrices?: number;
  37544. /**
  37545. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  37546. */
  37547. skeleton?: number;
  37548. /**
  37549. * 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)
  37550. */
  37551. joints: number[];
  37552. }
  37553. /**
  37554. * A texture and its sampler
  37555. */
  37556. interface ITexture extends IChildRootProperty {
  37557. /**
  37558. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  37559. */
  37560. sampler?: number;
  37561. /**
  37562. * The index of the image used by this texture
  37563. */
  37564. source: number;
  37565. }
  37566. /**
  37567. * Reference to a texture
  37568. */
  37569. interface ITextureInfo {
  37570. /**
  37571. * The index of the texture
  37572. */
  37573. index: number;
  37574. /**
  37575. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  37576. */
  37577. texCoord?: number;
  37578. }
  37579. /**
  37580. * The root object for a glTF asset
  37581. */
  37582. interface IGLTF extends IProperty {
  37583. /**
  37584. * An array of accessors. An accessor is a typed view into a bufferView
  37585. */
  37586. accessors?: IAccessor[];
  37587. /**
  37588. * An array of keyframe animations
  37589. */
  37590. animations?: IAnimation[];
  37591. /**
  37592. * Metadata about the glTF asset
  37593. */
  37594. asset: IAsset;
  37595. /**
  37596. * An array of buffers. A buffer points to binary geometry, animation, or skins
  37597. */
  37598. buffers?: IBuffer[];
  37599. /**
  37600. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  37601. */
  37602. bufferViews?: IBufferView[];
  37603. /**
  37604. * An array of cameras
  37605. */
  37606. cameras?: ICamera[];
  37607. /**
  37608. * Names of glTF extensions used somewhere in this asset
  37609. */
  37610. extensionsUsed?: string[];
  37611. /**
  37612. * Names of glTF extensions required to properly load this asset
  37613. */
  37614. extensionsRequired?: string[];
  37615. /**
  37616. * An array of images. An image defines data used to create a texture
  37617. */
  37618. images?: IImage[];
  37619. /**
  37620. * An array of materials. A material defines the appearance of a primitive
  37621. */
  37622. materials?: IMaterial[];
  37623. /**
  37624. * An array of meshes. A mesh is a set of primitives to be rendered
  37625. */
  37626. meshes?: IMesh[];
  37627. /**
  37628. * An array of nodes
  37629. */
  37630. nodes?: INode[];
  37631. /**
  37632. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  37633. */
  37634. samplers?: ISampler[];
  37635. /**
  37636. * The index of the default scene
  37637. */
  37638. scene?: number;
  37639. /**
  37640. * An array of scenes
  37641. */
  37642. scenes?: IScene[];
  37643. /**
  37644. * An array of skins. A skin is defined by joints and matrices
  37645. */
  37646. skins?: ISkin[];
  37647. /**
  37648. * An array of textures
  37649. */
  37650. textures?: ITexture[];
  37651. }
  37652. }