babylon.d.txt 1.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Sounds to keep.
  127. */
  128. sounds: Sound[];
  129. /**
  130. * Textures to keep.
  131. */
  132. textures: BaseTexture[];
  133. }
  134. }
  135. declare module BABYLON {
  136. /**
  137. * Set of assets to keep when moving a scene into an asset container.
  138. */
  139. class KeepAssets extends AbstractScene {
  140. }
  141. /**
  142. * Container with a set of assets that can be added or removed from a scene.
  143. */
  144. class AssetContainer extends AbstractScene {
  145. /**
  146. * The scene the AssetContainer belongs to.
  147. */
  148. scene: Scene;
  149. /**
  150. * Instantiates an AssetContainer.
  151. * @param scene The scene the AssetContainer belongs to.
  152. */
  153. constructor(scene: Scene);
  154. /**
  155. * Adds all the assets from the container to the scene.
  156. */
  157. addAllToScene(): void;
  158. /**
  159. * Removes all the assets in the container from the scene
  160. */
  161. removeAllFromScene(): void;
  162. private _moveAssets;
  163. /**
  164. * Removes all the assets contained in the scene and adds them to the container.
  165. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  166. */
  167. moveAllFromScene(keepAssets?: KeepAssets): void;
  168. /**
  169. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  170. * @returns the root mesh
  171. */
  172. createRootMesh(): Mesh;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. R16F: number;
  226. RG16F: number;
  227. RGB16F: number;
  228. RED: number;
  229. RG: number;
  230. R8: number;
  231. RG8: number;
  232. UNSIGNED_INT_24_8: number;
  233. DEPTH24_STENCIL8: number;
  234. drawBuffers(buffers: number[]): void;
  235. readBuffer(src: number): void;
  236. readonly COLOR_ATTACHMENT0: number;
  237. readonly COLOR_ATTACHMENT1: number;
  238. readonly COLOR_ATTACHMENT2: number;
  239. readonly COLOR_ATTACHMENT3: number;
  240. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  241. ANY_SAMPLES_PASSED: number;
  242. QUERY_RESULT_AVAILABLE: number;
  243. QUERY_RESULT: number;
  244. }
  245. interface Document {
  246. mozCancelFullScreen(): void;
  247. msCancelFullScreen(): void;
  248. mozFullScreen: boolean;
  249. msIsFullScreen: boolean;
  250. fullscreen: boolean;
  251. mozPointerLockElement: HTMLElement;
  252. msPointerLockElement: HTMLElement;
  253. webkitPointerLockElement: HTMLElement;
  254. }
  255. interface HTMLCanvasElement {
  256. msRequestPointerLock?(): void;
  257. mozRequestPointerLock?(): void;
  258. webkitRequestPointerLock?(): void;
  259. }
  260. interface CanvasRenderingContext2D {
  261. msImageSmoothingEnabled: boolean;
  262. }
  263. interface WebGLBuffer {
  264. references: number;
  265. capacity: number;
  266. is32Bits: boolean;
  267. }
  268. interface WebGLProgram {
  269. transformFeedback?: WebGLTransformFeedback | null;
  270. }
  271. interface MouseEvent {
  272. mozMovementX: number;
  273. mozMovementY: number;
  274. webkitMovementX: number;
  275. webkitMovementY: number;
  276. msMovementX: number;
  277. msMovementY: number;
  278. }
  279. interface Navigator {
  280. mozGetVRDevices: (any: any) => any;
  281. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  282. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  283. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  284. webkitGetGamepads(): Gamepad[];
  285. msGetGamepads(): Gamepad[];
  286. webkitGamepads(): Gamepad[];
  287. }
  288. interface HTMLVideoElement {
  289. mozSrcObject: any;
  290. }
  291. interface Screen {
  292. orientation: string;
  293. mozOrientation: string;
  294. }
  295. interface Math {
  296. fround(x: number): number;
  297. imul(a: number, b: number): number;
  298. }
  299. interface EXT_disjoint_timer_query {
  300. QUERY_COUNTER_BITS_EXT: number;
  301. TIME_ELAPSED_EXT: number;
  302. TIMESTAMP_EXT: number;
  303. GPU_DISJOINT_EXT: number;
  304. QUERY_RESULT_EXT: number;
  305. QUERY_RESULT_AVAILABLE_EXT: number;
  306. queryCounterEXT(query: WebGLQuery, target: number): void;
  307. createQueryEXT(): WebGLQuery;
  308. beginQueryEXT(target: number, query: WebGLQuery): void;
  309. endQueryEXT(target: number): void;
  310. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  311. deleteQueryEXT(query: WebGLQuery): void;
  312. }
  313. interface WebGLUniformLocation {
  314. }
  315. declare module BABYLON {
  316. /**
  317. * Defines how a node can be built from a string name.
  318. */
  319. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  320. /**
  321. * Node is the basic class for all scene objects (Mesh, Light Camera).
  322. */
  323. class Node implements IBehaviorAware<Node> {
  324. private static _NodeConstructors;
  325. /**
  326. * Add a new node constructor
  327. * @param type defines the type name of the node to construct
  328. * @param constructorFunc defines the constructor function
  329. */
  330. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  331. /**
  332. * Returns a node constructor based on type name
  333. * @param type defines the type name
  334. * @param name defines the new node name
  335. * @param scene defines the hosting scene
  336. * @param options defines optional options to transmit to constructors
  337. * @returns the new constructor or null
  338. */
  339. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  340. /**
  341. * Gets or sets the name of the node
  342. */
  343. name: string;
  344. /**
  345. * Gets or sets the id of the node
  346. */
  347. id: string;
  348. /**
  349. * Gets or sets the unique id of the node
  350. */
  351. uniqueId: number;
  352. /**
  353. * Gets or sets a string used to store user defined state for the node
  354. */
  355. state: string;
  356. /**
  357. * Gets or sets an object used to store user defined information for the node
  358. */
  359. metadata: any;
  360. /**
  361. * Gets or sets a boolean used to define if the node must be serialized
  362. */
  363. doNotSerialize: boolean;
  364. /** @hidden */
  365. /**
  366. * Gets a list of Animations associated with the node
  367. */
  368. animations: Animation[];
  369. protected _ranges: {
  370. [name: string]: Nullable<AnimationRange>;
  371. };
  372. /**
  373. * Callback raised when the node is ready to be used
  374. */
  375. onReady: (node: Node) => void;
  376. private _isEnabled;
  377. private _isReady;
  378. /** @hidden */
  379. private _parentRenderId;
  380. protected _childRenderId: number;
  381. /** @hidden */
  382. /** @hidden */
  383. /** @hidden */
  384. private _parentNode;
  385. private _children;
  386. /**
  387. * Gets a boolean indicating if the node has been disposed
  388. * @returns true if the node was disposed
  389. */
  390. isDisposed(): boolean;
  391. /**
  392. * Gets or sets the parent of the node
  393. */
  394. parent: Nullable<Node>;
  395. private _animationPropertiesOverride;
  396. /**
  397. * Gets or sets the animation properties override
  398. */
  399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  400. /**
  401. * Gets a string idenfifying the name of the class
  402. * @returns "Node" string
  403. */
  404. getClassName(): string;
  405. /**
  406. * An event triggered when the mesh is disposed
  407. */
  408. onDisposeObservable: Observable<Node>;
  409. private _onDisposeObserver;
  410. /**
  411. * Sets a callback that will be raised when the node will be disposed
  412. */
  413. onDispose: () => void;
  414. /**
  415. * Creates a new Node
  416. * @param {string} name - the name and id to be given to this node
  417. * @param {BABYLON.Scene} the scene this node will be added to
  418. */
  419. constructor(name: string, scene?: Nullable<Scene>);
  420. /**
  421. * Gets the scene of the node
  422. * @returns a {BABYLON.Scene}
  423. */
  424. getScene(): Scene;
  425. /**
  426. * Gets the engine of the node
  427. * @returns a {BABYLON.Engine}
  428. */
  429. getEngine(): Engine;
  430. private _behaviors;
  431. /**
  432. * Attach a behavior to the node
  433. * @see http://doc.babylonjs.com/features/behaviour
  434. * @param behavior defines the behavior to attach
  435. * @returns the current Node
  436. */
  437. addBehavior(behavior: Behavior<Node>): Node;
  438. /**
  439. * Remove an attached behavior
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @param behavior defines the behavior to attach
  442. * @returns the current Node
  443. */
  444. removeBehavior(behavior: Behavior<Node>): Node;
  445. /**
  446. * Gets the list of attached behaviors
  447. * @see http://doc.babylonjs.com/features/behaviour
  448. */
  449. readonly behaviors: Behavior<Node>[];
  450. /**
  451. * Gets an attached behavior by name
  452. * @param name defines the name of the behavior to look for
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @returns null if behavior was not found else the requested behavior
  455. */
  456. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  457. /**
  458. * Returns the world matrix of the node
  459. * @returns a matrix containing the node's world matrix
  460. */
  461. getWorldMatrix(): Matrix;
  462. /** @hidden */
  463. /** @hidden */
  464. /** @hidden */
  465. updateCache(force?: boolean): void;
  466. /** @hidden */
  467. /** @hidden */
  468. /** @hidden */
  469. /** @hidden */
  470. isSynchronizedWithParent(): boolean;
  471. /** @hidden */
  472. isSynchronized(updateCache?: boolean): boolean;
  473. /** @hidden */
  474. hasNewParent(): boolean;
  475. /**
  476. * Is this node ready to be used/rendered
  477. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  478. * @return true if the node is ready
  479. */
  480. isReady(completeCheck?: boolean): boolean;
  481. /**
  482. * Is this node enabled?
  483. * 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
  484. * @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
  485. * @return whether this node (and its parent) is enabled
  486. */
  487. isEnabled(checkAncestors?: boolean): boolean;
  488. /**
  489. * Set the enabled state of this node
  490. * @param value defines the new enabled state
  491. */
  492. setEnabled(value: boolean): void;
  493. /**
  494. * Is this node a descendant of the given node?
  495. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  496. * @param ancestor defines the parent node to inspect
  497. * @returns a boolean indicating if this node is a descendant of the given node
  498. */
  499. isDescendantOf(ancestor: Node): boolean;
  500. /** @hidden */
  501. /**
  502. * Will return all nodes that have this node as ascendant
  503. * @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
  504. * @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
  505. * @return all children nodes of all types
  506. */
  507. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  508. /**
  509. * Get all child-meshes of this node
  510. * @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
  511. * @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
  512. * @returns an array of {BABYLON.AbstractMesh}
  513. */
  514. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  515. /**
  516. * Get all child-transformNodes of this node
  517. * @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
  518. * @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
  519. * @returns an array of {BABYLON.TransformNode}
  520. */
  521. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  522. /**
  523. * Get all direct children of this node
  524. * @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
  525. * @returns an array of {BABYLON.Node}
  526. */
  527. getChildren(predicate?: (node: Node) => boolean): Node[];
  528. /** @hidden */
  529. /**
  530. * Get an animation by name
  531. * @param name defines the name of the animation to look for
  532. * @returns null if not found else the requested animation
  533. */
  534. getAnimationByName(name: string): Nullable<Animation>;
  535. /**
  536. * Creates an animation range for this node
  537. * @param name defines the name of the range
  538. * @param from defines the starting key
  539. * @param to defines the end key
  540. */
  541. createAnimationRange(name: string, from: number, to: number): void;
  542. /**
  543. * Delete a specific animation range
  544. * @param name defines the name of the range to delete
  545. * @param deleteFrames defines if animation frames from the range must be deleted as well
  546. */
  547. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  548. /**
  549. * Get an animation range by name
  550. * @param name defines the name of the animation range to look for
  551. * @returns null if not found else the requested animation range
  552. */
  553. getAnimationRange(name: string): Nullable<AnimationRange>;
  554. /**
  555. * Will start the animation sequence
  556. * @param name defines the range frames for animation sequence
  557. * @param loop defines if the animation should loop (false by default)
  558. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  559. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  560. * @returns the object created for this animation. If range does not exist, it will return null
  561. */
  562. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  563. /**
  564. * Serialize animation ranges into a JSON compatible object
  565. * @returns serialization object
  566. */
  567. serializeAnimationRanges(): any;
  568. /**
  569. * Computes the world matrix of the node
  570. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  571. * @returns the world matrix
  572. */
  573. computeWorldMatrix(force?: boolean): Matrix;
  574. /**
  575. * Releases resources associated with this node.
  576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  578. */
  579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  580. /**
  581. * Parse animation range data from a serialization object and store them into a given node
  582. * @param node defines where to store the animation ranges
  583. * @param parsedNode defines the serialization object to read data from
  584. * @param scene defines the hosting scene
  585. */
  586. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  587. }
  588. }
  589. declare module BABYLON {
  590. /**
  591. * Define an interface for all classes that will hold resources
  592. */
  593. interface IDisposable {
  594. /**
  595. * Releases all held resources
  596. */
  597. dispose(): void;
  598. }
  599. /**
  600. * This class is used by the onRenderingGroupObservable
  601. */
  602. class RenderingGroupInfo {
  603. /**
  604. * The Scene that being rendered
  605. */
  606. scene: Scene;
  607. /**
  608. * The camera currently used for the rendering pass
  609. */
  610. camera: Nullable<Camera>;
  611. /**
  612. * The ID of the renderingGroup being processed
  613. */
  614. renderingGroupId: number;
  615. }
  616. /**
  617. * Represents a scene to be rendered by the engine.
  618. * @see http://doc.babylonjs.com/features/scene
  619. */
  620. class Scene extends AbstractScene implements IAnimatable {
  621. private static _uniqueIdCounter;
  622. /** The fog is deactivated */
  623. static readonly FOGMODE_NONE: number;
  624. /** The fog density is following an exponential function */
  625. static readonly FOGMODE_EXP: number;
  626. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  627. static readonly FOGMODE_EXP2: number;
  628. /** The fog density is following a linear function. */
  629. static readonly FOGMODE_LINEAR: number;
  630. /**
  631. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  633. */
  634. static MinDeltaTime: number;
  635. /**
  636. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  638. */
  639. static MaxDeltaTime: number;
  640. /**
  641. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  642. */
  643. autoClear: boolean;
  644. /**
  645. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  646. */
  647. autoClearDepthAndStencil: boolean;
  648. /**
  649. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  650. */
  651. clearColor: Color4;
  652. /**
  653. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  654. */
  655. ambientColor: Color3;
  656. /** @hidden */
  657. /** @hidden */
  658. protected _environmentTexture: BaseTexture;
  659. /**
  660. * Texture used in all pbr material as the reflection texture.
  661. * As in the majority of the scene they are the same (exception for multi room and so on),
  662. * this is easier to reference from here than from all the materials.
  663. */
  664. /**
  665. * Texture used in all pbr material as the reflection texture.
  666. * As in the majority of the scene they are the same (exception for multi room and so on),
  667. * this is easier to set here than in all the materials.
  668. */
  669. environmentTexture: BaseTexture;
  670. /** @hidden */
  671. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  672. /**
  673. * Default image processing configuration used either in the rendering
  674. * Forward main pass or through the imageProcessingPostProcess if present.
  675. * As in the majority of the scene they are the same (exception for multi camera),
  676. * this is easier to reference from here than from all the materials and post process.
  677. *
  678. * No setter as we it is a shared configuration, you can set the values instead.
  679. */
  680. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  681. private _forceWireframe;
  682. /**
  683. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  684. */
  685. forceWireframe: boolean;
  686. private _forcePointsCloud;
  687. /**
  688. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  689. */
  690. forcePointsCloud: boolean;
  691. /**
  692. * Gets or sets the active clipplane 1
  693. */
  694. clipPlane: Nullable<Plane>;
  695. /**
  696. * Gets or sets the active clipplane 2
  697. */
  698. clipPlane2: Nullable<Plane>;
  699. /**
  700. * Gets or sets the active clipplane 3
  701. */
  702. clipPlane3: Nullable<Plane>;
  703. /**
  704. * Gets or sets the active clipplane 4
  705. */
  706. clipPlane4: Nullable<Plane>;
  707. /**
  708. * Gets or sets a boolean indicating if animations are enabled
  709. */
  710. animationsEnabled: boolean;
  711. private _animationPropertiesOverride;
  712. /**
  713. * Gets or sets the animation properties override
  714. */
  715. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  716. /**
  717. * Gets or sets a boolean indicating if a constant deltatime has to be used
  718. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  719. */
  720. useConstantAnimationDeltaTime: boolean;
  721. /**
  722. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  723. * Please note that it requires to run a ray cast through the scene on every frame
  724. */
  725. constantlyUpdateMeshUnderPointer: boolean;
  726. /**
  727. * Defines the HTML cursor to use when hovering over interactive elements
  728. */
  729. hoverCursor: string;
  730. /**
  731. * Defines the HTML default cursor to use (empty by default)
  732. */
  733. defaultCursor: string;
  734. /**
  735. * This is used to call preventDefault() on pointer down
  736. * in order to block unwanted artifacts like system double clicks
  737. */
  738. preventDefaultOnPointerDown: boolean;
  739. /**
  740. * Gets or sets user defined metadata
  741. */
  742. metadata: any;
  743. /**
  744. * Gets the name of the plugin used to load this scene (null by default)
  745. */
  746. loadingPluginName: string;
  747. /**
  748. * Use this array to add regular expressions used to disable offline support for specific urls
  749. */
  750. disableOfflineSupportExceptionRules: RegExp[];
  751. /**
  752. * An event triggered when the scene is disposed.
  753. */
  754. onDisposeObservable: Observable<Scene>;
  755. private _onDisposeObserver;
  756. /** Sets a function to be executed when this scene is disposed. */
  757. onDispose: () => void;
  758. /**
  759. * An event triggered before rendering the scene (right after animations and physics)
  760. */
  761. onBeforeRenderObservable: Observable<Scene>;
  762. private _onBeforeRenderObserver;
  763. /** Sets a function to be executed before rendering this scene */
  764. beforeRender: Nullable<() => void>;
  765. /**
  766. * An event triggered after rendering the scene
  767. */
  768. onAfterRenderObservable: Observable<Scene>;
  769. private _onAfterRenderObserver;
  770. /** Sets a function to be executed after rendering this scene */
  771. afterRender: Nullable<() => void>;
  772. /**
  773. * An event triggered before animating the scene
  774. */
  775. onBeforeAnimationsObservable: Observable<Scene>;
  776. /**
  777. * An event triggered after animations processing
  778. */
  779. onAfterAnimationsObservable: Observable<Scene>;
  780. /**
  781. * An event triggered before draw calls are ready to be sent
  782. */
  783. onBeforeDrawPhaseObservable: Observable<Scene>;
  784. /**
  785. * An event triggered after draw calls have been sent
  786. */
  787. onAfterDrawPhaseObservable: Observable<Scene>;
  788. /**
  789. * An event triggered when physic simulation is about to be run
  790. */
  791. onBeforePhysicsObservable: Observable<Scene>;
  792. /**
  793. * An event triggered when physic simulation has been done
  794. */
  795. onAfterPhysicsObservable: Observable<Scene>;
  796. /**
  797. * An event triggered when the scene is ready
  798. */
  799. onReadyObservable: Observable<Scene>;
  800. /**
  801. * An event triggered before rendering a camera
  802. */
  803. onBeforeCameraRenderObservable: Observable<Camera>;
  804. private _onBeforeCameraRenderObserver;
  805. /** Sets a function to be executed before rendering a camera*/
  806. beforeCameraRender: () => void;
  807. /**
  808. * An event triggered after rendering a camera
  809. */
  810. onAfterCameraRenderObservable: Observable<Camera>;
  811. private _onAfterCameraRenderObserver;
  812. /** Sets a function to be executed after rendering a camera*/
  813. afterCameraRender: () => void;
  814. /**
  815. * An event triggered when active meshes evaluation is about to start
  816. */
  817. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when active meshes evaluation is done
  820. */
  821. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when particles rendering is about to start
  824. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  825. */
  826. onBeforeParticlesRenderingObservable: Observable<Scene>;
  827. /**
  828. * An event triggered when particles rendering is done
  829. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  830. */
  831. onAfterParticlesRenderingObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  834. */
  835. onDataLoadedObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when a camera is created
  838. */
  839. onNewCameraAddedObservable: Observable<Camera>;
  840. /**
  841. * An event triggered when a camera is removed
  842. */
  843. onCameraRemovedObservable: Observable<Camera>;
  844. /**
  845. * An event triggered when a light is created
  846. */
  847. onNewLightAddedObservable: Observable<Light>;
  848. /**
  849. * An event triggered when a light is removed
  850. */
  851. onLightRemovedObservable: Observable<Light>;
  852. /**
  853. * An event triggered when a geometry is created
  854. */
  855. onNewGeometryAddedObservable: Observable<Geometry>;
  856. /**
  857. * An event triggered when a geometry is removed
  858. */
  859. onGeometryRemovedObservable: Observable<Geometry>;
  860. /**
  861. * An event triggered when a transform node is created
  862. */
  863. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  864. /**
  865. * An event triggered when a transform node is removed
  866. */
  867. onTransformNodeRemovedObservable: Observable<TransformNode>;
  868. /**
  869. * An event triggered when a mesh is created
  870. */
  871. onNewMeshAddedObservable: Observable<AbstractMesh>;
  872. /**
  873. * An event triggered when a mesh is removed
  874. */
  875. onMeshRemovedObservable: Observable<AbstractMesh>;
  876. /**
  877. * An event triggered when render targets are about to be rendered
  878. * Can happen multiple times per frame.
  879. */
  880. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  881. /**
  882. * An event triggered when render targets were rendered.
  883. * Can happen multiple times per frame.
  884. */
  885. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  886. /**
  887. * An event triggered before calculating deterministic simulation step
  888. */
  889. onBeforeStepObservable: Observable<Scene>;
  890. /**
  891. * An event triggered after calculating deterministic simulation step
  892. */
  893. onAfterStepObservable: Observable<Scene>;
  894. /**
  895. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  896. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  897. * 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)
  898. */
  899. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  900. /**
  901. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  902. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  903. * 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)
  904. */
  905. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  906. /**
  907. * This Observable will when a mesh has been imported into the scene.
  908. */
  909. onMeshImportedObservable: Observable<AbstractMesh>;
  910. private _registeredForLateAnimationBindings;
  911. /**
  912. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  913. */
  914. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  915. /**
  916. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  917. */
  918. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  919. /**
  920. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  921. */
  922. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  923. private _onPointerMove;
  924. private _onPointerDown;
  925. private _onPointerUp;
  926. /** Deprecated. Use onPointerObservable instead */
  927. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  928. /** Deprecated. Use onPointerObservable instead */
  929. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  930. /** Deprecated. Use onPointerObservable instead */
  931. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  932. /** Deprecated. Use onPointerObservable instead */
  933. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  934. /**
  935. * 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).
  936. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  937. */
  938. onPrePointerObservable: Observable<PointerInfoPre>;
  939. /**
  940. * Observable event triggered each time an input event is received from the rendering canvas
  941. */
  942. onPointerObservable: Observable<PointerInfo>;
  943. /**
  944. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  945. */
  946. readonly unTranslatedPointer: Vector2;
  947. /** The distance in pixel that you have to move to prevent some events */
  948. static DragMovementThreshold: number;
  949. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  950. static LongPressDelay: number;
  951. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  952. static DoubleClickDelay: number;
  953. /** If you need to check double click without raising a single click at first click, enable this flag */
  954. static ExclusiveDoubleClickMode: boolean;
  955. private _initClickEvent;
  956. private _initActionManager;
  957. private _delayedSimpleClick;
  958. private _delayedSimpleClickTimeout;
  959. private _previousDelayedSimpleClickTimeout;
  960. private _meshPickProceed;
  961. private _previousButtonPressed;
  962. private _currentPickResult;
  963. private _previousPickResult;
  964. private _totalPointersPressed;
  965. private _doubleClickOccured;
  966. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  967. cameraToUseForPointers: Nullable<Camera>;
  968. private _pointerX;
  969. private _pointerY;
  970. private _unTranslatedPointerX;
  971. private _unTranslatedPointerY;
  972. private _startingPointerPosition;
  973. private _previousStartingPointerPosition;
  974. private _startingPointerTime;
  975. private _previousStartingPointerTime;
  976. private _pointerCaptures;
  977. private _timeAccumulator;
  978. private _currentStepId;
  979. private _currentInternalStep;
  980. /** @hidden */
  981. /**
  982. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  983. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  984. */
  985. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  986. /**
  987. * Observable event triggered each time an keyboard event is received from the hosting window
  988. */
  989. onKeyboardObservable: Observable<KeyboardInfo>;
  990. private _onKeyDown;
  991. private _onKeyUp;
  992. private _onCanvasFocusObserver;
  993. private _onCanvasBlurObserver;
  994. private _useRightHandedSystem;
  995. /**
  996. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  997. */
  998. useRightHandedSystem: boolean;
  999. /**
  1000. * Sets the step Id used by deterministic lock step
  1001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1002. * @param newStepId defines the step Id
  1003. */
  1004. setStepId(newStepId: number): void;
  1005. /**
  1006. * Gets the step Id used by deterministic lock step
  1007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1008. * @returns the step Id
  1009. */
  1010. getStepId(): number;
  1011. /**
  1012. * Gets the internal step used by deterministic lock step
  1013. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1014. * @returns the internal step
  1015. */
  1016. getInternalStep(): number;
  1017. private _fogEnabled;
  1018. /**
  1019. * Gets or sets a boolean indicating if fog is enabled on this scene
  1020. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1021. */
  1022. fogEnabled: boolean;
  1023. private _fogMode;
  1024. /**
  1025. * Gets or sets the fog mode to use
  1026. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1027. */
  1028. fogMode: number;
  1029. /**
  1030. * Gets or sets the fog color to use
  1031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1032. */
  1033. fogColor: Color3;
  1034. /**
  1035. * Gets or sets the fog density to use
  1036. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1037. */
  1038. fogDensity: number;
  1039. /**
  1040. * Gets or sets the fog start distance to use
  1041. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1042. */
  1043. fogStart: number;
  1044. /**
  1045. * Gets or sets the fog end distance to use
  1046. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1047. */
  1048. fogEnd: number;
  1049. private _shadowsEnabled;
  1050. /**
  1051. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1052. */
  1053. shadowsEnabled: boolean;
  1054. private _lightsEnabled;
  1055. /**
  1056. * Gets or sets a boolean indicating if lights are enabled on this scene
  1057. */
  1058. lightsEnabled: boolean;
  1059. /** All of the active cameras added to this scene. */
  1060. activeCameras: Camera[];
  1061. /** The current active camera */
  1062. activeCamera: Nullable<Camera>;
  1063. private _defaultMaterial;
  1064. /** The default material used on meshes when no material is affected */
  1065. /** The default material used on meshes when no material is affected */
  1066. defaultMaterial: Material;
  1067. private _texturesEnabled;
  1068. /**
  1069. * Gets or sets a boolean indicating if textures are enabled on this scene
  1070. */
  1071. texturesEnabled: boolean;
  1072. /**
  1073. * Gets or sets a boolean indicating if particles are enabled on this scene
  1074. */
  1075. particlesEnabled: boolean;
  1076. /**
  1077. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1078. */
  1079. spritesEnabled: boolean;
  1080. private _skeletonsEnabled;
  1081. /**
  1082. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1083. */
  1084. skeletonsEnabled: boolean;
  1085. /**
  1086. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1087. */
  1088. lensFlaresEnabled: boolean;
  1089. /**
  1090. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1092. */
  1093. collisionsEnabled: boolean;
  1094. private _workerCollisions;
  1095. /** @hidden */
  1096. collisionCoordinator: ICollisionCoordinator;
  1097. /**
  1098. * Defines the gravity applied to this scene (used only for collisions)
  1099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1100. */
  1101. gravity: Vector3;
  1102. /**
  1103. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1104. */
  1105. postProcessesEnabled: boolean;
  1106. /**
  1107. * The list of postprocesses added to the scene
  1108. */
  1109. postProcesses: PostProcess[];
  1110. /**
  1111. * Gets the current postprocess manager
  1112. */
  1113. postProcessManager: PostProcessManager;
  1114. /**
  1115. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1116. */
  1117. renderTargetsEnabled: boolean;
  1118. /**
  1119. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1120. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1121. */
  1122. dumpNextRenderTargets: boolean;
  1123. /**
  1124. * The list of user defined render targets added to the scene
  1125. */
  1126. customRenderTargets: RenderTargetTexture[];
  1127. /**
  1128. * Defines if texture loading must be delayed
  1129. * If true, textures will only be loaded when they need to be rendered
  1130. */
  1131. useDelayedTextureLoading: boolean;
  1132. /**
  1133. * Gets the list of meshes imported to the scene through SceneLoader
  1134. */
  1135. importedMeshesFiles: String[];
  1136. /**
  1137. * Gets or sets a boolean indicating if probes are enabled on this scene
  1138. */
  1139. probesEnabled: boolean;
  1140. /**
  1141. * @hidden
  1142. */
  1143. database: Database;
  1144. /**
  1145. * Gets or sets the action manager associated with the scene
  1146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1147. */
  1148. actionManager: ActionManager;
  1149. private _meshesForIntersections;
  1150. /**
  1151. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1152. */
  1153. proceduralTexturesEnabled: boolean;
  1154. private _mainSoundTrack;
  1155. /**
  1156. * The list of sound tracks added to the scene
  1157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1158. */
  1159. soundTracks: SoundTrack[];
  1160. private _audioEnabled;
  1161. private _headphone;
  1162. /**
  1163. * Gets the main soundtrack associated with the scene
  1164. */
  1165. readonly mainSoundTrack: SoundTrack;
  1166. /**
  1167. * Gets or sets the VRExperienceHelper attached to the scene
  1168. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1169. * @ignorenaming
  1170. */
  1171. VRHelper: VRExperienceHelper;
  1172. private _engine;
  1173. private _totalVertices;
  1174. /** @hidden */
  1175. /** @hidden */
  1176. /** @hidden */
  1177. private _animationRatio;
  1178. private _animationTimeLast;
  1179. private _animationTime;
  1180. /**
  1181. * Gets or sets a general scale for animation speed
  1182. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1183. */
  1184. animationTimeScale: number;
  1185. /** @hidden */
  1186. /** @hidden */
  1187. /** @hidden */
  1188. private _renderId;
  1189. private _executeWhenReadyTimeoutId;
  1190. private _intermediateRendering;
  1191. private _viewUpdateFlag;
  1192. private _projectionUpdateFlag;
  1193. private _alternateViewUpdateFlag;
  1194. private _alternateProjectionUpdateFlag;
  1195. /** @hidden */
  1196. private _activeRequests;
  1197. private _pendingData;
  1198. private _isDisposed;
  1199. /**
  1200. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1201. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1202. */
  1203. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1204. private _activeMeshes;
  1205. private _processedMaterials;
  1206. private _renderTargets;
  1207. /** @hidden */
  1208. private _activeSkeletons;
  1209. private _softwareSkinnedMeshes;
  1210. private _renderingManager;
  1211. private _physicsEngine;
  1212. /** @hidden */
  1213. private _transformMatrix;
  1214. private _sceneUbo;
  1215. private _alternateSceneUbo;
  1216. private _pickWithRayInverseMatrix;
  1217. private _viewMatrix;
  1218. private _projectionMatrix;
  1219. private _alternateViewMatrix;
  1220. private _alternateProjectionMatrix;
  1221. private _alternateTransformMatrix;
  1222. private _useAlternateCameraConfiguration;
  1223. private _alternateRendering;
  1224. /** @hidden */
  1225. /** @hidden */
  1226. protected readonly _isAlternateRenderingEnabled: boolean;
  1227. private _frustumPlanes;
  1228. /**
  1229. * Gets the list of frustum planes (built from the active camera)
  1230. */
  1231. readonly frustumPlanes: Plane[];
  1232. /**
  1233. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1234. * This is useful if there are more lights that the maximum simulteanous authorized
  1235. */
  1236. requireLightSorting: boolean;
  1237. private _pointerOverMesh;
  1238. private _debugLayer;
  1239. private _pickedDownMesh;
  1240. private _pickedUpMesh;
  1241. private _externalData;
  1242. private _uid;
  1243. /**
  1244. * @hidden
  1245. * Backing store of defined scene components.
  1246. */
  1247. /**
  1248. * @hidden
  1249. * Backing store of defined scene components.
  1250. */
  1251. /**
  1252. * List of components to register on the next registration step.
  1253. */
  1254. private _transientComponents;
  1255. /**
  1256. * Registers the transient components if needed.
  1257. */
  1258. private _registerTransientComponents;
  1259. /**
  1260. * @hidden
  1261. * Add a component to the scene.
  1262. * Note that the ccomponent could be registered on th next frame if this is called after
  1263. * the register component stage.
  1264. * @param component Defines the component to add to the scene
  1265. */
  1266. /**
  1267. * @hidden
  1268. * Gets a component from the scene.
  1269. * @param name defines the name of the component to retrieve
  1270. * @returns the component or null if not present
  1271. */
  1272. /**
  1273. * @hidden
  1274. * Defines the actions happening before camera updates.
  1275. */
  1276. /**
  1277. * @hidden
  1278. * Defines the actions happening before clear the canvas.
  1279. */
  1280. /**
  1281. * @hidden
  1282. * Defines the actions happening before camera updates.
  1283. */
  1284. /**
  1285. * @hidden
  1286. * Defines the actions happening during the per mesh ready checks.
  1287. */
  1288. /**
  1289. * @hidden
  1290. * Defines the actions happening before evaluate active mesh checks.
  1291. */
  1292. /**
  1293. * @hidden
  1294. * Defines the actions happening during the evaluate sub mesh checks.
  1295. */
  1296. /**
  1297. * @hidden
  1298. * Defines the actions happening during the active mesh stage.
  1299. */
  1300. /**
  1301. * @hidden
  1302. * Defines the actions happening during the per camera render target step.
  1303. */
  1304. /**
  1305. * @hidden
  1306. * Defines the actions happening just before the active camera is drawing.
  1307. */
  1308. /**
  1309. * @hidden
  1310. * Defines the actions happening just before a rendering group is drawing.
  1311. */
  1312. /**
  1313. * @hidden
  1314. * Defines the actions happening just before a mesh is drawing.
  1315. */
  1316. /**
  1317. * @hidden
  1318. * Defines the actions happening just after a mesh has been drawn.
  1319. */
  1320. /**
  1321. * @hidden
  1322. * Defines the actions happening just after a rendering group has been drawn.
  1323. */
  1324. /**
  1325. * @hidden
  1326. * Defines the actions happening just after the active camera has been drawn.
  1327. */
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening when a pointer move event happens.
  1331. */
  1332. /**
  1333. * @hidden
  1334. * Defines the actions happening when a pointer down event happens.
  1335. */
  1336. /**
  1337. * @hidden
  1338. * Defines the actions happening when a pointer up event happens.
  1339. */
  1340. /**
  1341. * Creates a new Scene
  1342. * @param engine defines the engine to use to render this scene
  1343. */
  1344. constructor(engine: Engine);
  1345. private _defaultMeshCandidates;
  1346. /**
  1347. * @hidden
  1348. */
  1349. private _defaultSubMeshCandidates;
  1350. /**
  1351. * @hidden
  1352. */
  1353. /**
  1354. * Sets the default candidate providers for the scene.
  1355. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1356. * and getCollidingSubMeshCandidates to their default function
  1357. */
  1358. setDefaultCandidateProviders(): void;
  1359. /**
  1360. * Gets the debug layer (aka Inspector) associated with the scene
  1361. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1362. */
  1363. readonly debugLayer: DebugLayer;
  1364. /**
  1365. * Gets a boolean indicating if collisions are processed on a web worker
  1366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1367. */
  1368. workerCollisions: boolean;
  1369. /**
  1370. * Gets the mesh that is currently under the pointer
  1371. */
  1372. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1373. /**
  1374. * Gets the current on-screen X position of the pointer
  1375. */
  1376. readonly pointerX: number;
  1377. /**
  1378. * Gets the current on-screen Y position of the pointer
  1379. */
  1380. readonly pointerY: number;
  1381. /**
  1382. * Gets the cached material (ie. the latest rendered one)
  1383. * @returns the cached material
  1384. */
  1385. getCachedMaterial(): Nullable<Material>;
  1386. /**
  1387. * Gets the cached effect (ie. the latest rendered one)
  1388. * @returns the cached effect
  1389. */
  1390. getCachedEffect(): Nullable<Effect>;
  1391. /**
  1392. * Gets the cached visibility state (ie. the latest rendered one)
  1393. * @returns the cached visibility state
  1394. */
  1395. getCachedVisibility(): Nullable<number>;
  1396. /**
  1397. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1398. * @param material defines the current material
  1399. * @param effect defines the current effect
  1400. * @param visibility defines the current visibility state
  1401. * @returns true if one parameter is not cached
  1402. */
  1403. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1404. /**
  1405. * Gets the engine associated with the scene
  1406. * @returns an Engine
  1407. */
  1408. getEngine(): Engine;
  1409. /**
  1410. * Gets the total number of vertices rendered per frame
  1411. * @returns the total number of vertices rendered per frame
  1412. */
  1413. getTotalVertices(): number;
  1414. /**
  1415. * Gets the performance counter for total vertices
  1416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1417. */
  1418. readonly totalVerticesPerfCounter: PerfCounter;
  1419. /**
  1420. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1421. * @returns the total number of active indices rendered per frame
  1422. */
  1423. getActiveIndices(): number;
  1424. /**
  1425. * Gets the performance counter for active indices
  1426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1427. */
  1428. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1429. /**
  1430. * Gets the total number of active particles rendered per frame
  1431. * @returns the total number of active particles rendered per frame
  1432. */
  1433. getActiveParticles(): number;
  1434. /**
  1435. * Gets the performance counter for active particles
  1436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1437. */
  1438. readonly activeParticlesPerfCounter: PerfCounter;
  1439. /**
  1440. * Gets the total number of active bones rendered per frame
  1441. * @returns the total number of active bones rendered per frame
  1442. */
  1443. getActiveBones(): number;
  1444. /**
  1445. * Gets the performance counter for active bones
  1446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1447. */
  1448. readonly activeBonesPerfCounter: PerfCounter;
  1449. /** @hidden */
  1450. getInterFramePerfCounter(): number;
  1451. /** @hidden */
  1452. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1453. /** @hidden */
  1454. getLastFrameDuration(): number;
  1455. /** @hidden */
  1456. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1457. /** @hidden */
  1458. getEvaluateActiveMeshesDuration(): number;
  1459. /** @hidden */
  1460. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1461. /**
  1462. * Gets the array of active meshes
  1463. * @returns an array of AbstractMesh
  1464. */
  1465. getActiveMeshes(): SmartArray<AbstractMesh>;
  1466. /** @hidden */
  1467. getRenderTargetsDuration(): number;
  1468. /** @hidden */
  1469. getRenderDuration(): number;
  1470. /** @hidden */
  1471. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1472. /** @hidden */
  1473. getParticlesDuration(): number;
  1474. /** @hidden */
  1475. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1476. /** @hidden */
  1477. getSpritesDuration(): number;
  1478. /** @hidden */
  1479. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1480. /**
  1481. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1482. * @returns a number
  1483. */
  1484. getAnimationRatio(): number;
  1485. /**
  1486. * Gets an unique Id for the current frame
  1487. * @returns a number
  1488. */
  1489. getRenderId(): number;
  1490. /** Call this function if you want to manually increment the render Id*/
  1491. incrementRenderId(): void;
  1492. private _updatePointerPosition;
  1493. private _createUbo;
  1494. private _createAlternateUbo;
  1495. private _setRayOnPointerInfo;
  1496. /**
  1497. * Use this method to simulate a pointer move on a mesh
  1498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1501. * @returns the current scene
  1502. */
  1503. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1504. private _processPointerMove;
  1505. private _checkPrePointerObservable;
  1506. /**
  1507. * Use this method to simulate a pointer down on a mesh
  1508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1511. * @returns the current scene
  1512. */
  1513. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1514. private _processPointerDown;
  1515. /**
  1516. * Use this method to simulate a pointer up on a mesh
  1517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1520. * @returns the current scene
  1521. */
  1522. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1523. private _processPointerUp;
  1524. /**
  1525. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1526. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1527. * @returns true if the pointer was captured
  1528. */
  1529. isPointerCaptured(pointerId?: number): boolean;
  1530. /** @hidden */
  1531. /**
  1532. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1533. * @param attachUp defines if you want to attach events to pointerup
  1534. * @param attachDown defines if you want to attach events to pointerdown
  1535. * @param attachMove defines if you want to attach events to pointermove
  1536. */
  1537. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1538. /** Detaches all event handlers*/
  1539. detachControl(): void;
  1540. /**
  1541. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1542. * Delay loaded resources are not taking in account
  1543. * @return true if all required resources are ready
  1544. */
  1545. isReady(): boolean;
  1546. /** Resets all cached information relative to material (including effect and visibility) */
  1547. resetCachedMaterial(): void;
  1548. /**
  1549. * Registers a function to be called before every frame render
  1550. * @param func defines the function to register
  1551. */
  1552. registerBeforeRender(func: () => void): void;
  1553. /**
  1554. * Unregisters a function called before every frame render
  1555. * @param func defines the function to unregister
  1556. */
  1557. unregisterBeforeRender(func: () => void): void;
  1558. /**
  1559. * Registers a function to be called after every frame render
  1560. * @param func defines the function to register
  1561. */
  1562. registerAfterRender(func: () => void): void;
  1563. /**
  1564. * Unregisters a function called after every frame render
  1565. * @param func defines the function to unregister
  1566. */
  1567. unregisterAfterRender(func: () => void): void;
  1568. private _executeOnceBeforeRender;
  1569. /**
  1570. * The provided function will run before render once and will be disposed afterwards.
  1571. * A timeout delay can be provided so that the function will be executed in N ms.
  1572. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1573. * @param func The function to be executed.
  1574. * @param timeout optional delay in ms
  1575. */
  1576. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1577. /** @hidden */
  1578. /** @hidden */
  1579. /**
  1580. * Returns the number of items waiting to be loaded
  1581. * @returns the number of items waiting to be loaded
  1582. */
  1583. getWaitingItemsCount(): number;
  1584. /**
  1585. * Returns a boolean indicating if the scene is still loading data
  1586. */
  1587. readonly isLoading: boolean;
  1588. /**
  1589. * Registers a function to be executed when the scene is ready
  1590. * @param {Function} func - the function to be executed
  1591. */
  1592. executeWhenReady(func: () => void): void;
  1593. /**
  1594. * Returns a promise that resolves when the scene is ready
  1595. * @returns A promise that resolves when the scene is ready
  1596. */
  1597. whenReadyAsync(): Promise<void>;
  1598. /** @hidden */
  1599. /**
  1600. * Will start the animation sequence of a given target
  1601. * @param target defines the target
  1602. * @param from defines from which frame should animation start
  1603. * @param to defines until which frame should animation run.
  1604. * @param weight defines the weight to apply to the animation (1.0 by default)
  1605. * @param loop defines if the animation loops
  1606. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1607. * @param onAnimationEnd defines the function to be executed when the animation ends
  1608. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1609. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1610. * @returns the animatable object created for this animation
  1611. */
  1612. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1613. /**
  1614. * Will start the animation sequence of a given target
  1615. * @param target defines the target
  1616. * @param from defines from which frame should animation start
  1617. * @param to defines until which frame should animation run.
  1618. * @param loop defines if the animation loops
  1619. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1620. * @param onAnimationEnd defines the function to be executed when the animation ends
  1621. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1622. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1623. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1624. * @returns the animatable object created for this animation
  1625. */
  1626. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1627. /**
  1628. * Begin a new animation on a given node
  1629. * @param target defines the target where the animation will take place
  1630. * @param animations defines the list of animations to start
  1631. * @param from defines the initial value
  1632. * @param to defines the final value
  1633. * @param loop defines if you want animation to loop (off by default)
  1634. * @param speedRatio defines the speed ratio to apply to all animations
  1635. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1636. * @returns the list of created animatables
  1637. */
  1638. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1639. /**
  1640. * Begin a new animation on a given node and its hierarchy
  1641. * @param target defines the root node where the animation will take place
  1642. * @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.
  1643. * @param animations defines the list of animations to start
  1644. * @param from defines the initial value
  1645. * @param to defines the final value
  1646. * @param loop defines if you want animation to loop (off by default)
  1647. * @param speedRatio defines the speed ratio to apply to all animations
  1648. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1649. * @returns the list of animatables created for all nodes
  1650. */
  1651. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1652. /**
  1653. * Gets the animatable associated with a specific target
  1654. * @param target defines the target of the animatable
  1655. * @returns the required animatable if found
  1656. */
  1657. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1658. /**
  1659. * Gets all animatables associated with a given target
  1660. * @param target defines the target to look animatables for
  1661. * @returns an array of Animatables
  1662. */
  1663. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1664. /**
  1665. * Gets all animatable attached to the scene
  1666. */
  1667. readonly animatables: Animatable[];
  1668. /**
  1669. * Will stop the animation of the given target
  1670. * @param target - the target
  1671. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1672. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1673. */
  1674. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1675. /**
  1676. * Stops and removes all animations that have been applied to the scene
  1677. */
  1678. stopAllAnimations(): void;
  1679. private _animate;
  1680. /** @hidden */
  1681. private _processLateAnimationBindingsForMatrices;
  1682. private _processLateAnimationBindingsForQuaternions;
  1683. private _processLateAnimationBindings;
  1684. /** @hidden */
  1685. /**
  1686. * Gets the current view matrix
  1687. * @returns a Matrix
  1688. */
  1689. getViewMatrix(): Matrix;
  1690. /**
  1691. * Gets the current projection matrix
  1692. * @returns a Matrix
  1693. */
  1694. getProjectionMatrix(): Matrix;
  1695. /**
  1696. * Gets the current transform matrix
  1697. * @returns a Matrix made of View * Projection
  1698. */
  1699. getTransformMatrix(): Matrix;
  1700. /**
  1701. * Sets the current transform matrix
  1702. * @param view defines the View matrix to use
  1703. * @param projection defines the Projection matrix to use
  1704. */
  1705. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1706. /** @hidden */
  1707. /**
  1708. * Gets the uniform buffer used to store scene data
  1709. * @returns a UniformBuffer
  1710. */
  1711. getSceneUniformBuffer(): UniformBuffer;
  1712. /**
  1713. * Gets an unique (relatively to the current scene) Id
  1714. * @returns an unique number for the scene
  1715. */
  1716. getUniqueId(): number;
  1717. /**
  1718. * Add a mesh to the list of scene's meshes
  1719. * @param newMesh defines the mesh to add
  1720. * @param recursive if all child meshes should also be added to the scene
  1721. */
  1722. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1723. /**
  1724. * Remove a mesh for the list of scene's meshes
  1725. * @param toRemove defines the mesh to remove
  1726. * @param recursive if all child meshes should also be removed from the scene
  1727. * @returns the index where the mesh was in the mesh list
  1728. */
  1729. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1730. /**
  1731. * Add a transform node to the list of scene's transform nodes
  1732. * @param newTransformNode defines the transform node to add
  1733. */
  1734. addTransformNode(newTransformNode: TransformNode): void;
  1735. /**
  1736. * Remove a transform node for the list of scene's transform nodes
  1737. * @param toRemove defines the transform node to remove
  1738. * @returns the index where the transform node was in the transform node list
  1739. */
  1740. removeTransformNode(toRemove: TransformNode): number;
  1741. /**
  1742. * Remove a skeleton for the list of scene's skeletons
  1743. * @param toRemove defines the skeleton to remove
  1744. * @returns the index where the skeleton was in the skeleton list
  1745. */
  1746. removeSkeleton(toRemove: Skeleton): number;
  1747. /**
  1748. * Remove a morph target for the list of scene's morph targets
  1749. * @param toRemove defines the morph target to remove
  1750. * @returns the index where the morph target was in the morph target list
  1751. */
  1752. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1753. /**
  1754. * Remove a light for the list of scene's lights
  1755. * @param toRemove defines the light to remove
  1756. * @returns the index where the light was in the light list
  1757. */
  1758. removeLight(toRemove: Light): number;
  1759. /**
  1760. * Remove a camera for the list of scene's cameras
  1761. * @param toRemove defines the camera to remove
  1762. * @returns the index where the camera was in the camera list
  1763. */
  1764. removeCamera(toRemove: Camera): number;
  1765. /**
  1766. * Remove a particle system for the list of scene's particle systems
  1767. * @param toRemove defines the particle system to remove
  1768. * @returns the index where the particle system was in the particle system list
  1769. */
  1770. removeParticleSystem(toRemove: IParticleSystem): number;
  1771. /**
  1772. * Remove a animation for the list of scene's animations
  1773. * @param toRemove defines the animation to remove
  1774. * @returns the index where the animation was in the animation list
  1775. */
  1776. removeAnimation(toRemove: Animation): number;
  1777. /**
  1778. * Removes the given animation group from this scene.
  1779. * @param toRemove The animation group to remove
  1780. * @returns The index of the removed animation group
  1781. */
  1782. removeAnimationGroup(toRemove: AnimationGroup): number;
  1783. /**
  1784. * Removes the given multi-material from this scene.
  1785. * @param toRemove The multi-material to remove
  1786. * @returns The index of the removed multi-material
  1787. */
  1788. removeMultiMaterial(toRemove: MultiMaterial): number;
  1789. /**
  1790. * Removes the given material from this scene.
  1791. * @param toRemove The material to remove
  1792. * @returns The index of the removed material
  1793. */
  1794. removeMaterial(toRemove: Material): number;
  1795. /**
  1796. * Removes the given action manager from this scene.
  1797. * @param toRemove The action manager to remove
  1798. * @returns The index of the removed action manager
  1799. */
  1800. removeActionManager(toRemove: ActionManager): number;
  1801. /**
  1802. * Removes the given texture from this scene.
  1803. * @param toRemove The texture to remove
  1804. * @returns The index of the removed texture
  1805. */
  1806. removeTexture(toRemove: BaseTexture): number;
  1807. /**
  1808. * Adds the given light to this scene
  1809. * @param newLight The light to add
  1810. */
  1811. addLight(newLight: Light): void;
  1812. /**
  1813. * Sorts the list list based on light priorities
  1814. */
  1815. sortLightsByPriority(): void;
  1816. /**
  1817. * Adds the given camera to this scene
  1818. * @param newCamera The camera to add
  1819. */
  1820. addCamera(newCamera: Camera): void;
  1821. /**
  1822. * Adds the given skeleton to this scene
  1823. * @param newSkeleton The skeleton to add
  1824. */
  1825. addSkeleton(newSkeleton: Skeleton): void;
  1826. /**
  1827. * Adds the given particle system to this scene
  1828. * @param newParticleSystem The particle system to add
  1829. */
  1830. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1831. /**
  1832. * Adds the given animation to this scene
  1833. * @param newAnimation The animation to add
  1834. */
  1835. addAnimation(newAnimation: Animation): void;
  1836. /**
  1837. * Adds the given animation group to this scene.
  1838. * @param newAnimationGroup The animation group to add
  1839. */
  1840. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1841. /**
  1842. * Adds the given multi-material to this scene
  1843. * @param newMultiMaterial The multi-material to add
  1844. */
  1845. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1846. /**
  1847. * Adds the given material to this scene
  1848. * @param newMaterial The material to add
  1849. */
  1850. addMaterial(newMaterial: Material): void;
  1851. /**
  1852. * Adds the given morph target to this scene
  1853. * @param newMorphTargetManager The morph target to add
  1854. */
  1855. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1856. /**
  1857. * Adds the given geometry to this scene
  1858. * @param newGeometry The geometry to add
  1859. */
  1860. addGeometry(newGeometry: Geometry): void;
  1861. /**
  1862. * Adds the given action manager to this scene
  1863. * @param newActionManager The action manager to add
  1864. */
  1865. addActionManager(newActionManager: ActionManager): void;
  1866. /**
  1867. * Adds the given texture to this scene.
  1868. * @param newTexture The texture to add
  1869. */
  1870. addTexture(newTexture: BaseTexture): void;
  1871. /**
  1872. * Switch active camera
  1873. * @param newCamera defines the new active camera
  1874. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1875. */
  1876. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1877. /**
  1878. * sets the active camera of the scene using its ID
  1879. * @param id defines the camera's ID
  1880. * @return the new active camera or null if none found.
  1881. */
  1882. setActiveCameraByID(id: string): Nullable<Camera>;
  1883. /**
  1884. * sets the active camera of the scene using its name
  1885. * @param name defines the camera's name
  1886. * @returns the new active camera or null if none found.
  1887. */
  1888. setActiveCameraByName(name: string): Nullable<Camera>;
  1889. /**
  1890. * get an animation group using its name
  1891. * @param name defines the material's name
  1892. * @return the animation group or null if none found.
  1893. */
  1894. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1895. /**
  1896. * get a material using its id
  1897. * @param id defines the material's ID
  1898. * @return the material or null if none found.
  1899. */
  1900. getMaterialByID(id: string): Nullable<Material>;
  1901. /**
  1902. * Gets a material using its name
  1903. * @param name defines the material's name
  1904. * @return the material or null if none found.
  1905. */
  1906. getMaterialByName(name: string): Nullable<Material>;
  1907. /**
  1908. * Gets a camera using its id
  1909. * @param id defines the id to look for
  1910. * @returns the camera or null if not found
  1911. */
  1912. getCameraByID(id: string): Nullable<Camera>;
  1913. /**
  1914. * Gets a camera using its unique id
  1915. * @param uniqueId defines the unique id to look for
  1916. * @returns the camera or null if not found
  1917. */
  1918. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1919. /**
  1920. * Gets a camera using its name
  1921. * @param name defines the camera's name
  1922. * @return the camera or null if none found.
  1923. */
  1924. getCameraByName(name: string): Nullable<Camera>;
  1925. /**
  1926. * Gets a bone using its id
  1927. * @param id defines the bone's id
  1928. * @return the bone or null if not found
  1929. */
  1930. getBoneByID(id: string): Nullable<Bone>;
  1931. /**
  1932. * Gets a bone using its id
  1933. * @param name defines the bone's name
  1934. * @return the bone or null if not found
  1935. */
  1936. getBoneByName(name: string): Nullable<Bone>;
  1937. /**
  1938. * Gets a light node using its name
  1939. * @param name defines the the light's name
  1940. * @return the light or null if none found.
  1941. */
  1942. getLightByName(name: string): Nullable<Light>;
  1943. /**
  1944. * Gets a light node using its id
  1945. * @param id defines the light's id
  1946. * @return the light or null if none found.
  1947. */
  1948. getLightByID(id: string): Nullable<Light>;
  1949. /**
  1950. * Gets a light node using its scene-generated unique ID
  1951. * @param uniqueId defines the light's unique id
  1952. * @return the light or null if none found.
  1953. */
  1954. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1955. /**
  1956. * Gets a particle system by id
  1957. * @param id defines the particle system id
  1958. * @return the corresponding system or null if none found
  1959. */
  1960. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1961. /**
  1962. * Gets a geometry using its ID
  1963. * @param id defines the geometry's id
  1964. * @return the geometry or null if none found.
  1965. */
  1966. getGeometryByID(id: string): Nullable<Geometry>;
  1967. /**
  1968. * Add a new geometry to this scene
  1969. * @param geometry defines the geometry to be added to the scene.
  1970. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  1971. * @return a boolean defining if the geometry was added or not
  1972. */
  1973. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1974. /**
  1975. * Removes an existing geometry
  1976. * @param geometry defines the geometry to be removed from the scene
  1977. * @return a boolean defining if the geometry was removed or not
  1978. */
  1979. removeGeometry(geometry: Geometry): boolean;
  1980. /**
  1981. * Gets the list of geometries attached to the scene
  1982. * @returns an array of Geometry
  1983. */
  1984. getGeometries(): Geometry[];
  1985. /**
  1986. * Gets the first added mesh found of a given ID
  1987. * @param id defines the id to search for
  1988. * @return the mesh found or null if not found at all
  1989. */
  1990. getMeshByID(id: string): Nullable<AbstractMesh>;
  1991. /**
  1992. * Gets a list of meshes using their id
  1993. * @param id defines the id to search for
  1994. * @returns a list of meshes
  1995. */
  1996. getMeshesByID(id: string): Array<AbstractMesh>;
  1997. /**
  1998. * Gets the first added transform node found of a given ID
  1999. * @param id defines the id to search for
  2000. * @return the found transform node or null if not found at all.
  2001. */
  2002. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2003. /**
  2004. * Gets a list of transform nodes using their id
  2005. * @param id defines the id to search for
  2006. * @returns a list of transform nodes
  2007. */
  2008. getTransformNodesByID(id: string): Array<TransformNode>;
  2009. /**
  2010. * Gets a mesh with its auto-generated unique id
  2011. * @param uniqueId defines the unique id to search for
  2012. * @return the found mesh or null if not found at all.
  2013. */
  2014. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2015. /**
  2016. * Gets a the last added mesh using a given id
  2017. * @param id defines the id to search for
  2018. * @return the found mesh or null if not found at all.
  2019. */
  2020. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2021. /**
  2022. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2023. * @param id defines the id to search for
  2024. * @return the found node or null if not found at all
  2025. */
  2026. getLastEntryByID(id: string): Nullable<Node>;
  2027. /**
  2028. * Gets a node (Mesh, Camera, Light) using a given id
  2029. * @param id defines the id to search for
  2030. * @return the found node or null if not found at all
  2031. */
  2032. getNodeByID(id: string): Nullable<Node>;
  2033. /**
  2034. * Gets a node (Mesh, Camera, Light) using a given name
  2035. * @param name defines the name to search for
  2036. * @return the found node or null if not found at all.
  2037. */
  2038. getNodeByName(name: string): Nullable<Node>;
  2039. /**
  2040. * Gets a mesh using a given name
  2041. * @param name defines the name to search for
  2042. * @return the found mesh or null if not found at all.
  2043. */
  2044. getMeshByName(name: string): Nullable<AbstractMesh>;
  2045. /**
  2046. * Gets a transform node using a given name
  2047. * @param name defines the name to search for
  2048. * @return the found transform node or null if not found at all.
  2049. */
  2050. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2051. /**
  2052. * Gets a sound using a given name
  2053. * @param name defines the name to search for
  2054. * @return the found sound or null if not found at all.
  2055. */
  2056. getSoundByName(name: string): Nullable<Sound>;
  2057. /**
  2058. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2059. * @param id defines the id to search for
  2060. * @return the found skeleton or null if not found at all.
  2061. */
  2062. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2063. /**
  2064. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2065. * @param id defines the id to search for
  2066. * @return the found skeleton or null if not found at all.
  2067. */
  2068. getSkeletonById(id: string): Nullable<Skeleton>;
  2069. /**
  2070. * Gets a skeleton using a given name
  2071. * @param name defines the name to search for
  2072. * @return the found skeleton or null if not found at all.
  2073. */
  2074. getSkeletonByName(name: string): Nullable<Skeleton>;
  2075. /**
  2076. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2077. * @param id defines the id to search for
  2078. * @return the found morph target manager or null if not found at all.
  2079. */
  2080. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2081. /**
  2082. * Gets a boolean indicating if the given mesh is active
  2083. * @param mesh defines the mesh to look for
  2084. * @returns true if the mesh is in the active list
  2085. */
  2086. isActiveMesh(mesh: AbstractMesh): boolean;
  2087. /**
  2088. * Return a unique id as a string which can serve as an identifier for the scene
  2089. */
  2090. readonly uid: string;
  2091. /**
  2092. * Add an externaly attached data from its key.
  2093. * This method call will fail and return false, if such key already exists.
  2094. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2095. * @param key the unique key that identifies the data
  2096. * @param data the data object to associate to the key for this Engine instance
  2097. * @return true if no such key were already present and the data was added successfully, false otherwise
  2098. */
  2099. addExternalData<T>(key: string, data: T): boolean;
  2100. /**
  2101. * Get an externaly attached data from its key
  2102. * @param key the unique key that identifies the data
  2103. * @return the associated data, if present (can be null), or undefined if not present
  2104. */
  2105. getExternalData<T>(key: string): Nullable<T>;
  2106. /**
  2107. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2108. * @param key the unique key that identifies the data
  2109. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2110. * @return the associated data, can be null if the factory returned null.
  2111. */
  2112. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2113. /**
  2114. * Remove an externaly attached data from the Engine instance
  2115. * @param key the unique key that identifies the data
  2116. * @return true if the data was successfully removed, false if it doesn't exist
  2117. */
  2118. removeExternalData(key: string): boolean;
  2119. private _evaluateSubMesh;
  2120. /**
  2121. * Clear the processed materials smart array preventing retention point in material dispose.
  2122. */
  2123. freeProcessedMaterials(): void;
  2124. /**
  2125. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2126. */
  2127. freeActiveMeshes(): void;
  2128. /**
  2129. * Clear the info related to rendering groups preventing retention points during dispose.
  2130. */
  2131. freeRenderingGroups(): void;
  2132. /** @hidden */
  2133. /**
  2134. * Lambda returning the list of potentially active meshes.
  2135. */
  2136. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2137. /**
  2138. * Lambda returning the list of potentially active sub meshes.
  2139. */
  2140. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2141. /**
  2142. * Lambda returning the list of potentially intersecting sub meshes.
  2143. */
  2144. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2145. /**
  2146. * Lambda returning the list of potentially colliding sub meshes.
  2147. */
  2148. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2149. private _activeMeshesFrozen;
  2150. /**
  2151. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2152. * @returns the current scene
  2153. */
  2154. freezeActiveMeshes(): Scene;
  2155. /**
  2156. * Use this function to restart evaluating active meshes on every frame
  2157. * @returns the current scene
  2158. */
  2159. unfreezeActiveMeshes(): Scene;
  2160. private _evaluateActiveMeshes;
  2161. private _activeMesh;
  2162. /**
  2163. * Update the transform matrix to update from the current active camera
  2164. * @param force defines a boolean used to force the update even if cache is up to date
  2165. */
  2166. updateTransformMatrix(force?: boolean): void;
  2167. /**
  2168. * 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)
  2169. * @param alternateCamera defines the camera to use
  2170. */
  2171. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2172. /** @hidden */
  2173. private _renderForCamera;
  2174. private _processSubCameras;
  2175. private _checkIntersections;
  2176. /**
  2177. * Render the scene
  2178. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2179. */
  2180. render(updateCameras?: boolean): void;
  2181. private _updateAudioParameters;
  2182. /**
  2183. * Gets or sets if audio support is enabled
  2184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2185. */
  2186. audioEnabled: boolean;
  2187. private _disableAudio;
  2188. private _enableAudio;
  2189. /**
  2190. * Gets or sets if audio will be output to headphones
  2191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2192. */
  2193. headphone: boolean;
  2194. private _switchAudioModeForHeadphones;
  2195. private _switchAudioModeForNormalSpeakers;
  2196. /**
  2197. * Freeze all materials
  2198. * A frozen material will not be updatable but should be faster to render
  2199. */
  2200. freezeMaterials(): void;
  2201. /**
  2202. * Unfreeze all materials
  2203. * A frozen material will not be updatable but should be faster to render
  2204. */
  2205. unfreezeMaterials(): void;
  2206. /**
  2207. * Releases all held ressources
  2208. */
  2209. dispose(): void;
  2210. /**
  2211. * Gets if the scene is already disposed
  2212. */
  2213. readonly isDisposed: boolean;
  2214. /**
  2215. * Releases sounds & soundtracks
  2216. */
  2217. disposeSounds(): void;
  2218. /**
  2219. * Call this function to reduce memory footprint of the scene.
  2220. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2221. */
  2222. clearCachedVertexData(): void;
  2223. /**
  2224. * This function will remove the local cached buffer data from texture.
  2225. * It will save memory but will prevent the texture from being rebuilt
  2226. */
  2227. cleanCachedTextureBuffer(): void;
  2228. /**
  2229. * Get the world extend vectors with an optional filter
  2230. *
  2231. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2232. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2233. */
  2234. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2235. min: Vector3;
  2236. max: Vector3;
  2237. };
  2238. /**
  2239. * Creates a ray that can be used to pick in the scene
  2240. * @param x defines the x coordinate of the origin (on-screen)
  2241. * @param y defines the y coordinate of the origin (on-screen)
  2242. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2243. * @param camera defines the camera to use for the picking
  2244. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2245. * @returns a Ray
  2246. */
  2247. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2248. /**
  2249. * Creates a ray that can be used to pick in the scene
  2250. * @param x defines the x coordinate of the origin (on-screen)
  2251. * @param y defines the y coordinate of the origin (on-screen)
  2252. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2253. * @param result defines the ray where to store the picking ray
  2254. * @param camera defines the camera to use for the picking
  2255. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2256. * @returns the current scene
  2257. */
  2258. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2259. /**
  2260. * Creates a ray that can be used to pick in the scene
  2261. * @param x defines the x coordinate of the origin (on-screen)
  2262. * @param y defines the y coordinate of the origin (on-screen)
  2263. * @param camera defines the camera to use for the picking
  2264. * @returns a Ray
  2265. */
  2266. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2267. /**
  2268. * Creates a ray that can be used to pick in the scene
  2269. * @param x defines the x coordinate of the origin (on-screen)
  2270. * @param y defines the y coordinate of the origin (on-screen)
  2271. * @param result defines the ray where to store the picking ray
  2272. * @param camera defines the camera to use for the picking
  2273. * @returns the current scene
  2274. */
  2275. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2276. private _internalPick;
  2277. private _internalMultiPick;
  2278. private _tempPickingRay;
  2279. /** Launch a ray to try to pick a mesh in the scene
  2280. * @param x position on screen
  2281. * @param y position on screen
  2282. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2283. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2284. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2285. * @returns a PickingInfo
  2286. */
  2287. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2288. private _cachedRayForTransform;
  2289. /** Use the given ray to pick a mesh in the scene
  2290. * @param ray The ray to use to pick meshes
  2291. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2292. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2293. * @returns a PickingInfo
  2294. */
  2295. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2296. /**
  2297. * Launch a ray to try to pick a mesh in the scene
  2298. * @param x X position on screen
  2299. * @param y Y position on screen
  2300. * @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
  2301. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2302. * @returns an array of PickingInfo
  2303. */
  2304. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2305. /**
  2306. * Launch a ray to try to pick a mesh in the scene
  2307. * @param ray Ray to use
  2308. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2309. * @returns an array of PickingInfo
  2310. */
  2311. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2312. /**
  2313. * Force the value of meshUnderPointer
  2314. * @param mesh defines the mesh to use
  2315. */
  2316. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2317. /**
  2318. * Gets the mesh under the pointer
  2319. * @returns a Mesh or null if no mesh is under the pointer
  2320. */
  2321. getPointerOverMesh(): Nullable<AbstractMesh>;
  2322. /**
  2323. * Gets the current physics engine
  2324. * @returns a PhysicsEngine or null if none attached
  2325. */
  2326. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2327. /**
  2328. * Enables physics to the current scene
  2329. * @param gravity defines the scene's gravity for the physics engine
  2330. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2331. * @return a boolean indicating if the physics engine was initialized
  2332. */
  2333. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2334. /**
  2335. * Disables and disposes the physics engine associated with the scene
  2336. */
  2337. disablePhysicsEngine(): void;
  2338. /**
  2339. * Gets a boolean indicating if there is an active physics engine
  2340. * @returns a boolean indicating if there is an active physics engine
  2341. */
  2342. isPhysicsEnabled(): boolean;
  2343. /**
  2344. * Deletes a physics compound impostor
  2345. * @param compound defines the compound to delete
  2346. */
  2347. deleteCompoundImpostor(compound: any): void;
  2348. /** @hidden */
  2349. /** @hidden */
  2350. private _getByTags;
  2351. /**
  2352. * Get a list of meshes by tags
  2353. * @param tagsQuery defines the tags query to use
  2354. * @param forEach defines a predicate used to filter results
  2355. * @returns an array of Mesh
  2356. */
  2357. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2358. /**
  2359. * Get a list of cameras by tags
  2360. * @param tagsQuery defines the tags query to use
  2361. * @param forEach defines a predicate used to filter results
  2362. * @returns an array of Camera
  2363. */
  2364. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2365. /**
  2366. * Get a list of lights by tags
  2367. * @param tagsQuery defines the tags query to use
  2368. * @param forEach defines a predicate used to filter results
  2369. * @returns an array of Light
  2370. */
  2371. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2372. /**
  2373. * Get a list of materials by tags
  2374. * @param tagsQuery defines the tags query to use
  2375. * @param forEach defines a predicate used to filter results
  2376. * @returns an array of Material
  2377. */
  2378. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2379. /**
  2380. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2381. * This allowed control for front to back rendering or reversly depending of the special needs.
  2382. *
  2383. * @param renderingGroupId The rendering group id corresponding to its index
  2384. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2385. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2386. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2387. */
  2388. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2389. /**
  2390. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2391. *
  2392. * @param renderingGroupId The rendering group id corresponding to its index
  2393. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2394. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2395. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2396. */
  2397. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2398. /**
  2399. * Gets the current auto clear configuration for one rendering group of the rendering
  2400. * manager.
  2401. * @param index the rendering group index to get the information for
  2402. * @returns The auto clear setup for the requested rendering group
  2403. */
  2404. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2405. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2406. blockMaterialDirtyMechanism: boolean;
  2407. /**
  2408. * Will flag all materials as dirty to trigger new shader compilation
  2409. * @param flag defines the flag used to specify which material part must be marked as dirty
  2410. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2411. */
  2412. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2413. /** @hidden */
  2414. /** @hidden */
  2415. }
  2416. }
  2417. declare module BABYLON {
  2418. /**
  2419. * Groups all the scene component constants in one place to ease maintenance.
  2420. * @hidden
  2421. */
  2422. class SceneComponentConstants {
  2423. static readonly NAME_EFFECTLAYER: string;
  2424. static readonly NAME_LAYER: string;
  2425. static readonly NAME_LENSFLARESYSTEM: string;
  2426. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2427. static readonly NAME_PARTICLESYSTEM: string;
  2428. static readonly NAME_GAMEPAD: string;
  2429. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2430. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2431. static readonly NAME_DEPTHRENDERER: string;
  2432. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2433. static readonly NAME_SPRITE: string;
  2434. static readonly NAME_OUTLINERENDERER: string;
  2435. static readonly NAME_PROCEDURALTEXTURE: string;
  2436. static readonly NAME_SHADOWGENERATOR: string;
  2437. static readonly NAME_OCTREE: string;
  2438. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2439. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2440. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2441. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2442. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2443. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2444. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2445. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2446. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2447. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2448. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2449. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2450. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2451. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2452. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2453. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2454. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2455. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2456. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2457. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2458. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2459. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2460. static readonly STEP_POINTERMOVE_SPRITE: number;
  2461. static readonly STEP_POINTERDOWN_SPRITE: number;
  2462. static readonly STEP_POINTERUP_SPRITE: number;
  2463. }
  2464. /**
  2465. * This represents a scene component.
  2466. *
  2467. * This is used to decouple the dependency the scene is having on the different workloads like
  2468. * layers, post processes...
  2469. */
  2470. interface ISceneComponent {
  2471. /**
  2472. * The name of the component. Each component must have a unique name.
  2473. */
  2474. name: string;
  2475. /**
  2476. * The scene the component belongs to.
  2477. */
  2478. scene: Scene;
  2479. /**
  2480. * Register the component to one instance of a scene.
  2481. */
  2482. register(): void;
  2483. /**
  2484. * Rebuilds the elements related to this component in case of
  2485. * context lost for instance.
  2486. */
  2487. rebuild(): void;
  2488. /**
  2489. * Disposes the component and the associated ressources.
  2490. */
  2491. dispose(): void;
  2492. }
  2493. /**
  2494. * This represents a SERIALIZABLE scene component.
  2495. *
  2496. * This extends Scene Component to add Serialization methods on top.
  2497. */
  2498. interface ISceneSerializableComponent extends ISceneComponent {
  2499. /**
  2500. * Adds all the element from the container to the scene
  2501. * @param container the container holding the elements
  2502. */
  2503. addFromContainer(container: AbstractScene): void;
  2504. /**
  2505. * Removes all the elements in the container from the scene
  2506. * @param container contains the elements to remove
  2507. */
  2508. removeFromContainer(container: AbstractScene): void;
  2509. /**
  2510. * Serializes the component data to the specified json object
  2511. * @param serializationObject The object to serialize to
  2512. */
  2513. serialize(serializationObject: any): void;
  2514. }
  2515. /**
  2516. * Strong typing of a Mesh related stage step action
  2517. */
  2518. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2519. /**
  2520. * Strong typing of a Evaluate Sub Mesh related stage step action
  2521. */
  2522. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2523. /**
  2524. * Strong typing of a Active Mesh related stage step action
  2525. */
  2526. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2527. /**
  2528. * Strong typing of a Camera related stage step action
  2529. */
  2530. type CameraStageAction = (camera: Camera) => void;
  2531. /**
  2532. * Strong typing of a RenderingGroup related stage step action
  2533. */
  2534. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2535. /**
  2536. * Strong typing of a Mesh Render related stage step action
  2537. */
  2538. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2539. /**
  2540. * Strong typing of a simple stage step action
  2541. */
  2542. type SimpleStageAction = () => void;
  2543. /**
  2544. * Strong typing of a render target action.
  2545. */
  2546. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2547. /**
  2548. * Strong typing of a pointer move action.
  2549. */
  2550. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2551. /**
  2552. * Strong typing of a pointer up/down action.
  2553. */
  2554. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2555. /**
  2556. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2557. * @hidden
  2558. */
  2559. class Stage<T extends Function> extends Array<{
  2560. index: number;
  2561. component: ISceneComponent;
  2562. action: T;
  2563. }> {
  2564. /**
  2565. * Hide ctor from the rest of the world.
  2566. * @param items The items to add.
  2567. */
  2568. private constructor();
  2569. /**
  2570. * Creates a new Stage.
  2571. * @returns A new instance of a Stage
  2572. */
  2573. static Create<T extends Function>(): Stage<T>;
  2574. /**
  2575. * Registers a step in an ordered way in the targeted stage.
  2576. * @param index Defines the position to register the step in
  2577. * @param component Defines the component attached to the step
  2578. * @param action Defines the action to launch during the step
  2579. */
  2580. registerStep(index: number, component: ISceneComponent, action: T): void;
  2581. /**
  2582. * Clears all the steps from the stage.
  2583. */
  2584. clear(): void;
  2585. }
  2586. }
  2587. declare module BABYLON {
  2588. type Nullable<T> = T | null;
  2589. type float = number;
  2590. type double = number;
  2591. type int = number;
  2592. type FloatArray = number[] | Float32Array;
  2593. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2594. /**
  2595. * Alias for types that can be used by a Buffer or VertexBuffer.
  2596. */
  2597. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2598. }
  2599. declare module BABYLON {
  2600. /**
  2601. * The action to be carried out following a trigger
  2602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2603. */
  2604. class Action {
  2605. /** the trigger, with or without parameters, for the action */
  2606. triggerOptions: any;
  2607. /**
  2608. * Trigger for the action
  2609. */
  2610. trigger: number;
  2611. /**
  2612. * Internal only - manager for action
  2613. * @hidden
  2614. */
  2615. private _nextActiveAction;
  2616. private _child;
  2617. private _condition?;
  2618. private _triggerParameter;
  2619. /**
  2620. * An event triggered prior to action being executed.
  2621. */
  2622. onBeforeExecuteObservable: Observable<Action>;
  2623. /**
  2624. * Creates a new Action
  2625. * @param triggerOptions the trigger, with or without parameters, for the action
  2626. * @param condition an optional determinant of action
  2627. */
  2628. constructor(
  2629. /** the trigger, with or without parameters, for the action */
  2630. triggerOptions: any, condition?: Condition);
  2631. /**
  2632. * Internal only
  2633. * @hidden
  2634. */
  2635. /**
  2636. * Gets the trigger parameters
  2637. * @returns the trigger parameters
  2638. */
  2639. getTriggerParameter(): any;
  2640. /**
  2641. * Internal only - executes current action event
  2642. * @hidden
  2643. */
  2644. /**
  2645. * Execute placeholder for child classes
  2646. * @param evt optional action event
  2647. */
  2648. execute(evt?: ActionEvent): void;
  2649. /**
  2650. * Skips to next active action
  2651. */
  2652. skipToNextActiveAction(): void;
  2653. /**
  2654. * Adds action to chain of actions, may be a DoNothingAction
  2655. * @param action defines the next action to execute
  2656. * @returns The action passed in
  2657. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2658. */
  2659. then(action: Action): Action;
  2660. /**
  2661. * Internal only
  2662. * @hidden
  2663. */
  2664. /**
  2665. * Internal only
  2666. * @hidden
  2667. */
  2668. /**
  2669. * Serialize placeholder for child classes
  2670. * @param parent of child
  2671. * @returns the serialized object
  2672. */
  2673. serialize(parent: any): any;
  2674. /**
  2675. * Internal only called by serialize
  2676. * @hidden
  2677. */
  2678. protected _serialize(serializedAction: any, parent?: any): any;
  2679. /**
  2680. * Internal only
  2681. * @hidden
  2682. */
  2683. private static _SerializeValueAsString: (value: any) => string;
  2684. /**
  2685. * Internal only
  2686. * @hidden
  2687. */
  2688. private static _GetTargetProperty: (target: Scene | Node) => {
  2689. name: string;
  2690. targetType: string;
  2691. value: string;
  2692. };
  2693. }
  2694. }
  2695. declare module BABYLON {
  2696. /**
  2697. * ActionEvent is the event being sent when an action is triggered.
  2698. */
  2699. class ActionEvent {
  2700. /** The mesh or sprite that triggered the action */
  2701. source: any;
  2702. /** The X mouse cursor position at the time of the event */
  2703. pointerX: number;
  2704. /** The Y mouse cursor position at the time of the event */
  2705. pointerY: number;
  2706. /** The mesh that is currently pointed at (can be null) */
  2707. meshUnderPointer: Nullable<AbstractMesh>;
  2708. /** the original (browser) event that triggered the ActionEvent */
  2709. sourceEvent?: any;
  2710. /** additional data for the event */
  2711. additionalData?: any;
  2712. /**
  2713. * Creates a new ActionEvent
  2714. * @param source The mesh or sprite that triggered the action
  2715. * @param pointerX The X mouse cursor position at the time of the event
  2716. * @param pointerY The Y mouse cursor position at the time of the event
  2717. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2718. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2719. * @param additionalData additional data for the event
  2720. */
  2721. constructor(
  2722. /** The mesh or sprite that triggered the action */
  2723. source: any,
  2724. /** The X mouse cursor position at the time of the event */
  2725. pointerX: number,
  2726. /** The Y mouse cursor position at the time of the event */
  2727. pointerY: number,
  2728. /** The mesh that is currently pointed at (can be null) */
  2729. meshUnderPointer: Nullable<AbstractMesh>,
  2730. /** the original (browser) event that triggered the ActionEvent */
  2731. sourceEvent?: any,
  2732. /** additional data for the event */
  2733. additionalData?: any);
  2734. /**
  2735. * Helper function to auto-create an ActionEvent from a source mesh.
  2736. * @param source The source mesh that triggered the event
  2737. * @param evt The original (browser) event
  2738. * @param additionalData additional data for the event
  2739. * @returns the new ActionEvent
  2740. */
  2741. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2742. /**
  2743. * Helper function to auto-create an ActionEvent from a source sprite
  2744. * @param source The source sprite that triggered the event
  2745. * @param scene Scene associated with the sprite
  2746. * @param evt The original (browser) event
  2747. * @param additionalData additional data for the event
  2748. * @returns the new ActionEvent
  2749. */
  2750. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2751. /**
  2752. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2753. * @param scene the scene where the event occurred
  2754. * @param evt The original (browser) event
  2755. * @returns the new ActionEvent
  2756. */
  2757. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2758. /**
  2759. * Helper function to auto-create an ActionEvent from a primitive
  2760. * @param prim defines the target primitive
  2761. * @param pointerPos defines the pointer position
  2762. * @param evt The original (browser) event
  2763. * @param additionalData additional data for the event
  2764. * @returns the new ActionEvent
  2765. */
  2766. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2767. }
  2768. /**
  2769. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2770. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2772. */
  2773. class ActionManager {
  2774. private static _NothingTrigger;
  2775. private static _OnPickTrigger;
  2776. private static _OnLeftPickTrigger;
  2777. private static _OnRightPickTrigger;
  2778. private static _OnCenterPickTrigger;
  2779. private static _OnPickDownTrigger;
  2780. private static _OnDoublePickTrigger;
  2781. private static _OnPickUpTrigger;
  2782. private static _OnLongPressTrigger;
  2783. private static _OnPointerOverTrigger;
  2784. private static _OnPointerOutTrigger;
  2785. private static _OnEveryFrameTrigger;
  2786. private static _OnIntersectionEnterTrigger;
  2787. private static _OnIntersectionExitTrigger;
  2788. private static _OnKeyDownTrigger;
  2789. private static _OnKeyUpTrigger;
  2790. private static _OnPickOutTrigger;
  2791. /**
  2792. * Nothing
  2793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2794. */
  2795. static readonly NothingTrigger: number;
  2796. /**
  2797. * On pick
  2798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2799. */
  2800. static readonly OnPickTrigger: number;
  2801. /**
  2802. * On left pick
  2803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2804. */
  2805. static readonly OnLeftPickTrigger: number;
  2806. /**
  2807. * On right pick
  2808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2809. */
  2810. static readonly OnRightPickTrigger: number;
  2811. /**
  2812. * On center pick
  2813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2814. */
  2815. static readonly OnCenterPickTrigger: number;
  2816. /**
  2817. * On pick down
  2818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2819. */
  2820. static readonly OnPickDownTrigger: number;
  2821. /**
  2822. * On double pick
  2823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2824. */
  2825. static readonly OnDoublePickTrigger: number;
  2826. /**
  2827. * On pick up
  2828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2829. */
  2830. static readonly OnPickUpTrigger: number;
  2831. /**
  2832. * On pick out.
  2833. * This trigger will only be raised if you also declared a OnPickDown
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2835. */
  2836. static readonly OnPickOutTrigger: number;
  2837. /**
  2838. * On long press
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly OnLongPressTrigger: number;
  2842. /**
  2843. * On pointer over
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2845. */
  2846. static readonly OnPointerOverTrigger: number;
  2847. /**
  2848. * On pointer out
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly OnPointerOutTrigger: number;
  2852. /**
  2853. * On every frame
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnEveryFrameTrigger: number;
  2857. /**
  2858. * On intersection enter
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnIntersectionEnterTrigger: number;
  2862. /**
  2863. * On intersection exit
  2864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2865. */
  2866. static readonly OnIntersectionExitTrigger: number;
  2867. /**
  2868. * On key down
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2870. */
  2871. static readonly OnKeyDownTrigger: number;
  2872. /**
  2873. * On key up
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly OnKeyUpTrigger: number;
  2877. /** Gets the list of active triggers */
  2878. static Triggers: {
  2879. [key: string]: number;
  2880. };
  2881. /** Gets the list of actions */
  2882. actions: Action[];
  2883. /** Gets the cursor to use when hovering items */
  2884. hoverCursor: string;
  2885. private _scene;
  2886. /**
  2887. * Creates a new action manager
  2888. * @param scene defines the hosting scene
  2889. */
  2890. constructor(scene: Scene);
  2891. /**
  2892. * Releases all associated resources
  2893. */
  2894. dispose(): void;
  2895. /**
  2896. * Gets hosting scene
  2897. * @returns the hosting scene
  2898. */
  2899. getScene(): Scene;
  2900. /**
  2901. * Does this action manager handles actions of any of the given triggers
  2902. * @param triggers defines the triggers to be tested
  2903. * @return a boolean indicating whether one (or more) of the triggers is handled
  2904. */
  2905. hasSpecificTriggers(triggers: number[]): boolean;
  2906. /**
  2907. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2908. * speed.
  2909. * @param triggerA defines the trigger to be tested
  2910. * @param triggerB defines the trigger to be tested
  2911. * @return a boolean indicating whether one (or more) of the triggers is handled
  2912. */
  2913. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2914. /**
  2915. * Does this action manager handles actions of a given trigger
  2916. * @param trigger defines the trigger to be tested
  2917. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2918. * @return whether the trigger is handled
  2919. */
  2920. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2921. /**
  2922. * Does this action manager has pointer triggers
  2923. */
  2924. readonly hasPointerTriggers: boolean;
  2925. /**
  2926. * Does this action manager has pick triggers
  2927. */
  2928. readonly hasPickTriggers: boolean;
  2929. /**
  2930. * Does exist one action manager with at least one trigger
  2931. **/
  2932. static readonly HasTriggers: boolean;
  2933. /**
  2934. * Does exist one action manager with at least one pick trigger
  2935. **/
  2936. static readonly HasPickTriggers: boolean;
  2937. /**
  2938. * Does exist one action manager that handles actions of a given trigger
  2939. * @param trigger defines the trigger to be tested
  2940. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2941. **/
  2942. static HasSpecificTrigger(trigger: number): boolean;
  2943. /**
  2944. * Registers an action to this action manager
  2945. * @param action defines the action to be registered
  2946. * @return the action amended (prepared) after registration
  2947. */
  2948. registerAction(action: Action): Nullable<Action>;
  2949. /**
  2950. * Unregisters an action to this action manager
  2951. * @param action defines the action to be unregistered
  2952. * @return a boolean indicating whether the action has been unregistered
  2953. */
  2954. unregisterAction(action: Action): Boolean;
  2955. /**
  2956. * Process a specific trigger
  2957. * @param trigger defines the trigger to process
  2958. * @param evt defines the event details to be processed
  2959. */
  2960. processTrigger(trigger: number, evt?: ActionEvent): void;
  2961. /** @hidden */
  2962. /** @hidden */
  2963. /**
  2964. * Serialize this manager to a JSON object
  2965. * @param name defines the property name to store this manager
  2966. * @returns a JSON representation of this manager
  2967. */
  2968. serialize(name: string): any;
  2969. /**
  2970. * Creates a new ActionManager from a JSON data
  2971. * @param parsedActions defines the JSON data to read from
  2972. * @param object defines the hosting mesh
  2973. * @param scene defines the hosting scene
  2974. */
  2975. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2976. /**
  2977. * Get a trigger name by index
  2978. * @param trigger defines the trigger index
  2979. * @returns a trigger name
  2980. */
  2981. static GetTriggerName(trigger: number): string;
  2982. }
  2983. }
  2984. declare module BABYLON {
  2985. /**
  2986. * A Condition applied to an Action
  2987. */
  2988. class Condition {
  2989. /**
  2990. * Internal only - manager for action
  2991. * @hidden
  2992. */
  2993. /**
  2994. * Internal only
  2995. * @hidden
  2996. */
  2997. /**
  2998. * Internal only
  2999. * @hidden
  3000. */
  3001. /**
  3002. * Creates a new Condition
  3003. * @param actionManager the manager of the action the condition is applied to
  3004. */
  3005. constructor(actionManager: ActionManager);
  3006. /**
  3007. * Check if the current condition is valid
  3008. * @returns a boolean
  3009. */
  3010. isValid(): boolean;
  3011. /**
  3012. * Internal only
  3013. * @hidden
  3014. */
  3015. /**
  3016. * Internal only
  3017. * @hidden
  3018. */
  3019. /**
  3020. * Serialize placeholder for child classes
  3021. * @returns the serialized object
  3022. */
  3023. serialize(): any;
  3024. /**
  3025. * Internal only
  3026. * @hidden
  3027. */
  3028. protected _serialize(serializedCondition: any): any;
  3029. }
  3030. /**
  3031. * Defines specific conditional operators as extensions of Condition
  3032. */
  3033. class ValueCondition extends Condition {
  3034. /** path to specify the property of the target the conditional operator uses */
  3035. propertyPath: string;
  3036. /** the value compared by the conditional operator against the current value of the property */
  3037. value: any;
  3038. /** the conditional operator, default ValueCondition.IsEqual */
  3039. operator: number;
  3040. /**
  3041. * Internal only
  3042. * @hidden
  3043. */
  3044. private static _IsEqual;
  3045. /**
  3046. * Internal only
  3047. * @hidden
  3048. */
  3049. private static _IsDifferent;
  3050. /**
  3051. * Internal only
  3052. * @hidden
  3053. */
  3054. private static _IsGreater;
  3055. /**
  3056. * Internal only
  3057. * @hidden
  3058. */
  3059. private static _IsLesser;
  3060. /**
  3061. * returns the number for IsEqual
  3062. */
  3063. static readonly IsEqual: number;
  3064. /**
  3065. * Returns the number for IsDifferent
  3066. */
  3067. static readonly IsDifferent: number;
  3068. /**
  3069. * Returns the number for IsGreater
  3070. */
  3071. static readonly IsGreater: number;
  3072. /**
  3073. * Returns the number for IsLesser
  3074. */
  3075. static readonly IsLesser: number;
  3076. /**
  3077. * Internal only The action manager for the condition
  3078. * @hidden
  3079. */
  3080. /**
  3081. * Internal only
  3082. * @hidden
  3083. */
  3084. private _target;
  3085. /**
  3086. * Internal only
  3087. * @hidden
  3088. */
  3089. private _effectiveTarget;
  3090. /**
  3091. * Internal only
  3092. * @hidden
  3093. */
  3094. private _property;
  3095. /**
  3096. * Creates a new ValueCondition
  3097. * @param actionManager manager for the action the condition applies to
  3098. * @param target for the action
  3099. * @param propertyPath path to specify the property of the target the conditional operator uses
  3100. * @param value the value compared by the conditional operator against the current value of the property
  3101. * @param operator the conditional operator, default ValueCondition.IsEqual
  3102. */
  3103. constructor(actionManager: ActionManager, target: any,
  3104. /** path to specify the property of the target the conditional operator uses */
  3105. propertyPath: string,
  3106. /** the value compared by the conditional operator against the current value of the property */
  3107. value: any,
  3108. /** the conditional operator, default ValueCondition.IsEqual */
  3109. operator?: number);
  3110. /**
  3111. * Compares the given value with the property value for the specified conditional operator
  3112. * @returns the result of the comparison
  3113. */
  3114. isValid(): boolean;
  3115. /**
  3116. * Serialize the ValueCondition into a JSON compatible object
  3117. * @returns serialization object
  3118. */
  3119. serialize(): any;
  3120. /**
  3121. * Gets the name of the conditional operator for the ValueCondition
  3122. * @param operator the conditional operator
  3123. * @returns the name
  3124. */
  3125. static GetOperatorName(operator: number): string;
  3126. }
  3127. /**
  3128. * Defines a predicate condition as an extension of Condition
  3129. */
  3130. class PredicateCondition extends Condition {
  3131. /** defines the predicate function used to validate the condition */
  3132. predicate: () => boolean;
  3133. /**
  3134. * Internal only - manager for action
  3135. * @hidden
  3136. */
  3137. /**
  3138. * Creates a new PredicateCondition
  3139. * @param actionManager manager for the action the condition applies to
  3140. * @param predicate defines the predicate function used to validate the condition
  3141. */
  3142. constructor(actionManager: ActionManager,
  3143. /** defines the predicate function used to validate the condition */
  3144. predicate: () => boolean);
  3145. /**
  3146. * @returns the validity of the predicate condition
  3147. */
  3148. isValid(): boolean;
  3149. }
  3150. /**
  3151. * Defines a state condition as an extension of Condition
  3152. */
  3153. class StateCondition extends Condition {
  3154. value: string;
  3155. /**
  3156. * Internal only - manager for action
  3157. * @hidden
  3158. */
  3159. /**
  3160. * Internal only
  3161. * @hidden
  3162. */
  3163. private _target;
  3164. /**
  3165. * Creates a new StateCondition
  3166. * @param actionManager manager for the action the condition applies to
  3167. * @param target of the condition
  3168. * @param value to compare with target state
  3169. */
  3170. constructor(actionManager: ActionManager, target: any, value: string);
  3171. /**
  3172. * @returns the validity of the state
  3173. */
  3174. isValid(): boolean;
  3175. /**
  3176. * Serialize the StateCondition into a JSON compatible object
  3177. * @returns serialization object
  3178. */
  3179. serialize(): any;
  3180. }
  3181. }
  3182. declare module BABYLON {
  3183. class SwitchBooleanAction extends Action {
  3184. propertyPath: string;
  3185. private _target;
  3186. private _effectiveTarget;
  3187. private _property;
  3188. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3189. /** @hidden */
  3190. execute(): void;
  3191. serialize(parent: any): any;
  3192. }
  3193. class SetStateAction extends Action {
  3194. value: string;
  3195. private _target;
  3196. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3197. execute(): void;
  3198. serialize(parent: any): any;
  3199. }
  3200. class SetValueAction extends Action {
  3201. propertyPath: string;
  3202. value: any;
  3203. private _target;
  3204. private _effectiveTarget;
  3205. private _property;
  3206. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3207. /** @hidden */
  3208. execute(): void;
  3209. serialize(parent: any): any;
  3210. }
  3211. class IncrementValueAction extends Action {
  3212. propertyPath: string;
  3213. value: any;
  3214. private _target;
  3215. private _effectiveTarget;
  3216. private _property;
  3217. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3218. /** @hidden */
  3219. execute(): void;
  3220. serialize(parent: any): any;
  3221. }
  3222. class PlayAnimationAction extends Action {
  3223. from: number;
  3224. to: number;
  3225. loop?: boolean | undefined;
  3226. private _target;
  3227. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3228. /** @hidden */
  3229. execute(): void;
  3230. serialize(parent: any): any;
  3231. }
  3232. class StopAnimationAction extends Action {
  3233. private _target;
  3234. constructor(triggerOptions: any, target: any, condition?: Condition);
  3235. /** @hidden */
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class DoNothingAction extends Action {
  3240. constructor(triggerOptions?: any, condition?: Condition);
  3241. execute(): void;
  3242. serialize(parent: any): any;
  3243. }
  3244. class CombineAction extends Action {
  3245. children: Action[];
  3246. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3247. /** @hidden */
  3248. execute(evt: ActionEvent): void;
  3249. serialize(parent: any): any;
  3250. }
  3251. class ExecuteCodeAction extends Action {
  3252. func: (evt: ActionEvent) => void;
  3253. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3254. execute(evt: ActionEvent): void;
  3255. }
  3256. class SetParentAction extends Action {
  3257. private _parent;
  3258. private _target;
  3259. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3260. /** @hidden */
  3261. execute(): void;
  3262. serialize(parent: any): any;
  3263. }
  3264. class PlaySoundAction extends Action {
  3265. private _sound;
  3266. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3267. /** @hidden */
  3268. execute(): void;
  3269. serialize(parent: any): any;
  3270. }
  3271. class StopSoundAction extends Action {
  3272. private _sound;
  3273. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3274. /** @hidden */
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. }
  3279. declare module BABYLON {
  3280. class InterpolateValueAction extends Action {
  3281. propertyPath: string;
  3282. value: any;
  3283. duration: number;
  3284. stopOtherAnimations?: boolean | undefined;
  3285. onInterpolationDone?: (() => void) | undefined;
  3286. private _target;
  3287. private _effectiveTarget;
  3288. private _property;
  3289. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3290. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3291. /** @hidden */
  3292. execute(): void;
  3293. serialize(parent: any): any;
  3294. }
  3295. }
  3296. declare module BABYLON {
  3297. /**
  3298. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3300. */
  3301. class Analyser {
  3302. /**
  3303. * Gets or sets the smoothing
  3304. * @ignorenaming
  3305. */
  3306. SMOOTHING: number;
  3307. /**
  3308. * Gets or sets the FFT table size
  3309. * @ignorenaming
  3310. */
  3311. FFT_SIZE: number;
  3312. /**
  3313. * Gets or sets the bar graph amplitude
  3314. * @ignorenaming
  3315. */
  3316. BARGRAPHAMPLITUDE: number;
  3317. /**
  3318. * Gets or sets the position of the debug canvas
  3319. * @ignorenaming
  3320. */
  3321. DEBUGCANVASPOS: {
  3322. x: number;
  3323. y: number;
  3324. };
  3325. /**
  3326. * Gets or sets the debug canvas size
  3327. * @ignorenaming
  3328. */
  3329. DEBUGCANVASSIZE: {
  3330. width: number;
  3331. height: number;
  3332. };
  3333. private _byteFreqs;
  3334. private _byteTime;
  3335. private _floatFreqs;
  3336. private _webAudioAnalyser;
  3337. private _debugCanvas;
  3338. private _debugCanvasContext;
  3339. private _scene;
  3340. private _registerFunc;
  3341. private _audioEngine;
  3342. /**
  3343. * Creates a new analyser
  3344. * @param scene defines hosting scene
  3345. */
  3346. constructor(scene: Scene);
  3347. /**
  3348. * Get the number of data values you will have to play with for the visualization
  3349. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3350. * @returns a number
  3351. */
  3352. getFrequencyBinCount(): number;
  3353. /**
  3354. * Gets the current frequency data as a byte array
  3355. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3356. * @returns a Uint8Array
  3357. */
  3358. getByteFrequencyData(): Uint8Array;
  3359. /**
  3360. * Gets the current waveform as a byte array
  3361. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3362. * @returns a Uint8Array
  3363. */
  3364. getByteTimeDomainData(): Uint8Array;
  3365. /**
  3366. * Gets the current frequency data as a float array
  3367. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3368. * @returns a Float32Array
  3369. */
  3370. getFloatFrequencyData(): Float32Array;
  3371. /**
  3372. * Renders the debug canvas
  3373. */
  3374. drawDebugCanvas(): void;
  3375. /**
  3376. * Stops rendering the debug canvas and removes it
  3377. */
  3378. stopDebugCanvas(): void;
  3379. /**
  3380. * Connects two audio nodes
  3381. * @param inputAudioNode defines first node to connect
  3382. * @param outputAudioNode defines second node to connect
  3383. */
  3384. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3385. /**
  3386. * Releases all associated resources
  3387. */
  3388. dispose(): void;
  3389. }
  3390. }
  3391. declare module BABYLON {
  3392. class AudioEngine {
  3393. private _audioContext;
  3394. private _audioContextInitialized;
  3395. canUseWebAudio: boolean;
  3396. masterGain: GainNode;
  3397. private _connectedAnalyser;
  3398. WarnedWebAudioUnsupported: boolean;
  3399. unlocked: boolean;
  3400. onAudioUnlocked: () => any;
  3401. isMP3supported: boolean;
  3402. isOGGsupported: boolean;
  3403. readonly audioContext: Nullable<AudioContext>;
  3404. constructor();
  3405. private _unlockiOSaudio;
  3406. private _initializeAudioContext;
  3407. dispose(): void;
  3408. getGlobalVolume(): number;
  3409. setGlobalVolume(newVolume: number): void;
  3410. connectToAnalyser(analyser: Analyser): void;
  3411. }
  3412. }
  3413. declare module BABYLON {
  3414. class Sound {
  3415. name: string;
  3416. autoplay: boolean;
  3417. loop: boolean;
  3418. useCustomAttenuation: boolean;
  3419. soundTrackId: number;
  3420. spatialSound: boolean;
  3421. refDistance: number;
  3422. rolloffFactor: number;
  3423. maxDistance: number;
  3424. distanceModel: string;
  3425. private _panningModel;
  3426. onended: () => any;
  3427. /**
  3428. * Observable event when the current playing sound finishes.
  3429. */
  3430. onEndedObservable: Observable<Sound>;
  3431. private _playbackRate;
  3432. private _streaming;
  3433. private _startTime;
  3434. private _startOffset;
  3435. private _position;
  3436. /** @hidden */
  3437. private _localDirection;
  3438. private _volume;
  3439. private _isReadyToPlay;
  3440. isPlaying: boolean;
  3441. isPaused: boolean;
  3442. private _isDirectional;
  3443. private _readyToPlayCallback;
  3444. private _audioBuffer;
  3445. private _soundSource;
  3446. private _streamingSource;
  3447. private _soundPanner;
  3448. private _soundGain;
  3449. private _inputAudioNode;
  3450. private _outputAudioNode;
  3451. private _coneInnerAngle;
  3452. private _coneOuterAngle;
  3453. private _coneOuterGain;
  3454. private _scene;
  3455. private _connectedMesh;
  3456. private _customAttenuationFunction;
  3457. private _registerFunc;
  3458. private _isOutputConnected;
  3459. private _htmlAudioElement;
  3460. private _urlType;
  3461. /**
  3462. * Create a sound and attach it to a scene
  3463. * @param name Name of your sound
  3464. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  3465. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3466. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3467. */
  3468. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3469. dispose(): void;
  3470. isReady(): boolean;
  3471. private _soundLoaded;
  3472. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3473. updateOptions(options: any): void;
  3474. private _createSpatialParameters;
  3475. private _updateSpatialParameters;
  3476. switchPanningModelToHRTF(): void;
  3477. switchPanningModelToEqualPower(): void;
  3478. private _switchPanningModel;
  3479. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3480. /**
  3481. * Transform this sound into a directional source
  3482. * @param coneInnerAngle Size of the inner cone in degree
  3483. * @param coneOuterAngle Size of the outer cone in degree
  3484. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3485. */
  3486. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3487. /**
  3488. * Gets or sets the inner angle for the directional cone.
  3489. */
  3490. /**
  3491. * Gets or sets the inner angle for the directional cone.
  3492. */
  3493. directionalConeInnerAngle: number;
  3494. /**
  3495. * Gets or sets the outer angle for the directional cone.
  3496. */
  3497. /**
  3498. * Gets or sets the outer angle for the directional cone.
  3499. */
  3500. directionalConeOuterAngle: number;
  3501. setPosition(newPosition: Vector3): void;
  3502. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3503. private _updateDirection;
  3504. updateDistanceFromListener(): void;
  3505. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3506. /**
  3507. * Play the sound
  3508. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3509. * @param offset (optional) Start the sound setting it at a specific time
  3510. */
  3511. play(time?: number, offset?: number): void;
  3512. private _onended;
  3513. /**
  3514. * Stop the sound
  3515. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3516. */
  3517. stop(time?: number): void;
  3518. pause(): void;
  3519. setVolume(newVolume: number, time?: number): void;
  3520. setPlaybackRate(newPlaybackRate: number): void;
  3521. getVolume(): number;
  3522. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3523. detachFromMesh(): void;
  3524. private _onRegisterAfterWorldMatrixUpdate;
  3525. clone(): Nullable<Sound>;
  3526. getAudioBuffer(): AudioBuffer | null;
  3527. serialize(): any;
  3528. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3529. }
  3530. }
  3531. declare module BABYLON {
  3532. class SoundTrack {
  3533. private _outputAudioNode;
  3534. private _scene;
  3535. id: number;
  3536. soundCollection: Array<Sound>;
  3537. private _isMainTrack;
  3538. private _connectedAnalyser;
  3539. private _options;
  3540. private _isInitialized;
  3541. constructor(scene: Scene, options?: any);
  3542. private _initializeSoundTrackAudioGraph;
  3543. dispose(): void;
  3544. AddSound(sound: Sound): void;
  3545. RemoveSound(sound: Sound): void;
  3546. setVolume(newVolume: number): void;
  3547. switchPanningModelToHRTF(): void;
  3548. switchPanningModelToEqualPower(): void;
  3549. connectToAnalyser(analyser: Analyser): void;
  3550. }
  3551. }
  3552. declare module BABYLON {
  3553. /**
  3554. * Wraps one or more Sound objects and selects one with random weight for playback.
  3555. */
  3556. class WeightedSound {
  3557. /** When true a Sound will be selected and played when the current playing Sound completes. */
  3558. loop: boolean;
  3559. private _coneInnerAngle;
  3560. private _coneOuterAngle;
  3561. private _volume;
  3562. /** A Sound is currently playing. */
  3563. isPlaying: boolean;
  3564. /** A Sound is currently paused. */
  3565. isPaused: boolean;
  3566. private _sounds;
  3567. private _weights;
  3568. private _currentIndex?;
  3569. /**
  3570. * Creates a new WeightedSound from the list of sounds given.
  3571. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  3572. * @param sounds Array of Sounds that will be selected from.
  3573. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  3574. */
  3575. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  3576. /**
  3577. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  3578. */
  3579. /**
  3580. * The size of cone in degress for a directional sound in which there will be no attenuation.
  3581. */
  3582. directionalConeInnerAngle: number;
  3583. /**
  3584. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3585. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3586. */
  3587. /**
  3588. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  3589. * Listener angles between innerAngle and outerAngle will falloff linearly.
  3590. */
  3591. directionalConeOuterAngle: number;
  3592. /**
  3593. * Playback volume.
  3594. */
  3595. /**
  3596. * Playback volume.
  3597. */
  3598. volume: number;
  3599. private _onended;
  3600. /**
  3601. * Suspend playback
  3602. */
  3603. pause(): void;
  3604. /**
  3605. * Stop playback
  3606. */
  3607. stop(): void;
  3608. /**
  3609. * Start playback.
  3610. * @param startOffset Position the clip head at a specific time in seconds.
  3611. */
  3612. play(startOffset?: number): void;
  3613. }
  3614. }
  3615. declare module BABYLON {
  3616. /**
  3617. * Class used to store an actual running animation
  3618. */
  3619. class Animatable {
  3620. /** defines the target object */
  3621. target: any;
  3622. /** defines the starting frame number (default is 0) */
  3623. fromFrame: number;
  3624. /** defines the ending frame number (default is 100) */
  3625. toFrame: number;
  3626. /** defines if the animation must loop (default is false) */
  3627. loopAnimation: boolean;
  3628. /** defines a callback to call when animation ends if it is not looping */
  3629. onAnimationEnd?: (() => void) | null | undefined;
  3630. private _localDelayOffset;
  3631. private _pausedDelay;
  3632. private _runtimeAnimations;
  3633. private _paused;
  3634. private _scene;
  3635. private _speedRatio;
  3636. private _weight;
  3637. private _syncRoot;
  3638. /**
  3639. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3640. * This will only apply for non looping animation (default is true)
  3641. */
  3642. disposeOnEnd: boolean;
  3643. /**
  3644. * Gets a boolean indicating if the animation has started
  3645. */
  3646. animationStarted: boolean;
  3647. /**
  3648. * Observer raised when the animation ends
  3649. */
  3650. onAnimationEndObservable: Observable<Animatable>;
  3651. /**
  3652. * Gets the root Animatable used to synchronize and normalize animations
  3653. */
  3654. readonly syncRoot: Animatable;
  3655. /**
  3656. * Gets the current frame of the first RuntimeAnimation
  3657. * Used to synchronize Animatables
  3658. */
  3659. readonly masterFrame: number;
  3660. /**
  3661. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3662. */
  3663. weight: number;
  3664. /**
  3665. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3666. */
  3667. speedRatio: number;
  3668. /**
  3669. * Creates a new Animatable
  3670. * @param scene defines the hosting scene
  3671. * @param target defines the target object
  3672. * @param fromFrame defines the starting frame number (default is 0)
  3673. * @param toFrame defines the ending frame number (default is 100)
  3674. * @param loopAnimation defines if the animation must loop (default is false)
  3675. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3676. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3677. * @param animations defines a group of animation to add to the new Animatable
  3678. */
  3679. constructor(scene: Scene,
  3680. /** defines the target object */
  3681. target: any,
  3682. /** defines the starting frame number (default is 0) */
  3683. fromFrame?: number,
  3684. /** defines the ending frame number (default is 100) */
  3685. toFrame?: number,
  3686. /** defines if the animation must loop (default is false) */
  3687. loopAnimation?: boolean, speedRatio?: number,
  3688. /** defines a callback to call when animation ends if it is not looping */
  3689. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3690. /**
  3691. * Synchronize and normalize current Animatable with a source Animatable
  3692. * This is useful when using animation weights and when animations are not of the same length
  3693. * @param root defines the root Animatable to synchronize with
  3694. * @returns the current Animatable
  3695. */
  3696. syncWith(root: Animatable): Animatable;
  3697. /**
  3698. * Gets the list of runtime animations
  3699. * @returns an array of RuntimeAnimation
  3700. */
  3701. getAnimations(): RuntimeAnimation[];
  3702. /**
  3703. * Adds more animations to the current animatable
  3704. * @param target defines the target of the animations
  3705. * @param animations defines the new animations to add
  3706. */
  3707. appendAnimations(target: any, animations: Animation[]): void;
  3708. /**
  3709. * Gets the source animation for a specific property
  3710. * @param property defines the propertyu to look for
  3711. * @returns null or the source animation for the given property
  3712. */
  3713. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3714. /**
  3715. * Gets the runtime animation for a specific property
  3716. * @param property defines the propertyu to look for
  3717. * @returns null or the runtime animation for the given property
  3718. */
  3719. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3720. /**
  3721. * Resets the animatable to its original state
  3722. */
  3723. reset(): void;
  3724. /**
  3725. * Allows the animatable to blend with current running animations
  3726. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3727. * @param blendingSpeed defines the blending speed to use
  3728. */
  3729. enableBlending(blendingSpeed: number): void;
  3730. /**
  3731. * Disable animation blending
  3732. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3733. */
  3734. disableBlending(): void;
  3735. /**
  3736. * Jump directly to a given frame
  3737. * @param frame defines the frame to jump to
  3738. */
  3739. goToFrame(frame: number): void;
  3740. /**
  3741. * Pause the animation
  3742. */
  3743. pause(): void;
  3744. /**
  3745. * Restart the animation
  3746. */
  3747. restart(): void;
  3748. private _raiseOnAnimationEnd;
  3749. /**
  3750. * Stop and delete the current animation
  3751. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3752. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3753. */
  3754. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3755. /**
  3756. * Wait asynchronously for the animation to end
  3757. * @returns a promise which will be fullfilled when the animation ends
  3758. */
  3759. waitAsync(): Promise<Animatable>;
  3760. /** @hidden */
  3761. }
  3762. }
  3763. declare module BABYLON {
  3764. /**
  3765. * Represents the range of an animation
  3766. */
  3767. class AnimationRange {
  3768. /**The name of the animation range**/
  3769. name: string;
  3770. /**The starting frame of the animation */
  3771. from: number;
  3772. /**The ending frame of the animation*/
  3773. to: number;
  3774. /**
  3775. * Initializes the range of an animation
  3776. * @param name The name of the animation range
  3777. * @param from The starting frame of the animation
  3778. * @param to The ending frame of the animation
  3779. */
  3780. constructor(
  3781. /**The name of the animation range**/
  3782. name: string,
  3783. /**The starting frame of the animation */
  3784. from: number,
  3785. /**The ending frame of the animation*/
  3786. to: number);
  3787. /**
  3788. * Makes a copy of the animation range
  3789. * @returns A copy of the animation range
  3790. */
  3791. clone(): AnimationRange;
  3792. }
  3793. /**
  3794. * Composed of a frame, and an action function
  3795. */
  3796. class AnimationEvent {
  3797. /** The frame for which the event is triggered **/
  3798. frame: number;
  3799. /** The event to perform when triggered **/
  3800. action: (currentFrame: number) => void;
  3801. /** Specifies if the event should be triggered only once**/
  3802. onlyOnce?: boolean | undefined;
  3803. /**
  3804. * Specifies if the animation event is done
  3805. */
  3806. isDone: boolean;
  3807. /**
  3808. * Initializes the animation event
  3809. * @param frame The frame for which the event is triggered
  3810. * @param action The event to perform when triggered
  3811. * @param onlyOnce Specifies if the event should be triggered only once
  3812. */
  3813. constructor(
  3814. /** The frame for which the event is triggered **/
  3815. frame: number,
  3816. /** The event to perform when triggered **/
  3817. action: (currentFrame: number) => void,
  3818. /** Specifies if the event should be triggered only once**/
  3819. onlyOnce?: boolean | undefined);
  3820. /** @hidden */
  3821. }
  3822. /**
  3823. * A cursor which tracks a point on a path
  3824. */
  3825. class PathCursor {
  3826. private path;
  3827. /**
  3828. * Stores path cursor callbacks for when an onchange event is triggered
  3829. */
  3830. private _onchange;
  3831. /**
  3832. * The value of the path cursor
  3833. */
  3834. value: number;
  3835. /**
  3836. * The animation array of the path cursor
  3837. */
  3838. animations: Animation[];
  3839. /**
  3840. * Initializes the path cursor
  3841. * @param path The path to track
  3842. */
  3843. constructor(path: Path2);
  3844. /**
  3845. * Gets the cursor point on the path
  3846. * @returns A point on the path cursor at the cursor location
  3847. */
  3848. getPoint(): Vector3;
  3849. /**
  3850. * Moves the cursor ahead by the step amount
  3851. * @param step The amount to move the cursor forward
  3852. * @returns This path cursor
  3853. */
  3854. moveAhead(step?: number): PathCursor;
  3855. /**
  3856. * Moves the cursor behind by the step amount
  3857. * @param step The amount to move the cursor back
  3858. * @returns This path cursor
  3859. */
  3860. moveBack(step?: number): PathCursor;
  3861. /**
  3862. * Moves the cursor by the step amount
  3863. * If the step amount is greater than one, an exception is thrown
  3864. * @param step The amount to move the cursor
  3865. * @returns This path cursor
  3866. */
  3867. move(step: number): PathCursor;
  3868. /**
  3869. * Ensures that the value is limited between zero and one
  3870. * @returns This path cursor
  3871. */
  3872. private ensureLimits;
  3873. /**
  3874. * Runs onchange callbacks on change (used by the animation engine)
  3875. * @returns This path cursor
  3876. */
  3877. private raiseOnChange;
  3878. /**
  3879. * Executes a function on change
  3880. * @param f A path cursor onchange callback
  3881. * @returns This path cursor
  3882. */
  3883. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3884. }
  3885. /**
  3886. * Defines an interface which represents an animation key frame
  3887. */
  3888. interface IAnimationKey {
  3889. /**
  3890. * Frame of the key frame
  3891. */
  3892. frame: number;
  3893. /**
  3894. * Value at the specifies key frame
  3895. */
  3896. value: any;
  3897. /**
  3898. * The input tangent for the cubic hermite spline
  3899. */
  3900. inTangent?: any;
  3901. /**
  3902. * The output tangent for the cubic hermite spline
  3903. */
  3904. outTangent?: any;
  3905. /**
  3906. * The animation interpolation type
  3907. */
  3908. interpolation?: AnimationKeyInterpolation;
  3909. }
  3910. /**
  3911. * Enum for the animation key frame interpolation type
  3912. */
  3913. enum AnimationKeyInterpolation {
  3914. /**
  3915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3916. */
  3917. STEP = 1
  3918. }
  3919. /**
  3920. * Class used to store any kind of animation
  3921. */
  3922. class Animation {
  3923. /**Name of the animation */
  3924. name: string;
  3925. /**Property to animate */
  3926. targetProperty: string;
  3927. /**The frames per second of the animation */
  3928. framePerSecond: number;
  3929. /**The data type of the animation */
  3930. dataType: number;
  3931. /**The loop mode of the animation */
  3932. loopMode?: number | undefined;
  3933. /**Specifies if blending should be enabled */
  3934. enableBlending?: boolean | undefined;
  3935. /**
  3936. * Use matrix interpolation instead of using direct key value when animating matrices
  3937. */
  3938. static AllowMatricesInterpolation: boolean;
  3939. /**
  3940. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3941. */
  3942. static AllowMatrixDecomposeForInterpolation: boolean;
  3943. /**
  3944. * Stores the key frames of the animation
  3945. */
  3946. private _keys;
  3947. /**
  3948. * Stores the easing function of the animation
  3949. */
  3950. private _easingFunction;
  3951. /**
  3952. * @hidden Internal use only
  3953. */
  3954. /**
  3955. * The set of event that will be linked to this animation
  3956. */
  3957. private _events;
  3958. /**
  3959. * Stores an array of target property paths
  3960. */
  3961. targetPropertyPath: string[];
  3962. /**
  3963. * Stores the blending speed of the animation
  3964. */
  3965. blendingSpeed: number;
  3966. /**
  3967. * Stores the animation ranges for the animation
  3968. */
  3969. private _ranges;
  3970. /**
  3971. * @hidden Internal use
  3972. */
  3973. private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3974. /**
  3975. * Sets up an animation
  3976. * @param property The property to animate
  3977. * @param animationType The animation type to apply
  3978. * @param framePerSecond The frames per second of the animation
  3979. * @param easingFunction The easing function used in the animation
  3980. * @returns The created animation
  3981. */
  3982. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3983. /**
  3984. * Create and start an animation on a node
  3985. * @param name defines the name of the global animation that will be run on all nodes
  3986. * @param node defines the root node where the animation will take place
  3987. * @param targetProperty defines property to animate
  3988. * @param framePerSecond defines the number of frame per second yo use
  3989. * @param totalFrame defines the number of frames in total
  3990. * @param from defines the initial value
  3991. * @param to defines the final value
  3992. * @param loopMode defines which loop mode you want to use (off by default)
  3993. * @param easingFunction defines the easing function to use (linear by default)
  3994. * @param onAnimationEnd defines the callback to call when animation end
  3995. * @returns the animatable created for this animation
  3996. */
  3997. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3998. /**
  3999. * Create and start an animation on a node and its descendants
  4000. * @param name defines the name of the global animation that will be run on all nodes
  4001. * @param node defines the root node where the animation will take place
  4002. * @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
  4003. * @param targetProperty defines property to animate
  4004. * @param framePerSecond defines the number of frame per second to use
  4005. * @param totalFrame defines the number of frames in total
  4006. * @param from defines the initial value
  4007. * @param to defines the final value
  4008. * @param loopMode defines which loop mode you want to use (off by default)
  4009. * @param easingFunction defines the easing function to use (linear by default)
  4010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4011. * @returns the list of animatables created for all nodes
  4012. * @example https://www.babylonjs-playground.com/#MH0VLI
  4013. */
  4014. 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[]>;
  4015. /**
  4016. * Creates a new animation, merges it with the existing animations and starts it
  4017. * @param name Name of the animation
  4018. * @param node Node which contains the scene that begins the animations
  4019. * @param targetProperty Specifies which property to animate
  4020. * @param framePerSecond The frames per second of the animation
  4021. * @param totalFrame The total number of frames
  4022. * @param from The frame at the beginning of the animation
  4023. * @param to The frame at the end of the animation
  4024. * @param loopMode Specifies the loop mode of the animation
  4025. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4026. * @param onAnimationEnd Callback to run once the animation is complete
  4027. * @returns Nullable animation
  4028. */
  4029. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4030. /**
  4031. * Transition property of an host to the target Value
  4032. * @param property The property to transition
  4033. * @param targetValue The target Value of the property
  4034. * @param host The object where the property to animate belongs
  4035. * @param scene Scene used to run the animation
  4036. * @param frameRate Framerate (in frame/s) to use
  4037. * @param transition The transition type we want to use
  4038. * @param duration The duration of the animation, in milliseconds
  4039. * @param onAnimationEnd Callback trigger at the end of the animation
  4040. * @returns Nullable animation
  4041. */
  4042. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4043. /**
  4044. * Return the array of runtime animations currently using this animation
  4045. */
  4046. readonly runtimeAnimations: RuntimeAnimation[];
  4047. /**
  4048. * Specifies if any of the runtime animations are currently running
  4049. */
  4050. readonly hasRunningRuntimeAnimations: boolean;
  4051. /**
  4052. * Initializes the animation
  4053. * @param name Name of the animation
  4054. * @param targetProperty Property to animate
  4055. * @param framePerSecond The frames per second of the animation
  4056. * @param dataType The data type of the animation
  4057. * @param loopMode The loop mode of the animation
  4058. * @param enableBlendings Specifies if blending should be enabled
  4059. */
  4060. constructor(
  4061. /**Name of the animation */
  4062. name: string,
  4063. /**Property to animate */
  4064. targetProperty: string,
  4065. /**The frames per second of the animation */
  4066. framePerSecond: number,
  4067. /**The data type of the animation */
  4068. dataType: number,
  4069. /**The loop mode of the animation */
  4070. loopMode?: number | undefined,
  4071. /**Specifies if blending should be enabled */
  4072. enableBlending?: boolean | undefined);
  4073. /**
  4074. * Converts the animation to a string
  4075. * @param fullDetails support for multiple levels of logging within scene loading
  4076. * @returns String form of the animation
  4077. */
  4078. toString(fullDetails?: boolean): string;
  4079. /**
  4080. * Add an event to this animation
  4081. * @param event Event to add
  4082. */
  4083. addEvent(event: AnimationEvent): void;
  4084. /**
  4085. * Remove all events found at the given frame
  4086. * @param frame The frame to remove events from
  4087. */
  4088. removeEvents(frame: number): void;
  4089. /**
  4090. * Retrieves all the events from the animation
  4091. * @returns Events from the animation
  4092. */
  4093. getEvents(): AnimationEvent[];
  4094. /**
  4095. * Creates an animation range
  4096. * @param name Name of the animation range
  4097. * @param from Starting frame of the animation range
  4098. * @param to Ending frame of the animation
  4099. */
  4100. createRange(name: string, from: number, to: number): void;
  4101. /**
  4102. * Deletes an animation range by name
  4103. * @param name Name of the animation range to delete
  4104. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4105. */
  4106. deleteRange(name: string, deleteFrames?: boolean): void;
  4107. /**
  4108. * Gets the animation range by name, or null if not defined
  4109. * @param name Name of the animation range
  4110. * @returns Nullable animation range
  4111. */
  4112. getRange(name: string): Nullable<AnimationRange>;
  4113. /**
  4114. * Gets the key frames from the animation
  4115. * @returns The key frames of the animation
  4116. */
  4117. getKeys(): Array<IAnimationKey>;
  4118. /**
  4119. * Gets the highest frame rate of the animation
  4120. * @returns Highest frame rate of the animation
  4121. */
  4122. getHighestFrame(): number;
  4123. /**
  4124. * Gets the easing function of the animation
  4125. * @returns Easing function of the animation
  4126. */
  4127. getEasingFunction(): IEasingFunction;
  4128. /**
  4129. * Sets the easing function of the animation
  4130. * @param easingFunction A custom mathematical formula for animation
  4131. */
  4132. setEasingFunction(easingFunction: EasingFunction): void;
  4133. /**
  4134. * Interpolates a scalar linearly
  4135. * @param startValue Start value of the animation curve
  4136. * @param endValue End value of the animation curve
  4137. * @param gradient Scalar amount to interpolate
  4138. * @returns Interpolated scalar value
  4139. */
  4140. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4141. /**
  4142. * Interpolates a scalar cubically
  4143. * @param startValue Start value of the animation curve
  4144. * @param outTangent End tangent of the animation
  4145. * @param endValue End value of the animation curve
  4146. * @param inTangent Start tangent of the animation curve
  4147. * @param gradient Scalar amount to interpolate
  4148. * @returns Interpolated scalar value
  4149. */
  4150. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4151. /**
  4152. * Interpolates a quaternion using a spherical linear interpolation
  4153. * @param startValue Start value of the animation curve
  4154. * @param endValue End value of the animation curve
  4155. * @param gradient Scalar amount to interpolate
  4156. * @returns Interpolated quaternion value
  4157. */
  4158. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4159. /**
  4160. * Interpolates a quaternion cubically
  4161. * @param startValue Start value of the animation curve
  4162. * @param outTangent End tangent of the animation curve
  4163. * @param endValue End value of the animation curve
  4164. * @param inTangent Start tangent of the animation curve
  4165. * @param gradient Scalar amount to interpolate
  4166. * @returns Interpolated quaternion value
  4167. */
  4168. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4169. /**
  4170. * Interpolates a Vector3 linearl
  4171. * @param startValue Start value of the animation curve
  4172. * @param endValue End value of the animation curve
  4173. * @param gradient Scalar amount to interpolate
  4174. * @returns Interpolated scalar value
  4175. */
  4176. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4177. /**
  4178. * Interpolates a Vector3 cubically
  4179. * @param startValue Start value of the animation curve
  4180. * @param outTangent End tangent of the animation
  4181. * @param endValue End value of the animation curve
  4182. * @param inTangent Start tangent of the animation curve
  4183. * @param gradient Scalar amount to interpolate
  4184. * @returns InterpolatedVector3 value
  4185. */
  4186. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4187. /**
  4188. * Interpolates a Vector2 linearly
  4189. * @param startValue Start value of the animation curve
  4190. * @param endValue End value of the animation curve
  4191. * @param gradient Scalar amount to interpolate
  4192. * @returns Interpolated Vector2 value
  4193. */
  4194. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4195. /**
  4196. * Interpolates a Vector2 cubically
  4197. * @param startValue Start value of the animation curve
  4198. * @param outTangent End tangent of the animation
  4199. * @param endValue End value of the animation curve
  4200. * @param inTangent Start tangent of the animation curve
  4201. * @param gradient Scalar amount to interpolate
  4202. * @returns Interpolated Vector2 value
  4203. */
  4204. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4205. /**
  4206. * Interpolates a size linearly
  4207. * @param startValue Start value of the animation curve
  4208. * @param endValue End value of the animation curve
  4209. * @param gradient Scalar amount to interpolate
  4210. * @returns Interpolated Size value
  4211. */
  4212. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4213. /**
  4214. * Interpolates a Color3 linearly
  4215. * @param startValue Start value of the animation curve
  4216. * @param endValue End value of the animation curve
  4217. * @param gradient Scalar amount to interpolate
  4218. * @returns Interpolated Color3 value
  4219. */
  4220. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4221. /**
  4222. * @hidden Internal use only
  4223. */
  4224. /**
  4225. * @hidden Internal use only
  4226. */
  4227. /**
  4228. * Defines the function to use to interpolate matrices
  4229. * @param startValue defines the start matrix
  4230. * @param endValue defines the end matrix
  4231. * @param gradient defines the gradient between both matrices
  4232. * @param result defines an optional target matrix where to store the interpolation
  4233. * @returns the interpolated matrix
  4234. */
  4235. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4236. /**
  4237. * Makes a copy of the animation
  4238. * @returns Cloned animation
  4239. */
  4240. clone(): Animation;
  4241. /**
  4242. * Sets the key frames of the animation
  4243. * @param values The animation key frames to set
  4244. */
  4245. setKeys(values: Array<IAnimationKey>): void;
  4246. /**
  4247. * Serializes the animation to an object
  4248. * @returns Serialized object
  4249. */
  4250. serialize(): any;
  4251. /**
  4252. * Float animation type
  4253. */
  4254. private static _ANIMATIONTYPE_FLOAT;
  4255. /**
  4256. * Vector3 animation type
  4257. */
  4258. private static _ANIMATIONTYPE_VECTOR3;
  4259. /**
  4260. * Quaternion animation type
  4261. */
  4262. private static _ANIMATIONTYPE_QUATERNION;
  4263. /**
  4264. * Matrix animation type
  4265. */
  4266. private static _ANIMATIONTYPE_MATRIX;
  4267. /**
  4268. * Color3 animation type
  4269. */
  4270. private static _ANIMATIONTYPE_COLOR3;
  4271. /**
  4272. * Vector2 animation type
  4273. */
  4274. private static _ANIMATIONTYPE_VECTOR2;
  4275. /**
  4276. * Size animation type
  4277. */
  4278. private static _ANIMATIONTYPE_SIZE;
  4279. /**
  4280. * Relative Loop Mode
  4281. */
  4282. private static _ANIMATIONLOOPMODE_RELATIVE;
  4283. /**
  4284. * Cycle Loop Mode
  4285. */
  4286. private static _ANIMATIONLOOPMODE_CYCLE;
  4287. /**
  4288. * Constant Loop Mode
  4289. */
  4290. private static _ANIMATIONLOOPMODE_CONSTANT;
  4291. /**
  4292. * Get the float animation type
  4293. */
  4294. static readonly ANIMATIONTYPE_FLOAT: number;
  4295. /**
  4296. * Get the Vector3 animation type
  4297. */
  4298. static readonly ANIMATIONTYPE_VECTOR3: number;
  4299. /**
  4300. * Get the Vector2 animation type
  4301. */
  4302. static readonly ANIMATIONTYPE_VECTOR2: number;
  4303. /**
  4304. * Get the Size animation type
  4305. */
  4306. static readonly ANIMATIONTYPE_SIZE: number;
  4307. /**
  4308. * Get the Quaternion animation type
  4309. */
  4310. static readonly ANIMATIONTYPE_QUATERNION: number;
  4311. /**
  4312. * Get the Matrix animation type
  4313. */
  4314. static readonly ANIMATIONTYPE_MATRIX: number;
  4315. /**
  4316. * Get the Color3 animation type
  4317. */
  4318. static readonly ANIMATIONTYPE_COLOR3: number;
  4319. /**
  4320. * Get the Relative Loop Mode
  4321. */
  4322. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4323. /**
  4324. * Get the Cycle Loop Mode
  4325. */
  4326. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4327. /**
  4328. * Get the Constant Loop Mode
  4329. */
  4330. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4331. /** @hidden */
  4332. private static _UniversalLerp(left: any, right: any, amount: number): any;
  4333. /**
  4334. * Parses an animation object and creates an animation
  4335. * @param parsedAnimation Parsed animation object
  4336. * @returns Animation object
  4337. */
  4338. static Parse(parsedAnimation: any): Animation;
  4339. /**
  4340. * Appends the serialized animations from the source animations
  4341. * @param source Source containing the animations
  4342. * @param destination Target to store the animations
  4343. */
  4344. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4345. }
  4346. }
  4347. declare module BABYLON {
  4348. /**
  4349. * This class defines the direct association between an animation and a target
  4350. */
  4351. class TargetedAnimation {
  4352. animation: Animation;
  4353. target: any;
  4354. }
  4355. /**
  4356. * Use this class to create coordinated animations on multiple targets
  4357. */
  4358. class AnimationGroup implements IDisposable {
  4359. name: string;
  4360. private _scene;
  4361. private _targetedAnimations;
  4362. private _animatables;
  4363. private _from;
  4364. private _to;
  4365. private _isStarted;
  4366. private _speedRatio;
  4367. onAnimationEndObservable: Observable<TargetedAnimation>;
  4368. /**
  4369. * This observable will notify when all animations have ended.
  4370. */
  4371. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4372. /**
  4373. * This observable will notify when all animations have paused.
  4374. */
  4375. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4376. /**
  4377. * Gets the first frame
  4378. */
  4379. readonly from: number;
  4380. /**
  4381. * Gets the last frame
  4382. */
  4383. readonly to: number;
  4384. /**
  4385. * Define if the animations are started
  4386. */
  4387. readonly isStarted: boolean;
  4388. /**
  4389. * Gets or sets the speed ratio to use for all animations
  4390. */
  4391. /**
  4392. * Gets or sets the speed ratio to use for all animations
  4393. */
  4394. speedRatio: number;
  4395. /**
  4396. * Gets the targeted animations for this animation group
  4397. */
  4398. readonly targetedAnimations: Array<TargetedAnimation>;
  4399. /**
  4400. * returning the list of animatables controlled by this animation group.
  4401. */
  4402. readonly animatables: Array<Animatable>;
  4403. constructor(name: string, scene?: Nullable<Scene>);
  4404. /**
  4405. * Add an animation (with its target) in the group
  4406. * @param animation defines the animation we want to add
  4407. * @param target defines the target of the animation
  4408. * @returns the {BABYLON.TargetedAnimation} object
  4409. */
  4410. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4411. /**
  4412. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4413. * It can add constant keys at begin or end
  4414. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4415. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4416. */
  4417. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4418. /**
  4419. * Start all animations on given targets
  4420. * @param loop defines if animations must loop
  4421. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4422. * @param from defines the from key (optional)
  4423. * @param to defines the to key (optional)
  4424. * @returns the current animation group
  4425. */
  4426. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4427. /**
  4428. * Pause all animations
  4429. */
  4430. pause(): AnimationGroup;
  4431. /**
  4432. * Play all animations to initial state
  4433. * This function will start() the animations if they were not started or will restart() them if they were paused
  4434. * @param loop defines if animations must loop
  4435. */
  4436. play(loop?: boolean): AnimationGroup;
  4437. /**
  4438. * Reset all animations to initial state
  4439. */
  4440. reset(): AnimationGroup;
  4441. /**
  4442. * Restart animations from key 0
  4443. */
  4444. restart(): AnimationGroup;
  4445. /**
  4446. * Stop all animations
  4447. */
  4448. stop(): AnimationGroup;
  4449. /**
  4450. * Set animation weight for all animatables
  4451. * @param weight defines the weight to use
  4452. * @return the animationGroup
  4453. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4454. */
  4455. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4456. /**
  4457. * Synchronize and normalize all animatables with a source animatable
  4458. * @param root defines the root animatable to synchronize with
  4459. * @return the animationGroup
  4460. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4461. */
  4462. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4463. /**
  4464. * Goes to a specific frame in this animation group
  4465. * @param frame the frame number to go to
  4466. * @return the animationGroup
  4467. */
  4468. goToFrame(frame: number): AnimationGroup;
  4469. /**
  4470. * Dispose all associated resources
  4471. */
  4472. dispose(): void;
  4473. private _checkAnimationGroupEnded;
  4474. }
  4475. }
  4476. declare module BABYLON {
  4477. /**
  4478. * Class used to override all child animations of a given target
  4479. */
  4480. class AnimationPropertiesOverride {
  4481. /**
  4482. * Gets or sets a value indicating if animation blending must be used
  4483. */
  4484. enableBlending: boolean;
  4485. /**
  4486. * Gets or sets the blending speed to use when enableBlending is true
  4487. */
  4488. blendingSpeed: number;
  4489. /**
  4490. * Gets or sets the default loop mode to use
  4491. */
  4492. loopMode: number;
  4493. }
  4494. }
  4495. declare module BABYLON {
  4496. interface IEasingFunction {
  4497. ease(gradient: number): number;
  4498. }
  4499. class EasingFunction implements IEasingFunction {
  4500. private static _EASINGMODE_EASEIN;
  4501. private static _EASINGMODE_EASEOUT;
  4502. private static _EASINGMODE_EASEINOUT;
  4503. static readonly EASINGMODE_EASEIN: number;
  4504. static readonly EASINGMODE_EASEOUT: number;
  4505. static readonly EASINGMODE_EASEINOUT: number;
  4506. private _easingMode;
  4507. setEasingMode(easingMode: number): void;
  4508. getEasingMode(): number;
  4509. easeInCore(gradient: number): number;
  4510. ease(gradient: number): number;
  4511. }
  4512. class CircleEase extends EasingFunction implements IEasingFunction {
  4513. easeInCore(gradient: number): number;
  4514. }
  4515. class BackEase extends EasingFunction implements IEasingFunction {
  4516. amplitude: number;
  4517. constructor(amplitude?: number);
  4518. easeInCore(gradient: number): number;
  4519. }
  4520. class BounceEase extends EasingFunction implements IEasingFunction {
  4521. bounces: number;
  4522. bounciness: number;
  4523. constructor(bounces?: number, bounciness?: number);
  4524. easeInCore(gradient: number): number;
  4525. }
  4526. class CubicEase extends EasingFunction implements IEasingFunction {
  4527. easeInCore(gradient: number): number;
  4528. }
  4529. class ElasticEase extends EasingFunction implements IEasingFunction {
  4530. oscillations: number;
  4531. springiness: number;
  4532. constructor(oscillations?: number, springiness?: number);
  4533. easeInCore(gradient: number): number;
  4534. }
  4535. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4536. exponent: number;
  4537. constructor(exponent?: number);
  4538. easeInCore(gradient: number): number;
  4539. }
  4540. class PowerEase extends EasingFunction implements IEasingFunction {
  4541. power: number;
  4542. constructor(power?: number);
  4543. easeInCore(gradient: number): number;
  4544. }
  4545. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4546. easeInCore(gradient: number): number;
  4547. }
  4548. class QuarticEase extends EasingFunction implements IEasingFunction {
  4549. easeInCore(gradient: number): number;
  4550. }
  4551. class QuinticEase extends EasingFunction implements IEasingFunction {
  4552. easeInCore(gradient: number): number;
  4553. }
  4554. class SineEase extends EasingFunction implements IEasingFunction {
  4555. easeInCore(gradient: number): number;
  4556. }
  4557. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4558. x1: number;
  4559. y1: number;
  4560. x2: number;
  4561. y2: number;
  4562. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4563. easeInCore(gradient: number): number;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Defines a runtime animation
  4569. */
  4570. class RuntimeAnimation {
  4571. private _events;
  4572. /**
  4573. * The current frame of the runtime animation
  4574. */
  4575. private _currentFrame;
  4576. /**
  4577. * The animation used by the runtime animation
  4578. */
  4579. private _animation;
  4580. /**
  4581. * The target of the runtime animation
  4582. */
  4583. private _target;
  4584. /**
  4585. * The initiating animatable
  4586. */
  4587. private _host;
  4588. /**
  4589. * The original value of the runtime animation
  4590. */
  4591. private _originalValue;
  4592. /**
  4593. * The original blend value of the runtime animation
  4594. */
  4595. private _originalBlendValue;
  4596. /**
  4597. * The offsets cache of the runtime animation
  4598. */
  4599. private _offsetsCache;
  4600. /**
  4601. * The high limits cache of the runtime animation
  4602. */
  4603. private _highLimitsCache;
  4604. /**
  4605. * Specifies if the runtime animation has been stopped
  4606. */
  4607. private _stopped;
  4608. /**
  4609. * The blending factor of the runtime animation
  4610. */
  4611. private _blendingFactor;
  4612. /**
  4613. * The BabylonJS scene
  4614. */
  4615. private _scene;
  4616. /**
  4617. * The current value of the runtime animation
  4618. */
  4619. private _currentValue;
  4620. /** @hidden */
  4621. /**
  4622. * The active target of the runtime animation
  4623. */
  4624. private _activeTarget;
  4625. /**
  4626. * The target path of the runtime animation
  4627. */
  4628. private _targetPath;
  4629. /**
  4630. * The weight of the runtime animation
  4631. */
  4632. private _weight;
  4633. /**
  4634. * The ratio offset of the runtime animation
  4635. */
  4636. private _ratioOffset;
  4637. /**
  4638. * The previous delay of the runtime animation
  4639. */
  4640. private _previousDelay;
  4641. /**
  4642. * The previous ratio of the runtime animation
  4643. */
  4644. private _previousRatio;
  4645. /**
  4646. * Gets the current frame of the runtime animation
  4647. */
  4648. readonly currentFrame: number;
  4649. /**
  4650. * Gets the weight of the runtime animation
  4651. */
  4652. readonly weight: number;
  4653. /**
  4654. * Gets the current value of the runtime animation
  4655. */
  4656. readonly currentValue: any;
  4657. /**
  4658. * Gets the target path of the runtime animation
  4659. */
  4660. readonly targetPath: string;
  4661. /**
  4662. * Gets the actual target of the runtime animation
  4663. */
  4664. readonly target: any;
  4665. /**
  4666. * Create a new RuntimeAnimation object
  4667. * @param target defines the target of the animation
  4668. * @param animation defines the source animation object
  4669. * @param scene defines the hosting scene
  4670. * @param host defines the initiating Animatable
  4671. */
  4672. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4673. /**
  4674. * Gets the animation from the runtime animation
  4675. */
  4676. readonly animation: Animation;
  4677. /**
  4678. * Resets the runtime animation to the beginning
  4679. * @param restoreOriginal defines whether to restore the target property to the original value
  4680. */
  4681. reset(restoreOriginal?: boolean): void;
  4682. /**
  4683. * Specifies if the runtime animation is stopped
  4684. * @returns Boolean specifying if the runtime animation is stopped
  4685. */
  4686. isStopped(): boolean;
  4687. /**
  4688. * Disposes of the runtime animation
  4689. */
  4690. dispose(): void;
  4691. /**
  4692. * Interpolates the animation from the current frame
  4693. * @param currentFrame The frame to interpolate the animation to
  4694. * @param repeatCount The number of times that the animation should loop
  4695. * @param loopMode The type of looping mode to use
  4696. * @param offsetValue Animation offset value
  4697. * @param highLimitValue The high limit value
  4698. * @returns The interpolated value
  4699. */
  4700. private _interpolate;
  4701. /**
  4702. * Apply the interpolated value to the target
  4703. * @param currentValue defines the value computed by the animation
  4704. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4705. */
  4706. setValue(currentValue: any, weight?: number): void;
  4707. private _setValue;
  4708. /**
  4709. * Gets the loop pmode of the runtime animation
  4710. * @returns Loop Mode
  4711. */
  4712. private _getCorrectLoopMode;
  4713. /**
  4714. * Move the current animation to a given frame
  4715. * @param frame defines the frame to move to
  4716. */
  4717. goToFrame(frame: number): void;
  4718. /**
  4719. * @hidden Internal use only
  4720. */
  4721. /**
  4722. * Execute the current animation
  4723. * @param delay defines the delay to add to the current frame
  4724. * @param from defines the lower bound of the animation range
  4725. * @param to defines the upper bound of the animation range
  4726. * @param loop defines if the current animation must loop
  4727. * @param speedRatio defines the current speed ratio
  4728. * @param weight defines the weight of the animation (default is -1 so no weight)
  4729. * @returns a boolean indicating if the animation is running
  4730. */
  4731. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4732. }
  4733. }
  4734. declare module BABYLON {
  4735. /**
  4736. * Interface used to define a behavior
  4737. */
  4738. interface Behavior<T> {
  4739. /** gets or sets behavior's name */
  4740. name: string;
  4741. /**
  4742. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4743. */
  4744. init(): void;
  4745. /**
  4746. * Called when the behavior is attached to a target
  4747. * @param target defines the target where the behavior is attached to
  4748. */
  4749. attach(target: T): void;
  4750. /**
  4751. * Called when the behavior is detached from its target
  4752. */
  4753. detach(): void;
  4754. }
  4755. /**
  4756. * Interface implemented by classes supporting behaviors
  4757. */
  4758. interface IBehaviorAware<T> {
  4759. /**
  4760. * Attach a behavior
  4761. * @param behavior defines the behavior to attach
  4762. * @returns the current host
  4763. */
  4764. addBehavior(behavior: Behavior<T>): T;
  4765. /**
  4766. * Remove a behavior from the current object
  4767. * @param behavior defines the behavior to detach
  4768. * @returns the current host
  4769. */
  4770. removeBehavior(behavior: Behavior<T>): T;
  4771. /**
  4772. * Gets a behavior using its name to search
  4773. * @param name defines the name to search
  4774. * @returns the behavior or null if not found
  4775. */
  4776. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4777. }
  4778. }
  4779. declare module BABYLON {
  4780. /**
  4781. * Class used to store bone information
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4783. */
  4784. class Bone extends Node {
  4785. /**
  4786. * defines the bone name
  4787. */
  4788. name: string;
  4789. private static _tmpVecs;
  4790. private static _tmpQuat;
  4791. private static _tmpMats;
  4792. /**
  4793. * Gets the list of child bones
  4794. */
  4795. children: Bone[];
  4796. /** Gets the animations associated with this bone */
  4797. animations: Animation[];
  4798. /**
  4799. * Gets or sets bone length
  4800. */
  4801. length: number;
  4802. /**
  4803. * @hidden Internal only
  4804. * Set this value to map this bone to a different index in the transform matrices
  4805. * Set this value to -1 to exclude the bone from the transform matrices
  4806. */
  4807. private _skeleton;
  4808. private _localMatrix;
  4809. private _restPose;
  4810. private _baseMatrix;
  4811. private _absoluteTransform;
  4812. private _invertedAbsoluteTransform;
  4813. private _parent;
  4814. private _scalingDeterminant;
  4815. private _worldTransform;
  4816. private _localScaling;
  4817. private _localRotation;
  4818. private _localPosition;
  4819. private _needToDecompose;
  4820. private _needToCompose;
  4821. /** @hidden */
  4822. /** @hidden */
  4823. /**
  4824. * Create a new bone
  4825. * @param name defines the bone name
  4826. * @param skeleton defines the parent skeleton
  4827. * @param parentBone defines the parent (can be null if the bone is the root)
  4828. * @param localMatrix defines the local matrix
  4829. * @param restPose defines the rest pose matrix
  4830. * @param baseMatrix defines the base matrix
  4831. * @param index defines index of the bone in the hiearchy
  4832. */
  4833. constructor(
  4834. /**
  4835. * defines the bone name
  4836. */
  4837. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4838. /**
  4839. * Gets the parent skeleton
  4840. * @returns a skeleton
  4841. */
  4842. getSkeleton(): Skeleton;
  4843. /**
  4844. * Gets parent bone
  4845. * @returns a bone or null if the bone is the root of the bone hierarchy
  4846. */
  4847. getParent(): Nullable<Bone>;
  4848. /**
  4849. * Sets the parent bone
  4850. * @param parent defines the parent (can be null if the bone is the root)
  4851. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4852. */
  4853. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4854. /**
  4855. * Gets the local matrix
  4856. * @returns a matrix
  4857. */
  4858. getLocalMatrix(): Matrix;
  4859. /**
  4860. * Gets the base matrix (initial matrix which remains unchanged)
  4861. * @returns a matrix
  4862. */
  4863. getBaseMatrix(): Matrix;
  4864. /**
  4865. * Gets the rest pose matrix
  4866. * @returns a matrix
  4867. */
  4868. getRestPose(): Matrix;
  4869. /**
  4870. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4871. */
  4872. getWorldMatrix(): Matrix;
  4873. /**
  4874. * Sets the local matrix to rest pose matrix
  4875. */
  4876. returnToRest(): void;
  4877. /**
  4878. * Gets the inverse of the absolute transform matrix.
  4879. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4880. * @returns a matrix
  4881. */
  4882. getInvertedAbsoluteTransform(): Matrix;
  4883. /**
  4884. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4885. * @returns a matrix
  4886. */
  4887. getAbsoluteTransform(): Matrix;
  4888. /** Gets or sets current position (in local space) */
  4889. position: Vector3;
  4890. /** Gets or sets current rotation (in local space) */
  4891. rotation: Vector3;
  4892. /** Gets or sets current rotation quaternion (in local space) */
  4893. rotationQuaternion: Quaternion;
  4894. /** Gets or sets current scaling (in local space) */
  4895. scaling: Vector3;
  4896. /**
  4897. * Gets the animation properties override
  4898. */
  4899. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4900. private _decompose;
  4901. private _compose;
  4902. /**
  4903. * Update the base and local matrices
  4904. * @param matrix defines the new base or local matrix
  4905. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4906. * @param updateLocalMatrix defines if the local matrix should be updated
  4907. */
  4908. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4909. /** @hidden */
  4910. /**
  4911. * Flag the bone as dirty (Forcing it to update everything)
  4912. */
  4913. markAsDirty(): void;
  4914. private _markAsDirtyAndCompose;
  4915. private _markAsDirtyAndDecompose;
  4916. /**
  4917. * Copy an animation range from another bone
  4918. * @param source defines the source bone
  4919. * @param rangeName defines the range name to copy
  4920. * @param frameOffset defines the frame offset
  4921. * @param rescaleAsRequired defines if rescaling must be applied if required
  4922. * @param skelDimensionsRatio defines the scaling ratio
  4923. * @returns true if operation was successful
  4924. */
  4925. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4926. /**
  4927. * Translate the bone in local or world space
  4928. * @param vec The amount to translate the bone
  4929. * @param space The space that the translation is in
  4930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4931. */
  4932. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4933. /**
  4934. * Set the postion of the bone in local or world space
  4935. * @param position The position to set the bone
  4936. * @param space The space that the position is in
  4937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4938. */
  4939. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4940. /**
  4941. * Set the absolute position of the bone (world space)
  4942. * @param position The position to set the bone
  4943. * @param mesh The mesh that this bone is attached to
  4944. */
  4945. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4946. /**
  4947. * Scale the bone on the x, y and z axes (in local space)
  4948. * @param x The amount to scale the bone on the x axis
  4949. * @param y The amount to scale the bone on the y axis
  4950. * @param z The amount to scale the bone on the z axis
  4951. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4952. */
  4953. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4954. /**
  4955. * Set the bone scaling in local space
  4956. * @param scale defines the scaling vector
  4957. */
  4958. setScale(scale: Vector3): void;
  4959. /**
  4960. * Gets the current scaling in local space
  4961. * @returns the current scaling vector
  4962. */
  4963. getScale(): Vector3;
  4964. /**
  4965. * Gets the current scaling in local space and stores it in a target vector
  4966. * @param result defines the target vector
  4967. */
  4968. getScaleToRef(result: Vector3): void;
  4969. /**
  4970. * Set the yaw, pitch, and roll of the bone in local or world space
  4971. * @param yaw The rotation of the bone on the y axis
  4972. * @param pitch The rotation of the bone on the x axis
  4973. * @param roll The rotation of the bone on the z axis
  4974. * @param space The space that the axes of rotation are in
  4975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4976. */
  4977. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4978. /**
  4979. * Add a rotation to the bone on an axis in local or world space
  4980. * @param axis The axis to rotate the bone on
  4981. * @param amount The amount to rotate the bone
  4982. * @param space The space that the axis is in
  4983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4984. */
  4985. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4986. /**
  4987. * Set the rotation of the bone to a particular axis angle in local or world space
  4988. * @param axis The axis to rotate the bone on
  4989. * @param angle The angle that the bone should be rotated to
  4990. * @param space The space that the axis is in
  4991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4992. */
  4993. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4994. /**
  4995. * Set the euler rotation of the bone in local of world space
  4996. * @param rotation The euler rotation that the bone should be set to
  4997. * @param space The space that the rotation is in
  4998. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4999. */
  5000. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5001. /**
  5002. * Set the quaternion rotation of the bone in local of world space
  5003. * @param quat The quaternion rotation that the bone should be set to
  5004. * @param space The space that the rotation is in
  5005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5006. */
  5007. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5008. /**
  5009. * Set the rotation matrix of the bone in local of world space
  5010. * @param rotMat The rotation matrix that the bone should be set to
  5011. * @param space The space that the rotation is in
  5012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5013. */
  5014. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5015. private _rotateWithMatrix;
  5016. private _getNegativeRotationToRef;
  5017. /**
  5018. * Get the position of the bone in local or world space
  5019. * @param space The space that the returned position is in
  5020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5021. * @returns The position of the bone
  5022. */
  5023. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5024. /**
  5025. * Copy the position of the bone to a vector3 in local or world space
  5026. * @param space The space that the returned position is in
  5027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5028. * @param result The vector3 to copy the position to
  5029. */
  5030. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5031. /**
  5032. * Get the absolute position of the bone (world space)
  5033. * @param mesh The mesh that this bone is attached to
  5034. * @returns The absolute position of the bone
  5035. */
  5036. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5037. /**
  5038. * Copy the absolute position of the bone (world space) to the result param
  5039. * @param mesh The mesh that this bone is attached to
  5040. * @param result The vector3 to copy the absolute position to
  5041. */
  5042. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5043. /**
  5044. * Compute the absolute transforms of this bone and its children
  5045. */
  5046. computeAbsoluteTransforms(): void;
  5047. /**
  5048. * Get the world direction from an axis that is in the local space of the bone
  5049. * @param localAxis The local direction that is used to compute the world direction
  5050. * @param mesh The mesh that this bone is attached to
  5051. * @returns The world direction
  5052. */
  5053. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5054. /**
  5055. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5056. * @param localAxis The local direction that is used to compute the world direction
  5057. * @param mesh The mesh that this bone is attached to
  5058. * @param result The vector3 that the world direction will be copied to
  5059. */
  5060. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5061. /**
  5062. * Get the euler rotation of the bone in local or world space
  5063. * @param space The space that the rotation should be in
  5064. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5065. * @returns The euler rotation
  5066. */
  5067. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5068. /**
  5069. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5070. * @param space The space that the rotation should be in
  5071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5072. * @param result The vector3 that the rotation should be copied to
  5073. */
  5074. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5075. /**
  5076. * Get the quaternion rotation of the bone in either local or world space
  5077. * @param space The space that the rotation should be in
  5078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5079. * @returns The quaternion rotation
  5080. */
  5081. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5082. /**
  5083. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5084. * @param space The space that the rotation should be in
  5085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5086. * @param result The quaternion that the rotation should be copied to
  5087. */
  5088. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5089. /**
  5090. * Get the rotation matrix of the bone in local or world space
  5091. * @param space The space that the rotation should be in
  5092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5093. * @returns The rotation matrix
  5094. */
  5095. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5096. /**
  5097. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5098. * @param space The space that the rotation should be in
  5099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5100. * @param result The quaternion that the rotation should be copied to
  5101. */
  5102. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5103. /**
  5104. * Get the world position of a point that is in the local space of the bone
  5105. * @param position The local position
  5106. * @param mesh The mesh that this bone is attached to
  5107. * @returns The world position
  5108. */
  5109. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5110. /**
  5111. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5112. * @param position The local position
  5113. * @param mesh The mesh that this bone is attached to
  5114. * @param result The vector3 that the world position should be copied to
  5115. */
  5116. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5117. /**
  5118. * Get the local position of a point that is in world space
  5119. * @param position The world position
  5120. * @param mesh The mesh that this bone is attached to
  5121. * @returns The local position
  5122. */
  5123. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5124. /**
  5125. * Get the local position of a point that is in world space and copy it to the result param
  5126. * @param position The world position
  5127. * @param mesh The mesh that this bone is attached to
  5128. * @param result The vector3 that the local position should be copied to
  5129. */
  5130. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Class used to apply inverse kinematics to bones
  5136. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5137. */
  5138. class BoneIKController {
  5139. private static _tmpVecs;
  5140. private static _tmpQuat;
  5141. private static _tmpMats;
  5142. /**
  5143. * Gets or sets the target mesh
  5144. */
  5145. targetMesh: AbstractMesh;
  5146. /** Gets or sets the mesh used as pole */
  5147. poleTargetMesh: AbstractMesh;
  5148. /**
  5149. * Gets or sets the bone used as pole
  5150. */
  5151. poleTargetBone: Nullable<Bone>;
  5152. /**
  5153. * Gets or sets the target position
  5154. */
  5155. targetPosition: Vector3;
  5156. /**
  5157. * Gets or sets the pole target position
  5158. */
  5159. poleTargetPosition: Vector3;
  5160. /**
  5161. * Gets or sets the pole target local offset
  5162. */
  5163. poleTargetLocalOffset: Vector3;
  5164. /**
  5165. * Gets or sets the pole angle
  5166. */
  5167. poleAngle: number;
  5168. /**
  5169. * Gets or sets the mesh associated with the controller
  5170. */
  5171. mesh: AbstractMesh;
  5172. /**
  5173. * 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)
  5174. */
  5175. slerpAmount: number;
  5176. private _bone1Quat;
  5177. private _bone1Mat;
  5178. private _bone2Ang;
  5179. private _bone1;
  5180. private _bone2;
  5181. private _bone1Length;
  5182. private _bone2Length;
  5183. private _maxAngle;
  5184. private _maxReach;
  5185. private _rightHandedSystem;
  5186. private _bendAxis;
  5187. private _slerping;
  5188. private _adjustRoll;
  5189. /**
  5190. * Gets or sets maximum allowed angle
  5191. */
  5192. maxAngle: number;
  5193. /**
  5194. * Creates a new BoneIKController
  5195. * @param mesh defines the mesh to control
  5196. * @param bone defines the bone to control
  5197. * @param options defines options to set up the controller
  5198. */
  5199. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5200. targetMesh?: AbstractMesh;
  5201. poleTargetMesh?: AbstractMesh;
  5202. poleTargetBone?: Bone;
  5203. poleTargetLocalOffset?: Vector3;
  5204. poleAngle?: number;
  5205. bendAxis?: Vector3;
  5206. maxAngle?: number;
  5207. slerpAmount?: number;
  5208. });
  5209. private _setMaxAngle;
  5210. /**
  5211. * Force the controller to update the bones
  5212. */
  5213. update(): void;
  5214. }
  5215. }
  5216. declare module BABYLON {
  5217. /**
  5218. * Class used to make a bone look toward a point in space
  5219. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5220. */
  5221. class BoneLookController {
  5222. private static _tmpVecs;
  5223. private static _tmpQuat;
  5224. private static _tmpMats;
  5225. /**
  5226. * The target Vector3 that the bone will look at
  5227. */
  5228. target: Vector3;
  5229. /**
  5230. * The mesh that the bone is attached to
  5231. */
  5232. mesh: AbstractMesh;
  5233. /**
  5234. * The bone that will be looking to the target
  5235. */
  5236. bone: Bone;
  5237. /**
  5238. * The up axis of the coordinate system that is used when the bone is rotated
  5239. */
  5240. upAxis: Vector3;
  5241. /**
  5242. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5243. */
  5244. upAxisSpace: Space;
  5245. /**
  5246. * Used to make an adjustment to the yaw of the bone
  5247. */
  5248. adjustYaw: number;
  5249. /**
  5250. * Used to make an adjustment to the pitch of the bone
  5251. */
  5252. adjustPitch: number;
  5253. /**
  5254. * Used to make an adjustment to the roll of the bone
  5255. */
  5256. adjustRoll: number;
  5257. /**
  5258. * 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)
  5259. */
  5260. slerpAmount: number;
  5261. private _minYaw;
  5262. private _maxYaw;
  5263. private _minPitch;
  5264. private _maxPitch;
  5265. private _minYawSin;
  5266. private _minYawCos;
  5267. private _maxYawSin;
  5268. private _maxYawCos;
  5269. private _midYawConstraint;
  5270. private _minPitchTan;
  5271. private _maxPitchTan;
  5272. private _boneQuat;
  5273. private _slerping;
  5274. private _transformYawPitch;
  5275. private _transformYawPitchInv;
  5276. private _firstFrameSkipped;
  5277. private _yawRange;
  5278. private _fowardAxis;
  5279. /**
  5280. * Gets or sets the minimum yaw angle that the bone can look to
  5281. */
  5282. minYaw: number;
  5283. /**
  5284. * Gets or sets the maximum yaw angle that the bone can look to
  5285. */
  5286. maxYaw: number;
  5287. /**
  5288. * Gets or sets the minimum pitch angle that the bone can look to
  5289. */
  5290. minPitch: number;
  5291. /**
  5292. * Gets or sets the maximum pitch angle that the bone can look to
  5293. */
  5294. maxPitch: number;
  5295. /**
  5296. * Create a BoneLookController
  5297. * @param mesh the mesh that the bone belongs to
  5298. * @param bone the bone that will be looking to the target
  5299. * @param target the target Vector3 to look at
  5300. * @param settings optional settings:
  5301. * * maxYaw: the maximum angle the bone will yaw to
  5302. * * minYaw: the minimum angle the bone will yaw to
  5303. * * maxPitch: the maximum angle the bone will pitch to
  5304. * * minPitch: the minimum angle the bone will yaw to
  5305. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5306. * * upAxis: the up axis of the coordinate system
  5307. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5308. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5309. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5310. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5311. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5312. * * adjustRoll: used to make an adjustment to the roll of the bone
  5313. **/
  5314. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5315. maxYaw?: number;
  5316. minYaw?: number;
  5317. maxPitch?: number;
  5318. minPitch?: number;
  5319. slerpAmount?: number;
  5320. upAxis?: Vector3;
  5321. upAxisSpace?: Space;
  5322. yawAxis?: Vector3;
  5323. pitchAxis?: Vector3;
  5324. adjustYaw?: number;
  5325. adjustPitch?: number;
  5326. adjustRoll?: number;
  5327. });
  5328. /**
  5329. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5330. */
  5331. update(): void;
  5332. private _getAngleDiff;
  5333. private _getAngleBetween;
  5334. private _isAngleBetween;
  5335. }
  5336. }
  5337. declare module BABYLON {
  5338. /**
  5339. * Class used to handle skinning animations
  5340. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5341. */
  5342. class Skeleton implements IAnimatable {
  5343. /** defines the skeleton name */
  5344. name: string;
  5345. /** defines the skeleton Id */
  5346. id: string;
  5347. /**
  5348. * Gets the list of child bones
  5349. */
  5350. bones: Bone[];
  5351. /**
  5352. * Gets an estimate of the dimension of the skeleton at rest
  5353. */
  5354. dimensionsAtRest: Vector3;
  5355. /**
  5356. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5357. */
  5358. needInitialSkinMatrix: boolean;
  5359. /**
  5360. * Gets the list of animations attached to this skeleton
  5361. */
  5362. animations: Array<Animation>;
  5363. private _scene;
  5364. private _isDirty;
  5365. private _transformMatrices;
  5366. private _meshesWithPoseMatrix;
  5367. private _animatables;
  5368. private _identity;
  5369. private _synchronizedWithMesh;
  5370. private _ranges;
  5371. private _lastAbsoluteTransformsUpdateId;
  5372. /**
  5373. * Specifies if the skeleton should be serialized
  5374. */
  5375. doNotSerialize: boolean;
  5376. private _animationPropertiesOverride;
  5377. /**
  5378. * Gets or sets the animation properties override
  5379. */
  5380. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5381. /**
  5382. * An observable triggered before computing the skeleton's matrices
  5383. */
  5384. onBeforeComputeObservable: Observable<Skeleton>;
  5385. /**
  5386. * Creates a new skeleton
  5387. * @param name defines the skeleton name
  5388. * @param id defines the skeleton Id
  5389. * @param scene defines the hosting scene
  5390. */
  5391. constructor(
  5392. /** defines the skeleton name */
  5393. name: string,
  5394. /** defines the skeleton Id */
  5395. id: string, scene: Scene);
  5396. /**
  5397. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5398. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5399. * @returns a Float32Array containing matrices data
  5400. */
  5401. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5402. /**
  5403. * Gets the current hosting scene
  5404. * @returns a scene object
  5405. */
  5406. getScene(): Scene;
  5407. /**
  5408. * Gets a string representing the current skeleton data
  5409. * @param fullDetails defines a boolean indicating if we want a verbose version
  5410. * @returns a string representing the current skeleton data
  5411. */
  5412. toString(fullDetails?: boolean): string;
  5413. /**
  5414. * Get bone's index searching by name
  5415. * @param name defines bone's name to search for
  5416. * @return the indice of the bone. Returns -1 if not found
  5417. */
  5418. getBoneIndexByName(name: string): number;
  5419. /**
  5420. * Creater a new animation range
  5421. * @param name defines the name of the range
  5422. * @param from defines the start key
  5423. * @param to defines the end key
  5424. */
  5425. createAnimationRange(name: string, from: number, to: number): void;
  5426. /**
  5427. * Delete a specific animation range
  5428. * @param name defines the name of the range
  5429. * @param deleteFrames defines if frames must be removed as well
  5430. */
  5431. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5432. /**
  5433. * Gets a specific animation range
  5434. * @param name defines the name of the range to look for
  5435. * @returns the requested animation range or null if not found
  5436. */
  5437. getAnimationRange(name: string): Nullable<AnimationRange>;
  5438. /**
  5439. * Gets the list of all animation ranges defined on this skeleton
  5440. * @returns an array
  5441. */
  5442. getAnimationRanges(): Nullable<AnimationRange>[];
  5443. /**
  5444. * Copy animation range from a source skeleton.
  5445. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5446. * @param source defines the source skeleton
  5447. * @param name defines the name of the range to copy
  5448. * @param rescaleAsRequired defines if rescaling must be applied if required
  5449. * @returns true if operation was successful
  5450. */
  5451. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5452. /**
  5453. * Forces the skeleton to go to rest pose
  5454. */
  5455. returnToRest(): void;
  5456. private _getHighestAnimationFrame;
  5457. /**
  5458. * Begin a specific animation range
  5459. * @param name defines the name of the range to start
  5460. * @param loop defines if looping must be turned on (false by default)
  5461. * @param speedRatio defines the speed ratio to apply (1 by default)
  5462. * @param onAnimationEnd defines a callback which will be called when animation will end
  5463. * @returns a new animatable
  5464. */
  5465. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5466. /** @hidden */
  5467. /** @hidden */
  5468. /** @hidden */
  5469. /** @hidden */
  5470. /**
  5471. * Build all resources required to render a skeleton
  5472. */
  5473. prepare(): void;
  5474. /**
  5475. * Gets the list of animatables currently running for this skeleton
  5476. * @returns an array of animatables
  5477. */
  5478. getAnimatables(): IAnimatable[];
  5479. /**
  5480. * Clone the current skeleton
  5481. * @param name defines the name of the new skeleton
  5482. * @param id defines the id of the enw skeleton
  5483. * @returns the new skeleton
  5484. */
  5485. clone(name: string, id: string): Skeleton;
  5486. /**
  5487. * Enable animation blending for this skeleton
  5488. * @param blendingSpeed defines the blending speed to apply
  5489. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5490. */
  5491. enableBlending(blendingSpeed?: number): void;
  5492. /**
  5493. * Releases all resources associated with the current skeleton
  5494. */
  5495. dispose(): void;
  5496. /**
  5497. * Serialize the skeleton in a JSON object
  5498. * @returns a JSON object
  5499. */
  5500. serialize(): any;
  5501. /**
  5502. * Creates a new skeleton from serialized data
  5503. * @param parsedSkeleton defines the serialized data
  5504. * @param scene defines the hosting scene
  5505. * @returns a new skeleton
  5506. */
  5507. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5508. /**
  5509. * Compute all node absolute transforms
  5510. * @param forceUpdate defines if computation must be done even if cache is up to date
  5511. */
  5512. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5513. /**
  5514. * Gets the root pose matrix
  5515. * @returns a matrix
  5516. */
  5517. getPoseMatrix(): Nullable<Matrix>;
  5518. /**
  5519. * Sorts bones per internal index
  5520. */
  5521. sortBones(): void;
  5522. private _sortBones;
  5523. }
  5524. }
  5525. declare module BABYLON {
  5526. class Collider {
  5527. /** Define if a collision was found */
  5528. collisionFound: boolean;
  5529. /**
  5530. * Define last intersection point in local space
  5531. */
  5532. intersectionPoint: Vector3;
  5533. /**
  5534. * Define last collided mesh
  5535. */
  5536. collidedMesh: Nullable<AbstractMesh>;
  5537. private _collisionPoint;
  5538. private _planeIntersectionPoint;
  5539. private _tempVector;
  5540. private _tempVector2;
  5541. private _tempVector3;
  5542. private _tempVector4;
  5543. private _edge;
  5544. private _baseToVertex;
  5545. private _destinationPoint;
  5546. private _slidePlaneNormal;
  5547. private _displacementVector;
  5548. /** @hidden */
  5549. /** @hidden */
  5550. private _velocity;
  5551. private _basePoint;
  5552. private _epsilon;
  5553. /** @hidden */
  5554. /** @hidden */
  5555. private _velocityWorld;
  5556. private _normalizedVelocity;
  5557. /** @hidden */
  5558. /** @hidden */
  5559. private _nearestDistance;
  5560. private _collisionMask;
  5561. collisionMask: number;
  5562. /**
  5563. * Gets the plane normal used to compute the sliding response (in local space)
  5564. */
  5565. readonly slidePlaneNormal: Vector3;
  5566. /** @hidden */
  5567. /** @hidden */
  5568. /** @hidden */
  5569. /** @hidden */
  5570. /** @hidden */
  5571. /** @hidden */
  5572. }
  5573. }
  5574. declare module BABYLON {
  5575. var CollisionWorker: string;
  5576. interface ICollisionCoordinator {
  5577. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5578. init(scene: Scene): void;
  5579. destroy(): void;
  5580. onMeshAdded(mesh: AbstractMesh): void;
  5581. onMeshUpdated(mesh: AbstractMesh): void;
  5582. onMeshRemoved(mesh: AbstractMesh): void;
  5583. onGeometryAdded(geometry: Geometry): void;
  5584. onGeometryUpdated(geometry: Geometry): void;
  5585. onGeometryDeleted(geometry: Geometry): void;
  5586. }
  5587. interface SerializedMesh {
  5588. id: string;
  5589. name: string;
  5590. uniqueId: number;
  5591. geometryId: Nullable<string>;
  5592. sphereCenter: Array<number>;
  5593. sphereRadius: number;
  5594. boxMinimum: Array<number>;
  5595. boxMaximum: Array<number>;
  5596. worldMatrixFromCache: any;
  5597. subMeshes: Array<SerializedSubMesh>;
  5598. checkCollisions: boolean;
  5599. }
  5600. interface SerializedSubMesh {
  5601. position: number;
  5602. verticesStart: number;
  5603. verticesCount: number;
  5604. indexStart: number;
  5605. indexCount: number;
  5606. hasMaterial: boolean;
  5607. sphereCenter: Array<number>;
  5608. sphereRadius: number;
  5609. boxMinimum: Array<number>;
  5610. boxMaximum: Array<number>;
  5611. }
  5612. /**
  5613. * Interface describing the value associated with a geometry
  5614. */
  5615. interface SerializedGeometry {
  5616. /**
  5617. * Defines the unique ID of the geometry
  5618. */
  5619. id: string;
  5620. /**
  5621. * Defines the array containing the positions
  5622. */
  5623. positions: Float32Array;
  5624. /**
  5625. * Defines the array containing the indices
  5626. */
  5627. indices: Uint32Array;
  5628. /**
  5629. * Defines the array containing the normals
  5630. */
  5631. normals: Float32Array;
  5632. }
  5633. interface BabylonMessage {
  5634. taskType: WorkerTaskType;
  5635. payload: InitPayload | CollidePayload | UpdatePayload;
  5636. }
  5637. interface SerializedColliderToWorker {
  5638. position: Array<number>;
  5639. velocity: Array<number>;
  5640. radius: Array<number>;
  5641. }
  5642. /** Defines supported task for worker process */
  5643. enum WorkerTaskType {
  5644. /** Initialization */
  5645. INIT = 0,
  5646. /** Update of geometry */
  5647. UPDATE = 1,
  5648. /** Evaluate collision */
  5649. COLLIDE = 2
  5650. }
  5651. interface WorkerReply {
  5652. error: WorkerReplyType;
  5653. taskType: WorkerTaskType;
  5654. payload?: any;
  5655. }
  5656. interface CollisionReplyPayload {
  5657. newPosition: Array<number>;
  5658. collisionId: number;
  5659. collidedMeshUniqueId: number;
  5660. }
  5661. interface InitPayload {
  5662. }
  5663. interface CollidePayload {
  5664. collisionId: number;
  5665. collider: SerializedColliderToWorker;
  5666. maximumRetry: number;
  5667. excludedMeshUniqueId: Nullable<number>;
  5668. }
  5669. interface UpdatePayload {
  5670. updatedMeshes: {
  5671. [n: number]: SerializedMesh;
  5672. };
  5673. updatedGeometries: {
  5674. [s: string]: SerializedGeometry;
  5675. };
  5676. removedMeshes: Array<number>;
  5677. removedGeometries: Array<string>;
  5678. }
  5679. /** Defines kind of replies returned by worker */
  5680. enum WorkerReplyType {
  5681. /** Success */
  5682. SUCCESS = 0,
  5683. /** Unkown error */
  5684. UNKNOWN_ERROR = 1
  5685. }
  5686. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5687. private _scene;
  5688. private _scaledPosition;
  5689. private _scaledVelocity;
  5690. private _collisionsCallbackArray;
  5691. private _init;
  5692. private _runningUpdated;
  5693. private _worker;
  5694. private _addUpdateMeshesList;
  5695. private _addUpdateGeometriesList;
  5696. private _toRemoveMeshesArray;
  5697. private _toRemoveGeometryArray;
  5698. constructor();
  5699. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5700. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5701. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5702. init(scene: Scene): void;
  5703. destroy(): void;
  5704. onMeshAdded(mesh: AbstractMesh): void;
  5705. onMeshUpdated: (transformNode: TransformNode) => void;
  5706. onMeshRemoved(mesh: AbstractMesh): void;
  5707. onGeometryAdded(geometry: Geometry): void;
  5708. onGeometryUpdated: (geometry: Geometry) => void;
  5709. onGeometryDeleted(geometry: Geometry): void;
  5710. private _afterRender;
  5711. private _onMessageFromWorker;
  5712. }
  5713. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5714. private _scene;
  5715. private _scaledPosition;
  5716. private _scaledVelocity;
  5717. private _finalPosition;
  5718. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5719. init(scene: Scene): void;
  5720. destroy(): void;
  5721. onMeshAdded(mesh: AbstractMesh): void;
  5722. onMeshUpdated(mesh: AbstractMesh): void;
  5723. onMeshRemoved(mesh: AbstractMesh): void;
  5724. onGeometryAdded(geometry: Geometry): void;
  5725. onGeometryUpdated(geometry: Geometry): void;
  5726. onGeometryDeleted(geometry: Geometry): void;
  5727. private _collideWithWorld;
  5728. }
  5729. }
  5730. declare function importScripts(...urls: string[]): void;
  5731. declare const safePostMessage: any;
  5732. declare module BABYLON {
  5733. var WorkerIncluded: boolean;
  5734. class CollisionCache {
  5735. private _meshes;
  5736. private _geometries;
  5737. getMeshes(): {
  5738. [n: number]: SerializedMesh;
  5739. };
  5740. getGeometries(): {
  5741. [s: number]: SerializedGeometry;
  5742. };
  5743. getMesh(id: any): SerializedMesh;
  5744. addMesh(mesh: SerializedMesh): void;
  5745. removeMesh(uniqueId: number): void;
  5746. getGeometry(id: string): SerializedGeometry;
  5747. addGeometry(geometry: SerializedGeometry): void;
  5748. removeGeometry(id: string): void;
  5749. }
  5750. class CollideWorker {
  5751. collider: Collider;
  5752. private _collisionCache;
  5753. private finalPosition;
  5754. private collisionsScalingMatrix;
  5755. private collisionTranformationMatrix;
  5756. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5757. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5758. private checkCollision;
  5759. private processCollisionsForSubMeshes;
  5760. private collideForSubMesh;
  5761. private checkSubmeshCollision;
  5762. }
  5763. interface ICollisionDetector {
  5764. onInit(payload: InitPayload): void;
  5765. onUpdate(payload: UpdatePayload): void;
  5766. onCollision(payload: CollidePayload): void;
  5767. }
  5768. class CollisionDetectorTransferable implements ICollisionDetector {
  5769. private _collisionCache;
  5770. onInit(payload: InitPayload): void;
  5771. onUpdate(payload: UpdatePayload): void;
  5772. onCollision(payload: CollidePayload): void;
  5773. }
  5774. }
  5775. declare module BABYLON {
  5776. class IntersectionInfo {
  5777. bu: Nullable<number>;
  5778. bv: Nullable<number>;
  5779. distance: number;
  5780. faceId: number;
  5781. subMeshId: number;
  5782. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5783. }
  5784. /**
  5785. * Information about the result of picking within a scene
  5786. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5787. */
  5788. class PickingInfo {
  5789. /**
  5790. * If the pick collided with an object
  5791. */
  5792. hit: boolean;
  5793. /**
  5794. * Distance away where the pick collided
  5795. */
  5796. distance: number;
  5797. /**
  5798. * The location of pick collision
  5799. */
  5800. pickedPoint: Nullable<Vector3>;
  5801. /**
  5802. * The mesh corresponding the the pick collision
  5803. */
  5804. pickedMesh: Nullable<AbstractMesh>;
  5805. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5806. bu: number;
  5807. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5808. bv: number;
  5809. /** The id of the face on the mesh that was picked */
  5810. faceId: number;
  5811. /** Id of the the submesh that was picked */
  5812. subMeshId: number;
  5813. /** If a sprite was picked, this will be the sprite the pick collided with */
  5814. pickedSprite: Nullable<Sprite>;
  5815. /**
  5816. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5817. */
  5818. originMesh: Nullable<AbstractMesh>;
  5819. /**
  5820. * The ray that was used to perform the picking.
  5821. */
  5822. ray: Nullable<Ray>;
  5823. /**
  5824. * Gets the normal correspodning to the face the pick collided with
  5825. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5826. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5827. * @returns The normal correspodning to the face the pick collided with
  5828. */
  5829. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5830. /**
  5831. * Gets the texture coordinates of where the pick occured
  5832. * @returns the vector containing the coordnates of the texture
  5833. */
  5834. getTextureCoordinates(): Nullable<Vector2>;
  5835. }
  5836. }
  5837. declare module BABYLON {
  5838. class ArcRotateCamera extends TargetCamera {
  5839. alpha: number;
  5840. beta: number;
  5841. radius: number;
  5842. protected _target: Vector3;
  5843. protected _targetHost: Nullable<AbstractMesh>;
  5844. target: Vector3;
  5845. inertialAlphaOffset: number;
  5846. inertialBetaOffset: number;
  5847. inertialRadiusOffset: number;
  5848. lowerAlphaLimit: Nullable<number>;
  5849. upperAlphaLimit: Nullable<number>;
  5850. lowerBetaLimit: number;
  5851. upperBetaLimit: number;
  5852. lowerRadiusLimit: Nullable<number>;
  5853. upperRadiusLimit: Nullable<number>;
  5854. inertialPanningX: number;
  5855. inertialPanningY: number;
  5856. pinchToPanMaxDistance: number;
  5857. panningDistanceLimit: Nullable<number>;
  5858. panningOriginTarget: Vector3;
  5859. panningInertia: number;
  5860. angularSensibilityX: number;
  5861. angularSensibilityY: number;
  5862. pinchPrecision: number;
  5863. pinchDeltaPercentage: number;
  5864. panningSensibility: number;
  5865. keysUp: number[];
  5866. keysDown: number[];
  5867. keysLeft: number[];
  5868. keysRight: number[];
  5869. wheelPrecision: number;
  5870. wheelDeltaPercentage: number;
  5871. zoomOnFactor: number;
  5872. targetScreenOffset: Vector2;
  5873. allowUpsideDown: boolean;
  5874. /** @hidden */
  5875. /** @hidden */
  5876. /** @hidden */
  5877. inputs: ArcRotateCameraInputsManager;
  5878. /** @hidden */
  5879. panningAxis: Vector3;
  5880. protected _localDirection: Vector3;
  5881. protected _transformedDirection: Vector3;
  5882. private _bouncingBehavior;
  5883. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5884. useBouncingBehavior: boolean;
  5885. private _framingBehavior;
  5886. readonly framingBehavior: Nullable<FramingBehavior>;
  5887. useFramingBehavior: boolean;
  5888. private _autoRotationBehavior;
  5889. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5890. useAutoRotationBehavior: boolean;
  5891. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5892. onCollide: (collidedMesh: AbstractMesh) => void;
  5893. checkCollisions: boolean;
  5894. collisionRadius: Vector3;
  5895. protected _collider: Collider;
  5896. protected _previousPosition: Vector3;
  5897. protected _collisionVelocity: Vector3;
  5898. protected _newPosition: Vector3;
  5899. protected _previousAlpha: number;
  5900. protected _previousBeta: number;
  5901. protected _previousRadius: number;
  5902. protected _collisionTriggered: boolean;
  5903. protected _targetBoundingCenter: Nullable<Vector3>;
  5904. private _computationVector;
  5905. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5906. /** @hidden */
  5907. /** @hidden */
  5908. protected _getTargetPosition(): Vector3;
  5909. /**
  5910. * Store current camera state (fov, position, etc..)
  5911. */
  5912. private _storedAlpha;
  5913. private _storedBeta;
  5914. private _storedRadius;
  5915. private _storedTarget;
  5916. storeState(): Camera;
  5917. /**
  5918. * @hidden
  5919. * Restored camera state. You must call storeState() first
  5920. */
  5921. /** @hidden */
  5922. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5923. detachControl(element: HTMLElement): void;
  5924. /** @hidden */
  5925. protected _checkLimits(): void;
  5926. rebuildAnglesAndRadius(): void;
  5927. setPosition(position: Vector3): void;
  5928. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5929. /** @hidden */
  5930. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5931. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5932. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5933. min: Vector3;
  5934. max: Vector3;
  5935. distance: number;
  5936. }, doNotUpdateMaxZ?: boolean): void;
  5937. /**
  5938. * @override
  5939. * Override Camera.createRigCamera
  5940. */
  5941. createRigCamera(name: string, cameraIndex: number): Camera;
  5942. /**
  5943. * @hidden
  5944. * @override
  5945. * Override Camera._updateRigCameras
  5946. */
  5947. dispose(): void;
  5948. getClassName(): string;
  5949. }
  5950. }
  5951. declare module BABYLON {
  5952. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5953. constructor(camera: ArcRotateCamera);
  5954. addMouseWheel(): ArcRotateCameraInputsManager;
  5955. addPointers(): ArcRotateCameraInputsManager;
  5956. addKeyboard(): ArcRotateCameraInputsManager;
  5957. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5958. }
  5959. }
  5960. declare module BABYLON {
  5961. class Camera extends Node {
  5962. inputs: CameraInputsManager<Camera>;
  5963. private static _PERSPECTIVE_CAMERA;
  5964. private static _ORTHOGRAPHIC_CAMERA;
  5965. private static _FOVMODE_VERTICAL_FIXED;
  5966. private static _FOVMODE_HORIZONTAL_FIXED;
  5967. private static _RIG_MODE_NONE;
  5968. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5969. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5970. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5971. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5972. private static _RIG_MODE_VR;
  5973. private static _RIG_MODE_WEBVR;
  5974. static readonly PERSPECTIVE_CAMERA: number;
  5975. static readonly ORTHOGRAPHIC_CAMERA: number;
  5976. /**
  5977. * This is the default FOV mode for perspective cameras.
  5978. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5979. *
  5980. */
  5981. static readonly FOVMODE_VERTICAL_FIXED: number;
  5982. /**
  5983. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5984. *
  5985. */
  5986. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5987. static readonly RIG_MODE_NONE: number;
  5988. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5989. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5990. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5991. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5992. static readonly RIG_MODE_VR: number;
  5993. static readonly RIG_MODE_WEBVR: number;
  5994. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5995. static UseAlternateWebVRRendering: boolean;
  5996. position: Vector3;
  5997. /**
  5998. * The vector the camera should consider as up.
  5999. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6000. */
  6001. upVector: Vector3;
  6002. orthoLeft: Nullable<number>;
  6003. orthoRight: Nullable<number>;
  6004. orthoBottom: Nullable<number>;
  6005. orthoTop: Nullable<number>;
  6006. /**
  6007. * FOV is set in Radians. (default is 0.8)
  6008. */
  6009. fov: number;
  6010. minZ: number;
  6011. maxZ: number;
  6012. inertia: number;
  6013. mode: number;
  6014. isIntermediate: boolean;
  6015. viewport: Viewport;
  6016. /**
  6017. * Restricts the camera to viewing objects with the same layerMask.
  6018. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6019. */
  6020. layerMask: number;
  6021. /**
  6022. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6023. */
  6024. fovMode: number;
  6025. cameraRigMode: number;
  6026. interaxialDistance: number;
  6027. isStereoscopicSideBySide: boolean;
  6028. /** @hidden */
  6029. /** @hidden */
  6030. /** @hidden */
  6031. protected _webvrViewMatrix: Matrix;
  6032. /** @hidden */
  6033. /** @hidden */
  6034. customRenderTargets: RenderTargetTexture[];
  6035. onViewMatrixChangedObservable: Observable<Camera>;
  6036. onProjectionMatrixChangedObservable: Observable<Camera>;
  6037. onAfterCheckInputsObservable: Observable<Camera>;
  6038. onRestoreStateObservable: Observable<Camera>;
  6039. private _computedViewMatrix;
  6040. private _doNotComputeProjectionMatrix;
  6041. private _worldMatrix;
  6042. private _transformMatrix;
  6043. protected _globalPosition: Vector3;
  6044. private _frustumPlanes;
  6045. private _refreshFrustumPlanes;
  6046. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6047. private _storedFov;
  6048. private _stateStored;
  6049. /**
  6050. * Store current camera state (fov, position, etc..)
  6051. */
  6052. storeState(): Camera;
  6053. /**
  6054. * Restores the camera state values if it has been stored. You must call storeState() first
  6055. */
  6056. protected _restoreStateValues(): boolean;
  6057. /**
  6058. * Restored camera state. You must call storeState() first
  6059. */
  6060. restoreState(): boolean;
  6061. getClassName(): string;
  6062. /**
  6063. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6064. */
  6065. toString(fullDetails?: boolean): string;
  6066. readonly globalPosition: Vector3;
  6067. getActiveMeshes(): SmartArray<AbstractMesh>;
  6068. isActiveMesh(mesh: Mesh): boolean;
  6069. /**
  6070. * Is this camera ready to be used/rendered
  6071. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6072. * @return true if the camera is ready
  6073. */
  6074. isReady(completeCheck?: boolean): boolean;
  6075. /** @hidden */
  6076. /** @hidden */
  6077. /** @hidden */
  6078. /** @hidden */
  6079. /** @hidden */
  6080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6081. detachControl(element: HTMLElement): void;
  6082. update(): void;
  6083. /** @hidden */
  6084. readonly rigCameras: Camera[];
  6085. readonly rigPostProcess: Nullable<PostProcess>;
  6086. /**
  6087. * Internal, gets the first post proces.
  6088. * @returns the first post process to be run on this camera.
  6089. */
  6090. private _cascadePostProcessesToRigCams;
  6091. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6092. detachPostProcess(postProcess: PostProcess): void;
  6093. getWorldMatrix(): Matrix;
  6094. /** @hidden */
  6095. getViewMatrix(force?: boolean): Matrix;
  6096. freezeProjectionMatrix(projection?: Matrix): void;
  6097. unfreezeProjectionMatrix(): void;
  6098. getProjectionMatrix(force?: boolean): Matrix;
  6099. /**
  6100. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  6101. * @returns a Matrix
  6102. */
  6103. getTransformationMatrix(): Matrix;
  6104. private updateFrustumPlanes;
  6105. isInFrustum(target: ICullable): boolean;
  6106. isCompletelyInFrustum(target: ICullable): boolean;
  6107. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6108. /**
  6109. * Releases resources associated with this node.
  6110. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6111. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6112. */
  6113. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6114. readonly leftCamera: Nullable<FreeCamera>;
  6115. readonly rightCamera: Nullable<FreeCamera>;
  6116. getLeftTarget(): Nullable<Vector3>;
  6117. getRightTarget(): Nullable<Vector3>;
  6118. setCameraRigMode(mode: number, rigParams: any): void;
  6119. private _getVRProjectionMatrix;
  6120. protected _updateCameraRotationMatrix(): void;
  6121. protected _updateWebVRCameraRotationMatrix(): void;
  6122. /**
  6123. * This function MUST be overwritten by the different WebVR cameras available.
  6124. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6125. */
  6126. protected _getWebVRProjectionMatrix(): Matrix;
  6127. /**
  6128. * This function MUST be overwritten by the different WebVR cameras available.
  6129. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6130. */
  6131. protected _getWebVRViewMatrix(): Matrix;
  6132. setCameraRigParameter(name: string, value: any): void;
  6133. /**
  6134. * needs to be overridden by children so sub has required properties to be copied
  6135. */
  6136. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6137. /**
  6138. * May need to be overridden by children
  6139. * @hidden
  6140. */
  6141. /** @hidden */
  6142. serialize(): any;
  6143. clone(name: string): Camera;
  6144. getDirection(localAxis: Vector3): Vector3;
  6145. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6146. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6147. computeWorldMatrix(): Matrix;
  6148. static Parse(parsedCamera: any, scene: Scene): Camera;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. var CameraInputTypes: {};
  6153. interface ICameraInput<TCamera extends Camera> {
  6154. camera: Nullable<TCamera>;
  6155. getClassName(): string;
  6156. getSimpleName(): string;
  6157. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6158. detachControl: (element: Nullable<HTMLElement>) => void;
  6159. checkInputs?: () => void;
  6160. }
  6161. interface CameraInputsMap<TCamera extends Camera> {
  6162. [name: string]: ICameraInput<TCamera>;
  6163. [idx: number]: ICameraInput<TCamera>;
  6164. }
  6165. class CameraInputsManager<TCamera extends Camera> {
  6166. attached: CameraInputsMap<TCamera>;
  6167. attachedElement: Nullable<HTMLElement>;
  6168. noPreventDefault: boolean;
  6169. camera: TCamera;
  6170. checkInputs: () => void;
  6171. constructor(camera: TCamera);
  6172. /**
  6173. * Add an input method to a camera
  6174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6175. * @param input camera input method
  6176. */
  6177. add(input: ICameraInput<TCamera>): void;
  6178. /**
  6179. * Remove a specific input method from a camera
  6180. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6181. * @param inputToRemove camera input method
  6182. */
  6183. remove(inputToRemove: ICameraInput<TCamera>): void;
  6184. removeByType(inputType: string): void;
  6185. private _addCheckInputs;
  6186. attachInput(input: ICameraInput<TCamera>): void;
  6187. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6188. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6189. rebuildInputCheck(): void;
  6190. /**
  6191. * Remove all attached input methods from a camera
  6192. */
  6193. clear(): void;
  6194. serialize(serializedCamera: any): void;
  6195. parse(parsedCamera: any): void;
  6196. }
  6197. }
  6198. declare module BABYLON {
  6199. /**
  6200. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6201. * being tilted forward or back and left or right.
  6202. */
  6203. class DeviceOrientationCamera extends FreeCamera {
  6204. private _initialQuaternion;
  6205. private _quaternionCache;
  6206. /**
  6207. * Creates a new device orientation camera
  6208. * @param name The name of the camera
  6209. * @param position The start position camera
  6210. * @param scene The scene the camera belongs to
  6211. */
  6212. constructor(name: string, position: Vector3, scene: Scene);
  6213. /**
  6214. * Gets the current instance class name ("DeviceOrientationCamera").
  6215. * This helps avoiding instanceof at run time.
  6216. * @returns the class name
  6217. */
  6218. getClassName(): string;
  6219. /**
  6220. * @hidden
  6221. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6222. */
  6223. /**
  6224. * Reset the camera to its default orientation on the specified axis only.
  6225. * @param axis The axis to reset
  6226. */
  6227. resetToCurrentRotation(axis?: Axis): void;
  6228. }
  6229. }
  6230. declare module BABYLON {
  6231. class FollowCamera extends TargetCamera {
  6232. radius: number;
  6233. rotationOffset: number;
  6234. heightOffset: number;
  6235. cameraAcceleration: number;
  6236. maxCameraSpeed: number;
  6237. lockedTarget: Nullable<AbstractMesh>;
  6238. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6239. private getRadians;
  6240. private follow;
  6241. /** @hidden */
  6242. getClassName(): string;
  6243. }
  6244. class ArcFollowCamera extends TargetCamera {
  6245. alpha: number;
  6246. beta: number;
  6247. radius: number;
  6248. target: Nullable<AbstractMesh>;
  6249. private _cartesianCoordinates;
  6250. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6251. private follow;
  6252. /** @hidden */
  6253. getClassName(): string;
  6254. }
  6255. }
  6256. declare module BABYLON {
  6257. class FreeCamera extends TargetCamera {
  6258. ellipsoid: Vector3;
  6259. ellipsoidOffset: Vector3;
  6260. checkCollisions: boolean;
  6261. applyGravity: boolean;
  6262. inputs: FreeCameraInputsManager;
  6263. /**
  6264. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6265. * Higher values reduce sensitivity.
  6266. */
  6267. /**
  6268. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6269. * Higher values reduce sensitivity.
  6270. */
  6271. angularSensibility: number;
  6272. keysUp: number[];
  6273. keysDown: number[];
  6274. keysLeft: number[];
  6275. keysRight: number[];
  6276. onCollide: (collidedMesh: AbstractMesh) => void;
  6277. private _collider;
  6278. private _needMoveForGravity;
  6279. private _oldPosition;
  6280. private _diffPosition;
  6281. private _newPosition;
  6282. /** @hidden */
  6283. /** @hidden */
  6284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6286. detachControl(element: HTMLElement): void;
  6287. private _collisionMask;
  6288. collisionMask: number;
  6289. /** @hidden */
  6290. private _onCollisionPositionChange;
  6291. /** @hidden */
  6292. /** @hidden */
  6293. /** @hidden */
  6294. dispose(): void;
  6295. getClassName(): string;
  6296. }
  6297. }
  6298. declare module BABYLON {
  6299. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6300. constructor(camera: FreeCamera);
  6301. addKeyboard(): FreeCameraInputsManager;
  6302. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6303. addDeviceOrientation(): FreeCameraInputsManager;
  6304. addTouch(): FreeCameraInputsManager;
  6305. addVirtualJoystick(): FreeCameraInputsManager;
  6306. }
  6307. }
  6308. declare module BABYLON {
  6309. class GamepadCamera extends UniversalCamera {
  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 TargetCamera extends Camera {
  6318. cameraDirection: Vector3;
  6319. cameraRotation: Vector2;
  6320. rotation: Vector3;
  6321. rotationQuaternion: Quaternion;
  6322. speed: number;
  6323. noRotationConstraint: boolean;
  6324. lockedTarget: any;
  6325. /** @hidden */
  6326. /** @hidden */
  6327. /** @hidden */
  6328. /** @hidden */
  6329. /** @hidden */
  6330. private _rigCamTransformMatrix;
  6331. /** @hidden */
  6332. /** @hidden */
  6333. protected _globalCurrentTarget: Vector3;
  6334. protected _globalCurrentUpVector: Vector3;
  6335. /** @hidden */
  6336. private _defaultUp;
  6337. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6338. getFrontPosition(distance: number): Vector3;
  6339. /** @hidden */
  6340. /**
  6341. * Store current camera state (fov, position, etc..)
  6342. */
  6343. private _storedPosition;
  6344. private _storedRotation;
  6345. private _storedRotationQuaternion;
  6346. storeState(): Camera;
  6347. /**
  6348. * Restored camera state. You must call storeState() first
  6349. * @returns whether it was successful or not
  6350. * @hidden
  6351. */
  6352. /** @hidden */
  6353. /** @hidden */
  6354. /** @hidden */
  6355. /** @hidden */
  6356. /** @hidden */
  6357. setTarget(target: Vector3): void;
  6358. /**
  6359. * Return the current target position of the camera. This value is expressed in local space.
  6360. */
  6361. getTarget(): Vector3;
  6362. /** @hidden */
  6363. /** @hidden */
  6364. /** @hidden */
  6365. protected _updateCameraRotationMatrix(): void;
  6366. /**
  6367. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  6368. * @returns the current camera
  6369. */
  6370. private _rotateUpVectorWithCameraRotationMatrix;
  6371. private _cachedRotationZ;
  6372. /** @hidden */
  6373. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6374. /**
  6375. * @override
  6376. * Override Camera.createRigCamera
  6377. */
  6378. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6379. /**
  6380. * @hidden
  6381. * @override
  6382. * Override Camera._updateRigCameras
  6383. */
  6384. private _getRigCamPosition;
  6385. getClassName(): string;
  6386. }
  6387. }
  6388. declare module BABYLON {
  6389. class TouchCamera extends FreeCamera {
  6390. touchAngularSensibility: number;
  6391. touchMoveSensibility: number;
  6392. constructor(name: string, position: Vector3, scene: Scene);
  6393. getClassName(): string;
  6394. /** @hidden */
  6395. }
  6396. }
  6397. declare module BABYLON {
  6398. class UniversalCamera extends TouchCamera {
  6399. gamepadAngularSensibility: number;
  6400. gamepadMoveSensibility: number;
  6401. constructor(name: string, position: Vector3, scene: Scene);
  6402. getClassName(): string;
  6403. }
  6404. }
  6405. declare module BABYLON {
  6406. class VirtualJoysticksCamera extends FreeCamera {
  6407. constructor(name: string, position: Vector3, scene: Scene);
  6408. getClassName(): string;
  6409. }
  6410. }
  6411. interface VRDisplay extends EventTarget {
  6412. /**
  6413. * Dictionary of capabilities describing the VRDisplay.
  6414. */
  6415. readonly capabilities: VRDisplayCapabilities;
  6416. /**
  6417. * z-depth defining the far plane of the eye view frustum
  6418. * enables mapping of values in the render target depth
  6419. * attachment to scene coordinates. Initially set to 10000.0.
  6420. */
  6421. depthFar: number;
  6422. /**
  6423. * z-depth defining the near plane of the eye view frustum
  6424. * enables mapping of values in the render target depth
  6425. * attachment to scene coordinates. Initially set to 0.01.
  6426. */
  6427. depthNear: number;
  6428. /**
  6429. * An identifier for this distinct VRDisplay. Used as an
  6430. * association point in the Gamepad API.
  6431. */
  6432. readonly displayId: number;
  6433. /**
  6434. * A display name, a user-readable name identifying it.
  6435. */
  6436. readonly displayName: string;
  6437. readonly isConnected: boolean;
  6438. readonly isPresenting: boolean;
  6439. /**
  6440. * If this VRDisplay supports room-scale experiences, the optional
  6441. * stage attribute contains details on the room-scale parameters.
  6442. */
  6443. readonly stageParameters: VRStageParameters | null;
  6444. /**
  6445. * Passing the value returned by `requestAnimationFrame` to
  6446. * `cancelAnimationFrame` will unregister the callback.
  6447. */
  6448. cancelAnimationFrame(handle: number): void;
  6449. /**
  6450. * Stops presenting to the VRDisplay.
  6451. */
  6452. exitPresent(): Promise<void>;
  6453. getEyeParameters(whichEye: string): VREyeParameters;
  6454. /**
  6455. * Populates the passed VRFrameData with the information required to render
  6456. * the current frame.
  6457. */
  6458. getFrameData(frameData: VRFrameData): boolean;
  6459. /**
  6460. * Get the layers currently being presented.
  6461. */
  6462. getLayers(): VRLayer[];
  6463. /**
  6464. * Return a VRPose containing the future predicted pose of the VRDisplay
  6465. * when the current frame will be presented. The value returned will not
  6466. * change until JavaScript has returned control to the browser.
  6467. *
  6468. * The VRPose will contain the position, orientation, velocity,
  6469. * and acceleration of each of these properties.
  6470. */
  6471. getPose(): VRPose;
  6472. /**
  6473. * Return the current instantaneous pose of the VRDisplay, with no
  6474. * prediction applied.
  6475. */
  6476. getImmediatePose(): VRPose;
  6477. /**
  6478. * The callback passed to `requestAnimationFrame` will be called
  6479. * any time a new frame should be rendered. When the VRDisplay is
  6480. * presenting the callback will be called at the native refresh
  6481. * rate of the HMD. When not presenting this function acts
  6482. * identically to how window.requestAnimationFrame acts. Content should
  6483. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6484. * asynchronously from other displays and at differing refresh rates.
  6485. */
  6486. requestAnimationFrame(callback: FrameRequestCallback): number;
  6487. /**
  6488. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6489. * Repeat calls while already presenting will update the VRLayers being displayed.
  6490. */
  6491. requestPresent(layers: VRLayer[]): Promise<void>;
  6492. /**
  6493. * Reset the pose for this display, treating its current position and
  6494. * orientation as the "origin/zero" values. VRPose.position,
  6495. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6496. * updated when calling resetPose(). This should be called in only
  6497. * sitting-space experiences.
  6498. */
  6499. resetPose(): void;
  6500. /**
  6501. * The VRLayer provided to the VRDisplay will be captured and presented
  6502. * in the HMD. Calling this function has the same effect on the source
  6503. * canvas as any other operation that uses its source image, and canvases
  6504. * created without preserveDrawingBuffer set to true will be cleared.
  6505. */
  6506. submitFrame(pose?: VRPose): void;
  6507. }
  6508. declare var VRDisplay: {
  6509. prototype: VRDisplay;
  6510. new (): VRDisplay;
  6511. };
  6512. interface VRLayer {
  6513. leftBounds?: number[] | Float32Array | null;
  6514. rightBounds?: number[] | Float32Array | null;
  6515. source?: HTMLCanvasElement | null;
  6516. }
  6517. interface VRDisplayCapabilities {
  6518. readonly canPresent: boolean;
  6519. readonly hasExternalDisplay: boolean;
  6520. readonly hasOrientation: boolean;
  6521. readonly hasPosition: boolean;
  6522. readonly maxLayers: number;
  6523. }
  6524. interface VREyeParameters {
  6525. /** @deprecated */
  6526. readonly fieldOfView: VRFieldOfView;
  6527. readonly offset: Float32Array;
  6528. readonly renderHeight: number;
  6529. readonly renderWidth: number;
  6530. }
  6531. interface VRFieldOfView {
  6532. readonly downDegrees: number;
  6533. readonly leftDegrees: number;
  6534. readonly rightDegrees: number;
  6535. readonly upDegrees: number;
  6536. }
  6537. interface VRFrameData {
  6538. readonly leftProjectionMatrix: Float32Array;
  6539. readonly leftViewMatrix: Float32Array;
  6540. readonly pose: VRPose;
  6541. readonly rightProjectionMatrix: Float32Array;
  6542. readonly rightViewMatrix: Float32Array;
  6543. readonly timestamp: number;
  6544. }
  6545. interface VRPose {
  6546. readonly angularAcceleration: Float32Array | null;
  6547. readonly angularVelocity: Float32Array | null;
  6548. readonly linearAcceleration: Float32Array | null;
  6549. readonly linearVelocity: Float32Array | null;
  6550. readonly orientation: Float32Array | null;
  6551. readonly position: Float32Array | null;
  6552. readonly timestamp: number;
  6553. }
  6554. interface VRStageParameters {
  6555. sittingToStandingTransform?: Float32Array;
  6556. sizeX?: number;
  6557. sizeY?: number;
  6558. }
  6559. interface Navigator {
  6560. getVRDisplays(): Promise<VRDisplay[]>;
  6561. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6562. }
  6563. interface Window {
  6564. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6565. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6566. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6567. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6568. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6569. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6570. }
  6571. interface Gamepad {
  6572. readonly displayId: number;
  6573. }
  6574. declare module BABYLON {
  6575. class BoundingBox implements ICullable {
  6576. vectors: Vector3[];
  6577. center: Vector3;
  6578. centerWorld: Vector3;
  6579. extendSize: Vector3;
  6580. extendSizeWorld: Vector3;
  6581. directions: Vector3[];
  6582. vectorsWorld: Vector3[];
  6583. minimumWorld: Vector3;
  6584. maximumWorld: Vector3;
  6585. minimum: Vector3;
  6586. maximum: Vector3;
  6587. private _worldMatrix;
  6588. /**
  6589. * Creates a new bounding box
  6590. * @param min defines the minimum vector (in local space)
  6591. * @param max defines the maximum vector (in local space)
  6592. */
  6593. constructor(min: Vector3, max: Vector3);
  6594. /**
  6595. * Recreates the entire bounding box from scratch
  6596. * @param min defines the new minimum vector (in local space)
  6597. * @param max defines the new maximum vector (in local space)
  6598. */
  6599. reConstruct(min: Vector3, max: Vector3): void;
  6600. /**
  6601. * Scale the current bounding box by applying a scale factor
  6602. * @param factor defines the scale factor to apply
  6603. * @returns the current bounding box
  6604. */
  6605. scale(factor: number): BoundingBox;
  6606. getWorldMatrix(): Matrix;
  6607. setWorldMatrix(matrix: Matrix): BoundingBox;
  6608. /** @hidden */
  6609. isInFrustum(frustumPlanes: Plane[]): boolean;
  6610. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6611. intersectsPoint(point: Vector3): boolean;
  6612. intersectsSphere(sphere: BoundingSphere): boolean;
  6613. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6614. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6615. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6616. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6617. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6618. }
  6619. }
  6620. declare module BABYLON {
  6621. interface ICullable {
  6622. isInFrustum(frustumPlanes: Plane[]): boolean;
  6623. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6624. }
  6625. class BoundingInfo implements ICullable {
  6626. minimum: Vector3;
  6627. maximum: Vector3;
  6628. boundingBox: BoundingBox;
  6629. boundingSphere: BoundingSphere;
  6630. private _isLocked;
  6631. constructor(minimum: Vector3, maximum: Vector3);
  6632. isLocked: boolean;
  6633. update(world: Matrix): void;
  6634. /**
  6635. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6636. * @param center New center of the bounding info
  6637. * @param extend New extend of the bounding info
  6638. */
  6639. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6640. /**
  6641. * Scale the current bounding info by applying a scale factor
  6642. * @param factor defines the scale factor to apply
  6643. * @returns the current bounding info
  6644. */
  6645. scale(factor: number): BoundingInfo;
  6646. /**
  6647. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6648. * @param frustumPlanes defines the frustum to test
  6649. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6650. * @returns true if the bounding info is in the frustum planes
  6651. */
  6652. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6653. /**
  6654. * Gets the world distance between the min and max points of the bounding box
  6655. */
  6656. readonly diagonalLength: number;
  6657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6658. /** @hidden */
  6659. intersectsPoint(point: Vector3): boolean;
  6660. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6661. }
  6662. }
  6663. declare module BABYLON {
  6664. class BoundingSphere {
  6665. center: Vector3;
  6666. radius: number;
  6667. centerWorld: Vector3;
  6668. radiusWorld: number;
  6669. minimum: Vector3;
  6670. maximum: Vector3;
  6671. /**
  6672. * Creates a new bounding sphere
  6673. * @param min defines the minimum vector (in local space)
  6674. * @param max defines the maximum vector (in local space)
  6675. */
  6676. constructor(min: Vector3, max: Vector3);
  6677. /**
  6678. * Recreates the entire bounding sphere from scratch
  6679. * @param min defines the new minimum vector (in local space)
  6680. * @param max defines the new maximum vector (in local space)
  6681. */
  6682. reConstruct(min: Vector3, max: Vector3): void;
  6683. /**
  6684. * Scale the current bounding sphere by applying a scale factor
  6685. * @param factor defines the scale factor to apply
  6686. * @returns the current bounding box
  6687. */
  6688. scale(factor: number): BoundingSphere;
  6689. /** @hidden */
  6690. isInFrustum(frustumPlanes: Plane[]): boolean;
  6691. intersectsPoint(point: Vector3): boolean;
  6692. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. class Ray {
  6697. origin: Vector3;
  6698. direction: Vector3;
  6699. length: number;
  6700. private _edge1;
  6701. private _edge2;
  6702. private _pvec;
  6703. private _tvec;
  6704. private _qvec;
  6705. private _tmpRay;
  6706. constructor(origin: Vector3, direction: Vector3, length?: number);
  6707. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6708. intersectsBox(box: BoundingBox): boolean;
  6709. intersectsSphere(sphere: BoundingSphere): boolean;
  6710. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6711. intersectsPlane(plane: Plane): Nullable<number>;
  6712. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6713. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6714. private _comparePickingInfo;
  6715. private static smallnum;
  6716. private static rayl;
  6717. /**
  6718. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6719. * @param sega the first point of the segment to test the intersection against
  6720. * @param segb the second point of the segment to test the intersection against
  6721. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6722. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6723. */
  6724. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6725. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6726. static Zero(): Ray;
  6727. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6728. /**
  6729. * 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
  6730. * transformed to the given world matrix.
  6731. * @param origin The origin point
  6732. * @param end The end point
  6733. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6734. */
  6735. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6736. static Transform(ray: Ray, matrix: Matrix): Ray;
  6737. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6738. }
  6739. }
  6740. /**
  6741. * Module Debug contains the (visual) components to debug a scene correctly
  6742. */
  6743. declare module BABYLON.Debug {
  6744. /**
  6745. * The Axes viewer will show 3 axes in a specific point in space
  6746. */
  6747. class AxesViewer {
  6748. private _xline;
  6749. private _yline;
  6750. private _zline;
  6751. private _xmesh;
  6752. private _ymesh;
  6753. private _zmesh;
  6754. /**
  6755. * Gets the hosting scene
  6756. */
  6757. scene: Nullable<Scene>;
  6758. /**
  6759. * Gets or sets a number used to scale line length
  6760. */
  6761. scaleLines: number;
  6762. /**
  6763. * Creates a new AxesViewer
  6764. * @param scene defines the hosting scene
  6765. * @param scaleLines defines a number used to scale line length (1 by default)
  6766. */
  6767. constructor(scene: Scene, scaleLines?: number);
  6768. /**
  6769. * Force the viewer to update
  6770. * @param position defines the position of the viewer
  6771. * @param xaxis defines the x axis of the viewer
  6772. * @param yaxis defines the y axis of the viewer
  6773. * @param zaxis defines the z axis of the viewer
  6774. */
  6775. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6776. /** Releases resources */
  6777. dispose(): void;
  6778. }
  6779. }
  6780. declare module BABYLON.Debug {
  6781. /**
  6782. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6783. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6784. */
  6785. class BoneAxesViewer extends AxesViewer {
  6786. /**
  6787. * Gets or sets the target mesh where to display the axes viewer
  6788. */
  6789. mesh: Nullable<Mesh>;
  6790. /**
  6791. * Gets or sets the target bone where to display the axes viewer
  6792. */
  6793. bone: Nullable<Bone>;
  6794. /** Gets current position */
  6795. pos: Vector3;
  6796. /** Gets direction of X axis */
  6797. xaxis: Vector3;
  6798. /** Gets direction of Y axis */
  6799. yaxis: Vector3;
  6800. /** Gets direction of Z axis */
  6801. zaxis: Vector3;
  6802. /**
  6803. * Creates a new BoneAxesViewer
  6804. * @param scene defines the hosting scene
  6805. * @param bone defines the target bone
  6806. * @param mesh defines the target mesh
  6807. * @param scaleLines defines a scaling factor for line length (1 by default)
  6808. */
  6809. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6810. /**
  6811. * Force the viewer to update
  6812. */
  6813. update(): void;
  6814. /** Releases resources */
  6815. dispose(): void;
  6816. }
  6817. }
  6818. declare module BABYLON {
  6819. class DebugLayer {
  6820. private _scene;
  6821. static InspectorURL: string;
  6822. private _inspector;
  6823. private BJSINSPECTOR;
  6824. onPropertyChangedObservable: Observable<{
  6825. object: any;
  6826. property: string;
  6827. value: any;
  6828. initialValue: any;
  6829. }>;
  6830. constructor(scene: Scene);
  6831. /** Creates the inspector window. */
  6832. private _createInspector;
  6833. isVisible(): boolean;
  6834. hide(): void;
  6835. /**
  6836. *
  6837. * Launch the debugLayer.
  6838. *
  6839. * initialTab:
  6840. * | Value | Tab Name |
  6841. * | --- | --- |
  6842. * | 0 | Scene |
  6843. * | 1 | Console |
  6844. * | 2 | Stats |
  6845. * | 3 | Textures |
  6846. * | 4 | Mesh |
  6847. * | 5 | Light |
  6848. * | 6 | Material |
  6849. * | 7 | GLTF |
  6850. * | 8 | GUI |
  6851. * | 9 | Physics |
  6852. * | 10 | Camera |
  6853. * | 11 | Audio |
  6854. *
  6855. */
  6856. show(config?: {
  6857. popup?: boolean;
  6858. initialTab?: number;
  6859. parentElement?: HTMLElement;
  6860. newColors?: {
  6861. backgroundColor?: string;
  6862. backgroundColorLighter?: string;
  6863. backgroundColorLighter2?: string;
  6864. backgroundColorLighter3?: string;
  6865. color?: string;
  6866. colorTop?: string;
  6867. colorBot?: string;
  6868. };
  6869. }): void;
  6870. /**
  6871. * Gets the active tab
  6872. * @return the index of the active tab or -1 if the inspector is hidden
  6873. */
  6874. getActiveTab(): number;
  6875. }
  6876. }
  6877. declare module BABYLON.Debug {
  6878. /**
  6879. * Used to show the physics impostor around the specific mesh
  6880. */
  6881. class PhysicsViewer {
  6882. /** @hidden */
  6883. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6884. /** @hidden */
  6885. protected _meshes: Array<Nullable<AbstractMesh>>;
  6886. /** @hidden */
  6887. protected _scene: Nullable<Scene>;
  6888. /** @hidden */
  6889. protected _numMeshes: number;
  6890. /** @hidden */
  6891. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6892. private _renderFunction;
  6893. private _debugBoxMesh;
  6894. private _debugSphereMesh;
  6895. private _debugMaterial;
  6896. /**
  6897. * Creates a new PhysicsViewer
  6898. * @param scene defines the hosting scene
  6899. */
  6900. constructor(scene: Scene);
  6901. /** @hidden */
  6902. protected _updateDebugMeshes(): void;
  6903. /**
  6904. * Renders a specified physic impostor
  6905. * @param impostor defines the impostor to render
  6906. */
  6907. showImpostor(impostor: PhysicsImpostor): void;
  6908. /**
  6909. * Hides a specified physic impostor
  6910. * @param impostor defines the impostor to hide
  6911. */
  6912. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6913. private _getDebugMaterial;
  6914. private _getDebugBoxMesh;
  6915. private _getDebugSphereMesh;
  6916. private _getDebugMesh;
  6917. /** Releases all resources */
  6918. dispose(): void;
  6919. }
  6920. }
  6921. declare module BABYLON {
  6922. class RayHelper {
  6923. ray: Nullable<Ray>;
  6924. private _renderPoints;
  6925. private _renderLine;
  6926. private _renderFunction;
  6927. private _scene;
  6928. private _updateToMeshFunction;
  6929. private _attachedToMesh;
  6930. private _meshSpaceDirection;
  6931. private _meshSpaceOrigin;
  6932. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6933. constructor(ray: Ray);
  6934. show(scene: Scene, color?: Color3): void;
  6935. hide(): void;
  6936. private _render;
  6937. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6938. detachFromMesh(): void;
  6939. private _updateToMesh;
  6940. dispose(): void;
  6941. }
  6942. }
  6943. declare module BABYLON.Debug {
  6944. /**
  6945. * Class used to render a debug view of a given skeleton
  6946. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6947. */
  6948. class SkeletonViewer {
  6949. /** defines the skeleton to render */
  6950. skeleton: Skeleton;
  6951. /** defines the mesh attached to the skeleton */
  6952. mesh: AbstractMesh;
  6953. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6954. autoUpdateBonesMatrices: boolean;
  6955. /** defines the rendering group id to use with the viewer */
  6956. renderingGroupId: number;
  6957. /** Gets or sets the color used to render the skeleton */
  6958. color: Color3;
  6959. private _scene;
  6960. private _debugLines;
  6961. private _debugMesh;
  6962. private _isEnabled;
  6963. private _renderFunction;
  6964. /**
  6965. * Creates a new SkeletonViewer
  6966. * @param skeleton defines the skeleton to render
  6967. * @param mesh defines the mesh attached to the skeleton
  6968. * @param scene defines the hosting scene
  6969. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6970. * @param renderingGroupId defines the rendering group id to use with the viewer
  6971. */
  6972. constructor(
  6973. /** defines the skeleton to render */
  6974. skeleton: Skeleton,
  6975. /** defines the mesh attached to the skeleton */
  6976. mesh: AbstractMesh, scene: Scene,
  6977. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6978. autoUpdateBonesMatrices?: boolean,
  6979. /** defines the rendering group id to use with the viewer */
  6980. renderingGroupId?: number);
  6981. /** Gets or sets a boolean indicating if the viewer is enabled */
  6982. isEnabled: boolean;
  6983. private _getBonePosition;
  6984. private _getLinesForBonesWithLength;
  6985. private _getLinesForBonesNoLength;
  6986. /** Update the viewer to sync with current skeleton state */
  6987. update(): void;
  6988. /** Release associated resources */
  6989. dispose(): void;
  6990. }
  6991. }
  6992. declare module BABYLON {
  6993. /**
  6994. * Interface for attribute information associated with buffer instanciation
  6995. */
  6996. class InstancingAttributeInfo {
  6997. /**
  6998. * Index/offset of the attribute in the vertex shader
  6999. */
  7000. index: number;
  7001. /**
  7002. * size of the attribute, 1, 2, 3 or 4
  7003. */
  7004. attributeSize: number;
  7005. /**
  7006. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7007. * default is FLOAT
  7008. */
  7009. attribyteType: number;
  7010. /**
  7011. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7012. */
  7013. normalized: boolean;
  7014. /**
  7015. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7016. */
  7017. offset: number;
  7018. /**
  7019. * Name of the GLSL attribute, for debugging purpose only
  7020. */
  7021. attributeName: string;
  7022. }
  7023. /**
  7024. * Define options used to create a render target texture
  7025. */
  7026. class RenderTargetCreationOptions {
  7027. /**
  7028. * Specifies is mipmaps must be generated
  7029. */
  7030. generateMipMaps?: boolean;
  7031. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7032. generateDepthBuffer?: boolean;
  7033. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7034. generateStencilBuffer?: boolean;
  7035. /** Defines texture type (int by default) */
  7036. type?: number;
  7037. /** Defines sampling mode (trilinear by default) */
  7038. samplingMode?: number;
  7039. /** Defines format (RGBA by default) */
  7040. format?: number;
  7041. }
  7042. /**
  7043. * Define options used to create a depth texture
  7044. */
  7045. class DepthTextureCreationOptions {
  7046. /** Specifies whether or not a stencil should be allocated in the texture */
  7047. generateStencil?: boolean;
  7048. /** Specifies whether or not bilinear filtering is enable on the texture */
  7049. bilinearFiltering?: boolean;
  7050. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7051. comparisonFunction?: number;
  7052. /** Specifies if the created texture is a cube texture */
  7053. isCube?: boolean;
  7054. }
  7055. /**
  7056. * Class used to describe the capabilities of the engine relatively to the current browser
  7057. */
  7058. class EngineCapabilities {
  7059. /** Maximum textures units per fragment shader */
  7060. maxTexturesImageUnits: number;
  7061. /** Maximum texture units per vertex shader */
  7062. maxVertexTextureImageUnits: number;
  7063. /** Maximum textures units in the entire pipeline */
  7064. maxCombinedTexturesImageUnits: number;
  7065. /** Maximum texture size */
  7066. maxTextureSize: number;
  7067. /** Maximum cube texture size */
  7068. maxCubemapTextureSize: number;
  7069. /** Maximum render texture size */
  7070. maxRenderTextureSize: number;
  7071. /** Maximum number of vertex attributes */
  7072. maxVertexAttribs: number;
  7073. /** Maximum number of varyings */
  7074. maxVaryingVectors: number;
  7075. /** Maximum number of uniforms per vertex shader */
  7076. maxVertexUniformVectors: number;
  7077. /** Maximum number of uniforms per fragment shader */
  7078. maxFragmentUniformVectors: number;
  7079. /** Defines if standard derivates (dx/dy) are supported */
  7080. standardDerivatives: boolean;
  7081. /** Defines if s3tc texture compression is supported */
  7082. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7083. /** Defines if pvrtc texture compression is supported */
  7084. pvrtc: any;
  7085. /** Defines if etc1 texture compression is supported */
  7086. etc1: any;
  7087. /** Defines if etc2 texture compression is supported */
  7088. etc2: any;
  7089. /** Defines if astc texture compression is supported */
  7090. astc: any;
  7091. /** Defines if float textures are supported */
  7092. textureFloat: boolean;
  7093. /** Defines if vertex array objects are supported */
  7094. vertexArrayObject: boolean;
  7095. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7096. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7097. /** Gets the maximum level of anisotropy supported */
  7098. maxAnisotropy: number;
  7099. /** Defines if instancing is supported */
  7100. instancedArrays: boolean;
  7101. /** Defines if 32 bits indices are supported */
  7102. uintIndices: boolean;
  7103. /** Defines if high precision shaders are supported */
  7104. highPrecisionShaderSupported: boolean;
  7105. /** Defines if depth reading in the fragment shader is supported */
  7106. fragmentDepthSupported: boolean;
  7107. /** Defines if float texture linear filtering is supported*/
  7108. textureFloatLinearFiltering: boolean;
  7109. /** Defines if rendering to float textures is supported */
  7110. textureFloatRender: boolean;
  7111. /** Defines if half float textures are supported*/
  7112. textureHalfFloat: boolean;
  7113. /** Defines if half float texture linear filtering is supported*/
  7114. textureHalfFloatLinearFiltering: boolean;
  7115. /** Defines if rendering to half float textures is supported */
  7116. textureHalfFloatRender: boolean;
  7117. /** Defines if textureLOD shader command is supported */
  7118. textureLOD: boolean;
  7119. /** Defines if draw buffers extension is supported */
  7120. drawBuffersExtension: boolean;
  7121. /** Defines if depth textures are supported */
  7122. depthTextureExtension: boolean;
  7123. /** Defines if float color buffer are supported */
  7124. colorBufferFloat: boolean;
  7125. /** Gets disjoint timer query extension (null if not supported) */
  7126. timerQuery: EXT_disjoint_timer_query;
  7127. /** Defines if timestamp can be used with timer query */
  7128. canUseTimestampForTimerQuery: boolean;
  7129. }
  7130. /** Interface defining initialization parameters for Engine class */
  7131. interface EngineOptions extends WebGLContextAttributes {
  7132. /**
  7133. * Defines if the engine should no exceed a specified device ratio
  7134. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7135. */
  7136. limitDeviceRatio?: number;
  7137. /**
  7138. * Defines if webvr should be enabled automatically
  7139. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7140. */
  7141. autoEnableWebVR?: boolean;
  7142. /**
  7143. * Defines if webgl2 should be turned off even if supported
  7144. * @see http://doc.babylonjs.com/features/webgl2
  7145. */
  7146. disableWebGL2Support?: boolean;
  7147. /**
  7148. * Defines if webaudio should be initialized as well
  7149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7150. */
  7151. audioEngine?: boolean;
  7152. /**
  7153. * Defines if animations should run using a deterministic lock step
  7154. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7155. */
  7156. deterministicLockstep?: boolean;
  7157. /** Defines the maximum steps to use with deterministic lock step mode */
  7158. lockstepMaxSteps?: number;
  7159. /**
  7160. * Defines that engine should ignore context lost events
  7161. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7162. */
  7163. doNotHandleContextLost?: boolean;
  7164. }
  7165. /**
  7166. * Defines the interface used by display changed events
  7167. */
  7168. interface IDisplayChangedEventArgs {
  7169. /** Gets the vrDisplay object (if any) */
  7170. vrDisplay: Nullable<any>;
  7171. /** Gets a boolean indicating if webVR is supported */
  7172. vrSupported: boolean;
  7173. }
  7174. /**
  7175. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7176. */
  7177. class Engine {
  7178. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7179. static ExceptionList: ({
  7180. key: string;
  7181. capture: string;
  7182. captureConstraint: number;
  7183. targets: string[];
  7184. } | {
  7185. key: string;
  7186. capture: null;
  7187. captureConstraint: null;
  7188. targets: string[];
  7189. })[];
  7190. /** Gets the list of created engines */
  7191. static Instances: Engine[];
  7192. /**
  7193. * Gets the latest created engine
  7194. */
  7195. static readonly LastCreatedEngine: Nullable<Engine>;
  7196. /**
  7197. * Gets the latest created scene
  7198. */
  7199. static readonly LastCreatedScene: Nullable<Scene>;
  7200. /**
  7201. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7202. * @param flag defines which part of the materials must be marked as dirty
  7203. * @param predicate defines a predicate used to filter which materials should be affected
  7204. */
  7205. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7206. /**
  7207. * Hidden
  7208. */
  7209. private static _TextureLoaders: IInternalTextureLoader[];
  7210. /** Defines that alpha blending is disabled */
  7211. static readonly ALPHA_DISABLE: number;
  7212. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7213. static readonly ALPHA_ADD: number;
  7214. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7215. static readonly ALPHA_COMBINE: number;
  7216. /** Defines that alpha blending to DEST - SRC * DEST */
  7217. static readonly ALPHA_SUBTRACT: number;
  7218. /** Defines that alpha blending to SRC * DEST */
  7219. static readonly ALPHA_MULTIPLY: number;
  7220. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7221. static readonly ALPHA_MAXIMIZED: number;
  7222. /** Defines that alpha blending to SRC + DEST */
  7223. static readonly ALPHA_ONEONE: number;
  7224. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7225. static readonly ALPHA_PREMULTIPLIED: number;
  7226. /**
  7227. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7228. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7229. */
  7230. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7231. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7232. static readonly ALPHA_INTERPOLATE: number;
  7233. /**
  7234. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7235. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7236. */
  7237. static readonly ALPHA_SCREENMODE: number;
  7238. /** Defines that the ressource is not delayed*/
  7239. static readonly DELAYLOADSTATE_NONE: number;
  7240. /** Defines that the ressource was successfully delay loaded */
  7241. static readonly DELAYLOADSTATE_LOADED: number;
  7242. /** Defines that the ressource is currently delay loading */
  7243. static readonly DELAYLOADSTATE_LOADING: number;
  7244. /** Defines that the ressource is delayed and has not started loading */
  7245. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7247. static readonly NEVER: number;
  7248. /** 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 */
  7249. static readonly ALWAYS: number;
  7250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7251. static readonly LESS: number;
  7252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7253. static readonly EQUAL: number;
  7254. /** 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 */
  7255. static readonly LEQUAL: number;
  7256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7257. static readonly GREATER: number;
  7258. /** 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 */
  7259. static readonly GEQUAL: number;
  7260. /** 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 */
  7261. static readonly NOTEQUAL: number;
  7262. /** Passed to stencilOperation to specify that stencil value must be kept */
  7263. static readonly KEEP: number;
  7264. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7265. static readonly REPLACE: number;
  7266. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7267. static readonly INCR: number;
  7268. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7269. static readonly DECR: number;
  7270. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7271. static readonly INVERT: number;
  7272. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7273. static readonly INCR_WRAP: number;
  7274. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7275. static readonly DECR_WRAP: number;
  7276. /** Texture is not repeating outside of 0..1 UVs */
  7277. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7278. /** Texture is repeating outside of 0..1 UVs */
  7279. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7280. /** Texture is repeating and mirrored */
  7281. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7282. /** ALPHA */
  7283. static readonly TEXTUREFORMAT_ALPHA: number;
  7284. /** LUMINANCE */
  7285. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7286. /** LUMINANCE_ALPHA */
  7287. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7288. /** RGB */
  7289. static readonly TEXTUREFORMAT_RGB: number;
  7290. /** RGBA */
  7291. static readonly TEXTUREFORMAT_RGBA: number;
  7292. /** RED */
  7293. static readonly TEXTUREFORMAT_RED: number;
  7294. /** RED (2nd reference) */
  7295. static readonly TEXTUREFORMAT_R: number;
  7296. /** RG */
  7297. static readonly TEXTUREFORMAT_RG: number;
  7298. /** RED_INTEGER */
  7299. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7300. /** RED_INTEGER (2nd reference) */
  7301. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7302. /** RG_INTEGER */
  7303. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7304. /** RGB_INTEGER */
  7305. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7306. /** RGBA_INTEGER */
  7307. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7308. /** UNSIGNED_BYTE */
  7309. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7310. /** UNSIGNED_BYTE (2nd reference) */
  7311. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7312. /** FLOAT */
  7313. static readonly TEXTURETYPE_FLOAT: number;
  7314. /** HALF_FLOAT */
  7315. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7316. /** BYTE */
  7317. static readonly TEXTURETYPE_BYTE: number;
  7318. /** SHORT */
  7319. static readonly TEXTURETYPE_SHORT: number;
  7320. /** UNSIGNED_SHORT */
  7321. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7322. /** INT */
  7323. static readonly TEXTURETYPE_INT: number;
  7324. /** UNSIGNED_INT */
  7325. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7326. /** UNSIGNED_SHORT_4_4_4_4 */
  7327. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7328. /** UNSIGNED_SHORT_5_5_5_1 */
  7329. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7330. /** UNSIGNED_SHORT_5_6_5 */
  7331. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7332. /** UNSIGNED_INT_2_10_10_10_REV */
  7333. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7334. /** UNSIGNED_INT_24_8 */
  7335. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7336. /** UNSIGNED_INT_10F_11F_11F_REV */
  7337. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7338. /** UNSIGNED_INT_5_9_9_9_REV */
  7339. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7340. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7341. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7342. /** nearest is mag = nearest and min = nearest and mip = linear */
  7343. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7344. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7345. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7346. /** Trilinear is mag = linear and min = linear and mip = linear */
  7347. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7348. /** nearest is mag = nearest and min = nearest and mip = linear */
  7349. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7350. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7351. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7352. /** Trilinear is mag = linear and min = linear and mip = linear */
  7353. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7354. /** mag = nearest and min = nearest and mip = nearest */
  7355. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7356. /** mag = nearest and min = linear and mip = nearest */
  7357. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7358. /** mag = nearest and min = linear and mip = linear */
  7359. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7360. /** mag = nearest and min = linear and mip = none */
  7361. static readonly TEXTURE_NEAREST_LINEAR: number;
  7362. /** mag = nearest and min = nearest and mip = none */
  7363. static readonly TEXTURE_NEAREST_NEAREST: number;
  7364. /** mag = linear and min = nearest and mip = nearest */
  7365. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7366. /** mag = linear and min = nearest and mip = linear */
  7367. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7368. /** mag = linear and min = linear and mip = none */
  7369. static readonly TEXTURE_LINEAR_LINEAR: number;
  7370. /** mag = linear and min = nearest and mip = none */
  7371. static readonly TEXTURE_LINEAR_NEAREST: number;
  7372. /** Explicit coordinates mode */
  7373. static readonly TEXTURE_EXPLICIT_MODE: number;
  7374. /** Spherical coordinates mode */
  7375. static readonly TEXTURE_SPHERICAL_MODE: number;
  7376. /** Planar coordinates mode */
  7377. static readonly TEXTURE_PLANAR_MODE: number;
  7378. /** Cubic coordinates mode */
  7379. static readonly TEXTURE_CUBIC_MODE: number;
  7380. /** Projection coordinates mode */
  7381. static readonly TEXTURE_PROJECTION_MODE: number;
  7382. /** Skybox coordinates mode */
  7383. static readonly TEXTURE_SKYBOX_MODE: number;
  7384. /** Inverse Cubic coordinates mode */
  7385. static readonly TEXTURE_INVCUBIC_MODE: number;
  7386. /** Equirectangular coordinates mode */
  7387. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7388. /** Equirectangular Fixed coordinates mode */
  7389. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7390. /** Equirectangular Fixed Mirrored coordinates mode */
  7391. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7392. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7393. static readonly SCALEMODE_FLOOR: number;
  7394. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7395. static readonly SCALEMODE_NEAREST: number;
  7396. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7397. static readonly SCALEMODE_CEILING: number;
  7398. /**
  7399. * Returns the current version of the framework
  7400. */
  7401. static readonly Version: string;
  7402. /**
  7403. * Gets or sets the epsilon value used by collision engine
  7404. */
  7405. static CollisionsEpsilon: number;
  7406. /**
  7407. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7408. */
  7409. static CodeRepository: string;
  7410. /**
  7411. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7412. */
  7413. static ShadersRepository: string;
  7414. /**
  7415. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7416. */
  7417. forcePOTTextures: boolean;
  7418. /**
  7419. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7420. */
  7421. isFullscreen: boolean;
  7422. /**
  7423. * Gets a boolean indicating if the pointer is currently locked
  7424. */
  7425. isPointerLock: boolean;
  7426. /**
  7427. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7428. */
  7429. cullBackFaces: boolean;
  7430. /**
  7431. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7432. */
  7433. renderEvenInBackground: boolean;
  7434. /**
  7435. * Gets or sets a boolean indicating that cache can be kept between frames
  7436. */
  7437. preventCacheWipeBetweenFrames: boolean;
  7438. /**
  7439. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7440. **/
  7441. enableOfflineSupport: boolean;
  7442. /**
  7443. * 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)
  7444. **/
  7445. disableManifestCheck: boolean;
  7446. /**
  7447. * Gets the list of created scenes
  7448. */
  7449. scenes: Scene[];
  7450. /**
  7451. * Gets the list of created postprocesses
  7452. */
  7453. postProcesses: PostProcess[];
  7454. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7455. validateShaderPrograms: boolean;
  7456. /**
  7457. * Observable event triggered each time the rendering canvas is resized
  7458. */
  7459. onResizeObservable: Observable<Engine>;
  7460. /**
  7461. * Observable event triggered each time the canvas loses focus
  7462. */
  7463. onCanvasBlurObservable: Observable<Engine>;
  7464. /**
  7465. * Observable event triggered each time the canvas gains focus
  7466. */
  7467. onCanvasFocusObservable: Observable<Engine>;
  7468. /**
  7469. * Observable event triggered each time the canvas receives pointerout event
  7470. */
  7471. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7472. /**
  7473. * Observable event triggered before each texture is initialized
  7474. */
  7475. onBeforeTextureInitObservable: Observable<Texture>;
  7476. private _vrDisplay;
  7477. private _vrSupported;
  7478. private _oldSize;
  7479. private _oldHardwareScaleFactor;
  7480. private _vrExclusivePointerMode;
  7481. private _webVRInitPromise;
  7482. /**
  7483. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7484. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7485. */
  7486. readonly isInVRExclusivePointerMode: boolean;
  7487. /**
  7488. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7489. */
  7490. disableUniformBuffers: boolean;
  7491. /** @hidden */
  7492. /**
  7493. * Gets a boolean indicating that the engine supports uniform buffers
  7494. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7495. */
  7496. readonly supportsUniformBuffers: boolean;
  7497. /**
  7498. * Observable raised when the engine begins a new frame
  7499. */
  7500. onBeginFrameObservable: Observable<Engine>;
  7501. /**
  7502. * Observable raised when the engine ends the current frame
  7503. */
  7504. onEndFrameObservable: Observable<Engine>;
  7505. /**
  7506. * Observable raised when the engine is about to compile a shader
  7507. */
  7508. onBeforeShaderCompilationObservable: Observable<Engine>;
  7509. /**
  7510. * Observable raised when the engine has jsut compiled a shader
  7511. */
  7512. onAfterShaderCompilationObservable: Observable<Engine>;
  7513. /** @hidden */
  7514. private _renderingCanvas;
  7515. private _windowIsBackground;
  7516. private _webGLVersion;
  7517. /**
  7518. * Gets a boolean indicating that only power of 2 textures are supported
  7519. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7520. */
  7521. readonly needPOTTextures: boolean;
  7522. /** @hidden */
  7523. /** @hidden */
  7524. /**
  7525. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7526. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7527. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7528. */
  7529. disableTextureBindingOptimization: boolean;
  7530. /**
  7531. * Gets the audio engine
  7532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7533. * @ignorenaming
  7534. */
  7535. static audioEngine: AudioEngine;
  7536. private _onFocus;
  7537. private _onBlur;
  7538. private _onCanvasPointerOut;
  7539. private _onCanvasBlur;
  7540. private _onCanvasFocus;
  7541. private _onFullscreenChange;
  7542. private _onPointerLockChange;
  7543. private _onVRDisplayPointerRestricted;
  7544. private _onVRDisplayPointerUnrestricted;
  7545. private _onVrDisplayConnect;
  7546. private _onVrDisplayDisconnect;
  7547. private _onVrDisplayPresentChange;
  7548. /**
  7549. * Observable signaled when VR display mode changes
  7550. */
  7551. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7552. /**
  7553. * Observable signaled when VR request present is complete
  7554. */
  7555. onVRRequestPresentComplete: Observable<boolean>;
  7556. /**
  7557. * Observable signaled when VR request present starts
  7558. */
  7559. onVRRequestPresentStart: Observable<Engine>;
  7560. private _hardwareScalingLevel;
  7561. /** @hidden */
  7562. protected _caps: EngineCapabilities;
  7563. private _pointerLockRequested;
  7564. private _isStencilEnable;
  7565. private _colorWrite;
  7566. private _loadingScreen;
  7567. /** @hidden */
  7568. /** @hidden */
  7569. private _glVersion;
  7570. private _glRenderer;
  7571. private _glVendor;
  7572. private _videoTextureSupported;
  7573. private _renderingQueueLaunched;
  7574. private _activeRenderLoops;
  7575. private _deterministicLockstep;
  7576. private _lockstepMaxSteps;
  7577. /**
  7578. * Observable signaled when a context lost event is raised
  7579. */
  7580. onContextLostObservable: Observable<Engine>;
  7581. /**
  7582. * Observable signaled when a context restored event is raised
  7583. */
  7584. onContextRestoredObservable: Observable<Engine>;
  7585. private _onContextLost;
  7586. private _onContextRestored;
  7587. private _contextWasLost;
  7588. private _doNotHandleContextLost;
  7589. /**
  7590. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7592. */
  7593. doNotHandleContextLost: boolean;
  7594. private _performanceMonitor;
  7595. private _fps;
  7596. private _deltaTime;
  7597. /**
  7598. * Turn this value on if you want to pause FPS computation when in background
  7599. */
  7600. disablePerformanceMonitorInBackground: boolean;
  7601. /**
  7602. * Gets the performance monitor attached to this engine
  7603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7604. */
  7605. readonly performanceMonitor: PerformanceMonitor;
  7606. /** @hidden */
  7607. protected _depthCullingState: _DepthCullingState;
  7608. /** @hidden */
  7609. protected _stencilState: _StencilState;
  7610. /** @hidden */
  7611. protected _alphaState: _AlphaState;
  7612. /** @hidden */
  7613. protected _alphaMode: number;
  7614. protected _internalTexturesCache: InternalTexture[];
  7615. /** @hidden */
  7616. protected _activeChannel: number;
  7617. private _currentTextureChannel;
  7618. /** @hidden */
  7619. protected _boundTexturesCache: {
  7620. [key: string]: Nullable<InternalTexture>;
  7621. };
  7622. /** @hidden */
  7623. protected _currentEffect: Nullable<Effect>;
  7624. /** @hidden */
  7625. protected _currentProgram: Nullable<WebGLProgram>;
  7626. private _compiledEffects;
  7627. private _vertexAttribArraysEnabled;
  7628. /** @hidden */
  7629. protected _cachedViewport: Nullable<Viewport>;
  7630. private _cachedVertexArrayObject;
  7631. /** @hidden */
  7632. protected _cachedVertexBuffers: any;
  7633. /** @hidden */
  7634. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7635. /** @hidden */
  7636. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7637. /** @hidden */
  7638. protected _currentRenderTarget: Nullable<InternalTexture>;
  7639. private _uintIndicesCurrentlySet;
  7640. private _currentBoundBuffer;
  7641. /** @hidden */
  7642. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7643. private _currentBufferPointers;
  7644. private _currentInstanceLocations;
  7645. private _currentInstanceBuffers;
  7646. private _textureUnits;
  7647. private _firstBoundInternalTextureTracker;
  7648. private _lastBoundInternalTextureTracker;
  7649. private _workingCanvas;
  7650. private _workingContext;
  7651. private _rescalePostProcess;
  7652. private _dummyFramebuffer;
  7653. private _externalData;
  7654. private _bindedRenderFunction;
  7655. private _vaoRecordInProgress;
  7656. private _mustWipeVertexAttributes;
  7657. private _emptyTexture;
  7658. private _emptyCubeTexture;
  7659. private _emptyTexture3D;
  7660. private _frameHandler;
  7661. private _nextFreeTextureSlots;
  7662. private _maxSimultaneousTextures;
  7663. private _activeRequests;
  7664. private _texturesSupported;
  7665. private _textureFormatInUse;
  7666. /**
  7667. * Gets the list of texture formats supported
  7668. */
  7669. readonly texturesSupported: Array<string>;
  7670. /**
  7671. * Gets the list of texture formats in use
  7672. */
  7673. readonly textureFormatInUse: Nullable<string>;
  7674. /**
  7675. * Gets the current viewport
  7676. */
  7677. readonly currentViewport: Nullable<Viewport>;
  7678. /**
  7679. * Gets the default empty texture
  7680. */
  7681. readonly emptyTexture: InternalTexture;
  7682. /**
  7683. * Gets the default empty 3D texture
  7684. */
  7685. readonly emptyTexture3D: InternalTexture;
  7686. /**
  7687. * Gets the default empty cube texture
  7688. */
  7689. readonly emptyCubeTexture: InternalTexture;
  7690. /**
  7691. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7692. */
  7693. readonly premultipliedAlpha: boolean;
  7694. /**
  7695. * Creates a new engine
  7696. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7697. * @param antialias defines enable antialiasing (default: false)
  7698. * @param options defines further options to be sent to the getContext() function
  7699. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7700. */
  7701. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7702. private _rebuildInternalTextures;
  7703. private _rebuildEffects;
  7704. private _rebuildBuffers;
  7705. private _initGLContext;
  7706. /**
  7707. * Gets version of the current webGL context
  7708. */
  7709. readonly webGLVersion: number;
  7710. /**
  7711. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7712. */
  7713. readonly isStencilEnable: boolean;
  7714. private _prepareWorkingCanvas;
  7715. /**
  7716. * Reset the texture cache to empty state
  7717. */
  7718. resetTextureCache(): void;
  7719. /**
  7720. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7722. * @returns true if engine is in deterministic lock step mode
  7723. */
  7724. isDeterministicLockStep(): boolean;
  7725. /**
  7726. * Gets the max steps when engine is running in deterministic lock step
  7727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7728. * @returns the max steps
  7729. */
  7730. getLockstepMaxSteps(): number;
  7731. /**
  7732. * Gets an object containing information about the current webGL context
  7733. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7734. */
  7735. getGlInfo(): {
  7736. vendor: string;
  7737. renderer: string;
  7738. version: string;
  7739. };
  7740. /**
  7741. * Gets current aspect ratio
  7742. * @param camera defines the camera to use to get the aspect ratio
  7743. * @param useScreen defines if screen size must be used (or the current render target if any)
  7744. * @returns a number defining the aspect ratio
  7745. */
  7746. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7747. /**
  7748. * Gets current screen aspect ratio
  7749. * @returns a number defining the aspect ratio
  7750. */
  7751. getScreenAspectRatio(): number;
  7752. /**
  7753. * Gets the current render width
  7754. * @param useScreen defines if screen size must be used (or the current render target if any)
  7755. * @returns a number defining the current render width
  7756. */
  7757. getRenderWidth(useScreen?: boolean): number;
  7758. /**
  7759. * Gets the current render height
  7760. * @param useScreen defines if screen size must be used (or the current render target if any)
  7761. * @returns a number defining the current render height
  7762. */
  7763. getRenderHeight(useScreen?: boolean): number;
  7764. /**
  7765. * Gets the HTML canvas attached with the current webGL context
  7766. * @returns a HTML canvas
  7767. */
  7768. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7769. /**
  7770. * Gets the client rect of the HTML canvas attached with the current webGL context
  7771. * @returns a client rectanglee
  7772. */
  7773. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7774. /**
  7775. * Defines the hardware scaling level.
  7776. * By default the hardware scaling level is computed from the window device ratio.
  7777. * 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.
  7778. * @param level defines the level to use
  7779. */
  7780. setHardwareScalingLevel(level: number): void;
  7781. /**
  7782. * Gets the current hardware scaling level.
  7783. * By default the hardware scaling level is computed from the window device ratio.
  7784. * 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.
  7785. * @returns a number indicating the current hardware scaling level
  7786. */
  7787. getHardwareScalingLevel(): number;
  7788. /**
  7789. * Gets the list of loaded textures
  7790. * @returns an array containing all loaded textures
  7791. */
  7792. getLoadedTexturesCache(): InternalTexture[];
  7793. /**
  7794. * Gets the object containing all engine capabilities
  7795. * @returns the EngineCapabilities object
  7796. */
  7797. getCaps(): EngineCapabilities;
  7798. /** @hidden */
  7799. readonly drawCalls: number;
  7800. /** @hidden */
  7801. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7802. /**
  7803. * Gets the current depth function
  7804. * @returns a number defining the depth function
  7805. */
  7806. getDepthFunction(): Nullable<number>;
  7807. /**
  7808. * Sets the current depth function
  7809. * @param depthFunc defines the function to use
  7810. */
  7811. setDepthFunction(depthFunc: number): void;
  7812. /**
  7813. * Sets the current depth function to GREATER
  7814. */
  7815. setDepthFunctionToGreater(): void;
  7816. /**
  7817. * Sets the current depth function to GEQUAL
  7818. */
  7819. setDepthFunctionToGreaterOrEqual(): void;
  7820. /**
  7821. * Sets the current depth function to LESS
  7822. */
  7823. setDepthFunctionToLess(): void;
  7824. /**
  7825. * Sets the current depth function to LEQUAL
  7826. */
  7827. setDepthFunctionToLessOrEqual(): void;
  7828. /**
  7829. * Gets a boolean indicating if stencil buffer is enabled
  7830. * @returns the current stencil buffer state
  7831. */
  7832. getStencilBuffer(): boolean;
  7833. /**
  7834. * Enable or disable the stencil buffer
  7835. * @param enable defines if the stencil buffer must be enabled or disabled
  7836. */
  7837. setStencilBuffer(enable: boolean): void;
  7838. /**
  7839. * Gets the current stencil mask
  7840. * @returns a number defining the new stencil mask to use
  7841. */
  7842. getStencilMask(): number;
  7843. /**
  7844. * Sets the current stencil mask
  7845. * @param mask defines the new stencil mask to use
  7846. */
  7847. setStencilMask(mask: number): void;
  7848. /**
  7849. * Gets the current stencil function
  7850. * @returns a number defining the stencil function to use
  7851. */
  7852. getStencilFunction(): number;
  7853. /**
  7854. * Gets the current stencil reference value
  7855. * @returns a number defining the stencil reference value to use
  7856. */
  7857. getStencilFunctionReference(): number;
  7858. /**
  7859. * Gets the current stencil mask
  7860. * @returns a number defining the stencil mask to use
  7861. */
  7862. getStencilFunctionMask(): number;
  7863. /**
  7864. * Sets the current stencil function
  7865. * @param stencilFunc defines the new stencil function to use
  7866. */
  7867. setStencilFunction(stencilFunc: number): void;
  7868. /**
  7869. * Sets the current stencil reference
  7870. * @param reference defines the new stencil reference to use
  7871. */
  7872. setStencilFunctionReference(reference: number): void;
  7873. /**
  7874. * Sets the current stencil mask
  7875. * @param mask defines the new stencil mask to use
  7876. */
  7877. setStencilFunctionMask(mask: number): void;
  7878. /**
  7879. * Gets the current stencil operation when stencil fails
  7880. * @returns a number defining stencil operation to use when stencil fails
  7881. */
  7882. getStencilOperationFail(): number;
  7883. /**
  7884. * Gets the current stencil operation when depth fails
  7885. * @returns a number defining stencil operation to use when depth fails
  7886. */
  7887. getStencilOperationDepthFail(): number;
  7888. /**
  7889. * Gets the current stencil operation when stencil passes
  7890. * @returns a number defining stencil operation to use when stencil passes
  7891. */
  7892. getStencilOperationPass(): number;
  7893. /**
  7894. * Sets the stencil operation to use when stencil fails
  7895. * @param operation defines the stencil operation to use when stencil fails
  7896. */
  7897. setStencilOperationFail(operation: number): void;
  7898. /**
  7899. * Sets the stencil operation to use when depth fails
  7900. * @param operation defines the stencil operation to use when depth fails
  7901. */
  7902. setStencilOperationDepthFail(operation: number): void;
  7903. /**
  7904. * Sets the stencil operation to use when stencil passes
  7905. * @param operation defines the stencil operation to use when stencil passes
  7906. */
  7907. setStencilOperationPass(operation: number): void;
  7908. /**
  7909. * Sets a boolean indicating if the dithering state is enabled or disabled
  7910. * @param value defines the dithering state
  7911. */
  7912. setDitheringState(value: boolean): void;
  7913. /**
  7914. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7915. * @param value defines the rasterizer state
  7916. */
  7917. setRasterizerState(value: boolean): void;
  7918. /**
  7919. * stop executing a render loop function and remove it from the execution array
  7920. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7921. */
  7922. stopRenderLoop(renderFunction?: () => void): void;
  7923. /** @hidden */
  7924. /**
  7925. * Register and execute a render loop. The engine can have more than one render function
  7926. * @param renderFunction defines the function to continuously execute
  7927. */
  7928. runRenderLoop(renderFunction: () => void): void;
  7929. /**
  7930. * Toggle full screen mode
  7931. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7932. * @param options defines an option object to be sent to the requestFullscreen function
  7933. */
  7934. switchFullscreen(requestPointerLock: boolean): void;
  7935. /**
  7936. * Clear the current render buffer or the current render target (if any is set up)
  7937. * @param color defines the color to use
  7938. * @param backBuffer defines if the back buffer must be cleared
  7939. * @param depth defines if the depth buffer must be cleared
  7940. * @param stencil defines if the stencil buffer must be cleared
  7941. */
  7942. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7943. /**
  7944. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7945. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7946. * @param y defines the y-coordinate of the corner of the clear rectangle
  7947. * @param width defines the width of the clear rectangle
  7948. * @param height defines the height of the clear rectangle
  7949. * @param clearColor defines the clear color
  7950. */
  7951. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7952. private _viewportCached;
  7953. /** @hidden */
  7954. /**
  7955. * Set the WebGL's viewport
  7956. * @param viewport defines the viewport element to be used
  7957. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7958. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7959. */
  7960. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7961. /**
  7962. * Directly set the WebGL Viewport
  7963. * @param x defines the x coordinate of the viewport (in screen space)
  7964. * @param y defines the y coordinate of the viewport (in screen space)
  7965. * @param width defines the width of the viewport (in screen space)
  7966. * @param height defines the height of the viewport (in screen space)
  7967. * @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
  7968. */
  7969. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7970. /**
  7971. * Begin a new frame
  7972. */
  7973. beginFrame(): void;
  7974. /**
  7975. * Enf the current frame
  7976. */
  7977. endFrame(): void;
  7978. /**
  7979. * Resize the view according to the canvas' size
  7980. */
  7981. resize(): void;
  7982. /**
  7983. * Force a specific size of the canvas
  7984. * @param width defines the new canvas' width
  7985. * @param height defines the new canvas' height
  7986. */
  7987. setSize(width: number, height: number): void;
  7988. /**
  7989. * Gets a boolean indicating if a webVR device was detected
  7990. * @returns true if a webVR device was detected
  7991. */
  7992. isVRDevicePresent(): boolean;
  7993. /**
  7994. * Gets the current webVR device
  7995. * @returns the current webVR device (or null)
  7996. */
  7997. getVRDevice(): any;
  7998. /**
  7999. * Initializes a webVR display and starts listening to display change events
  8000. * The onVRDisplayChangedObservable will be notified upon these changes
  8001. * @returns The onVRDisplayChangedObservable
  8002. */
  8003. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8004. /**
  8005. * Initializes a webVR display and starts listening to display change events
  8006. * The onVRDisplayChangedObservable will be notified upon these changes
  8007. * @returns A promise containing a VRDisplay and if vr is supported
  8008. */
  8009. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8010. /**
  8011. * Call this function to switch to webVR mode
  8012. * Will do nothing if webVR is not supported or if there is no webVR device
  8013. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8014. */
  8015. enableVR(): void;
  8016. /**
  8017. * Call this function to leave webVR mode
  8018. * Will do nothing if webVR is not supported or if there is no webVR device
  8019. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8020. */
  8021. disableVR(): void;
  8022. private _onVRFullScreenTriggered;
  8023. private _getVRDisplaysAsync;
  8024. /**
  8025. * Binds the frame buffer to the specified texture.
  8026. * @param texture The texture to render to or null for the default canvas
  8027. * @param faceIndex The face of the texture to render to in case of cube texture
  8028. * @param requiredWidth The width of the target to render to
  8029. * @param requiredHeight The height of the target to render to
  8030. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8031. * @param depthStencilTexture The depth stencil texture to use to render
  8032. * @param lodLevel defines le lod level to bind to the frame buffer
  8033. */
  8034. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8035. private bindUnboundFramebuffer;
  8036. /**
  8037. * Unbind the current render target texture from the webGL context
  8038. * @param texture defines the render target texture to unbind
  8039. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8040. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8041. */
  8042. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8043. /**
  8044. * Unbind a list of render target textures from the webGL context
  8045. * This is used only when drawBuffer extension or webGL2 are active
  8046. * @param textures defines the render target textures to unbind
  8047. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8048. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8049. */
  8050. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8051. /**
  8052. * Force the mipmap generation for the given render target texture
  8053. * @param texture defines the render target texture to use
  8054. */
  8055. generateMipMapsForCubemap(texture: InternalTexture): void;
  8056. /**
  8057. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8058. */
  8059. flushFramebuffer(): void;
  8060. /**
  8061. * Unbind the current render target and bind the default framebuffer
  8062. */
  8063. restoreDefaultFramebuffer(): void;
  8064. /**
  8065. * Create an uniform buffer
  8066. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8067. * @param elements defines the content of the uniform buffer
  8068. * @returns the webGL uniform buffer
  8069. */
  8070. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8071. /**
  8072. * Create a dynamic uniform buffer
  8073. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8074. * @param elements defines the content of the uniform buffer
  8075. * @returns the webGL uniform buffer
  8076. */
  8077. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8078. /**
  8079. * Update an existing uniform buffer
  8080. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8081. * @param uniformBuffer defines the target uniform buffer
  8082. * @param elements defines the content to update
  8083. * @param offset defines the offset in the uniform buffer where update should start
  8084. * @param count defines the size of the data to update
  8085. */
  8086. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8087. private _resetVertexBufferBinding;
  8088. /**
  8089. * Creates a vertex buffer
  8090. * @param data the data for the vertex buffer
  8091. * @returns the new WebGL static buffer
  8092. */
  8093. createVertexBuffer(data: DataArray): WebGLBuffer;
  8094. /**
  8095. * Creates a dynamic vertex buffer
  8096. * @param data the data for the dynamic vertex buffer
  8097. * @returns the new WebGL dynamic buffer
  8098. */
  8099. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8100. /**
  8101. * Update a dynamic index buffer
  8102. * @param indexBuffer defines the target index buffer
  8103. * @param indices defines the data to update
  8104. * @param offset defines the offset in the target index buffer where update should start
  8105. */
  8106. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8107. /**
  8108. * Updates a dynamic vertex buffer.
  8109. * @param vertexBuffer the vertex buffer to update
  8110. * @param data the data used to update the vertex buffer
  8111. * @param byteOffset the byte offset of the data
  8112. * @param byteLength the byte length of the data
  8113. */
  8114. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8115. private _resetIndexBufferBinding;
  8116. /**
  8117. * Creates a new index buffer
  8118. * @param indices defines the content of the index buffer
  8119. * @param updatable defines if the index buffer must be updatable
  8120. * @returns a new webGL buffer
  8121. */
  8122. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8123. /**
  8124. * Bind a webGL buffer to the webGL context
  8125. * @param buffer defines the buffer to bind
  8126. */
  8127. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8128. /**
  8129. * Bind an uniform buffer to the current webGL context
  8130. * @param buffer defines the buffer to bind
  8131. */
  8132. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8133. /**
  8134. * Bind a buffer to the current webGL context at a given location
  8135. * @param buffer defines the buffer to bind
  8136. * @param location defines the index where to bind the buffer
  8137. */
  8138. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8139. /**
  8140. * Bind a specific block at a given index in a specific shader program
  8141. * @param shaderProgram defines the shader program
  8142. * @param blockName defines the block name
  8143. * @param index defines the index where to bind the block
  8144. */
  8145. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8146. private bindIndexBuffer;
  8147. private bindBuffer;
  8148. /**
  8149. * update the bound buffer with the given data
  8150. * @param data defines the data to update
  8151. */
  8152. updateArrayBuffer(data: Float32Array): void;
  8153. private _vertexAttribPointer;
  8154. private _bindIndexBufferWithCache;
  8155. private _bindVertexBuffersAttributes;
  8156. /**
  8157. * Records a vertex array object
  8158. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8159. * @param vertexBuffers defines the list of vertex buffers to store
  8160. * @param indexBuffer defines the index buffer to store
  8161. * @param effect defines the effect to store
  8162. * @returns the new vertex array object
  8163. */
  8164. recordVertexArrayObject(vertexBuffers: {
  8165. [key: string]: VertexBuffer;
  8166. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8167. /**
  8168. * Bind a specific vertex array object
  8169. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8170. * @param vertexArrayObject defines the vertex array object to bind
  8171. * @param indexBuffer defines the index buffer to bind
  8172. */
  8173. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8174. /**
  8175. * Bind webGl buffers directly to the webGL context
  8176. * @param vertexBuffer defines the vertex buffer to bind
  8177. * @param indexBuffer defines the index buffer to bind
  8178. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8179. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8180. * @param effect defines the effect associated with the vertex buffer
  8181. */
  8182. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8183. private _unbindVertexArrayObject;
  8184. /**
  8185. * Bind a list of vertex buffers to the webGL context
  8186. * @param vertexBuffers defines the list of vertex buffers to bind
  8187. * @param indexBuffer defines the index buffer to bind
  8188. * @param effect defines the effect associated with the vertex buffers
  8189. */
  8190. bindBuffers(vertexBuffers: {
  8191. [key: string]: Nullable<VertexBuffer>;
  8192. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8193. /**
  8194. * Unbind all instance attributes
  8195. */
  8196. unbindInstanceAttributes(): void;
  8197. /**
  8198. * Release and free the memory of a vertex array object
  8199. * @param vao defines the vertex array object to delete
  8200. */
  8201. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8202. /** @hidden */
  8203. /**
  8204. * Creates a webGL buffer to use with instanciation
  8205. * @param capacity defines the size of the buffer
  8206. * @returns the webGL buffer
  8207. */
  8208. createInstancesBuffer(capacity: number): WebGLBuffer;
  8209. /**
  8210. * Delete a webGL buffer used with instanciation
  8211. * @param buffer defines the webGL buffer to delete
  8212. */
  8213. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8214. /**
  8215. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8216. * @param instancesBuffer defines the webGL buffer to update and bind
  8217. * @param data defines the data to store in the buffer
  8218. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8219. */
  8220. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8221. /**
  8222. * Apply all cached states (depth, culling, stencil and alpha)
  8223. */
  8224. applyStates(): void;
  8225. /**
  8226. * Send a draw order
  8227. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8228. * @param indexStart defines the starting index
  8229. * @param indexCount defines the number of index to draw
  8230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8231. */
  8232. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8233. /**
  8234. * Draw a list of points
  8235. * @param verticesStart defines the index of first vertex to draw
  8236. * @param verticesCount defines the count of vertices to draw
  8237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8238. */
  8239. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8240. /**
  8241. * Draw a list of unindexed primitives
  8242. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8243. * @param verticesStart defines the index of first vertex to draw
  8244. * @param verticesCount defines the count of vertices to draw
  8245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8246. */
  8247. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8248. /**
  8249. * Draw a list of indexed primitives
  8250. * @param fillMode defines the primitive to use
  8251. * @param indexStart defines the starting index
  8252. * @param indexCount defines the number of index to draw
  8253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8254. */
  8255. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8256. /**
  8257. * Draw a list of unindexed primitives
  8258. * @param fillMode defines the primitive to use
  8259. * @param verticesStart defines the index of first vertex to draw
  8260. * @param verticesCount defines the count of vertices to draw
  8261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8262. */
  8263. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8264. private _drawMode;
  8265. /** @hidden */
  8266. /** @hidden */
  8267. /**
  8268. * Create a new effect (used to store vertex/fragment shaders)
  8269. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8270. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8271. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8272. * @param samplers defines an array of string used to represent textures
  8273. * @param defines defines the string containing the defines to use to compile the shaders
  8274. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8275. * @param onCompiled defines a function to call when the effect creation is successful
  8276. * @param onError defines a function to call when the effect creation has failed
  8277. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8278. * @returns the new Effect
  8279. */
  8280. 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;
  8281. private _compileShader;
  8282. private _compileRawShader;
  8283. /**
  8284. * Directly creates a webGL program
  8285. * @param vertexCode defines the vertex shader code to use
  8286. * @param fragmentCode defines the fragment shader code to use
  8287. * @param context defines the webGL context to use (if not set, the current one will be used)
  8288. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8289. * @returns the new webGL program
  8290. */
  8291. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8292. /**
  8293. * Creates a webGL program
  8294. * @param vertexCode defines the vertex shader code to use
  8295. * @param fragmentCode defines the fragment shader code to use
  8296. * @param defines defines the string containing the defines to use to compile the shaders
  8297. * @param context defines the webGL context to use (if not set, the current one will be used)
  8298. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8299. * @returns the new webGL program
  8300. */
  8301. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8302. private _createShaderProgram;
  8303. /**
  8304. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8305. * @param shaderProgram defines the webGL program to use
  8306. * @param uniformsNames defines the list of uniform names
  8307. * @returns an array of webGL uniform locations
  8308. */
  8309. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8310. /**
  8311. * Gets the lsit of active attributes for a given webGL program
  8312. * @param shaderProgram defines the webGL program to use
  8313. * @param attributesNames defines the list of attribute names to get
  8314. * @returns an array of indices indicating the offset of each attribute
  8315. */
  8316. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8317. /**
  8318. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8319. * @param effect defines the effect to activate
  8320. */
  8321. enableEffect(effect: Nullable<Effect>): void;
  8322. /**
  8323. * Set the value of an uniform to an array of int32
  8324. * @param uniform defines the webGL uniform location where to store the value
  8325. * @param array defines the array of int32 to store
  8326. */
  8327. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8328. /**
  8329. * Set the value of an uniform to an array of int32 (stored as vec2)
  8330. * @param uniform defines the webGL uniform location where to store the value
  8331. * @param array defines the array of int32 to store
  8332. */
  8333. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8334. /**
  8335. * Set the value of an uniform to an array of int32 (stored as vec3)
  8336. * @param uniform defines the webGL uniform location where to store the value
  8337. * @param array defines the array of int32 to store
  8338. */
  8339. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8340. /**
  8341. * Set the value of an uniform to an array of int32 (stored as vec4)
  8342. * @param uniform defines the webGL uniform location where to store the value
  8343. * @param array defines the array of int32 to store
  8344. */
  8345. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8346. /**
  8347. * Set the value of an uniform to an array of float32
  8348. * @param uniform defines the webGL uniform location where to store the value
  8349. * @param array defines the array of float32 to store
  8350. */
  8351. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8352. /**
  8353. * Set the value of an uniform to an array of float32 (stored as vec2)
  8354. * @param uniform defines the webGL uniform location where to store the value
  8355. * @param array defines the array of float32 to store
  8356. */
  8357. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8358. /**
  8359. * Set the value of an uniform to an array of float32 (stored as vec3)
  8360. * @param uniform defines the webGL uniform location where to store the value
  8361. * @param array defines the array of float32 to store
  8362. */
  8363. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8364. /**
  8365. * Set the value of an uniform to an array of float32 (stored as vec4)
  8366. * @param uniform defines the webGL uniform location where to store the value
  8367. * @param array defines the array of float32 to store
  8368. */
  8369. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8370. /**
  8371. * Set the value of an uniform to an array of number
  8372. * @param uniform defines the webGL uniform location where to store the value
  8373. * @param array defines the array of number to store
  8374. */
  8375. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8376. /**
  8377. * Set the value of an uniform to an array of number (stored as vec2)
  8378. * @param uniform defines the webGL uniform location where to store the value
  8379. * @param array defines the array of number to store
  8380. */
  8381. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8382. /**
  8383. * Set the value of an uniform to an array of number (stored as vec3)
  8384. * @param uniform defines the webGL uniform location where to store the value
  8385. * @param array defines the array of number to store
  8386. */
  8387. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8388. /**
  8389. * Set the value of an uniform to an array of number (stored as vec4)
  8390. * @param uniform defines the webGL uniform location where to store the value
  8391. * @param array defines the array of number to store
  8392. */
  8393. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8394. /**
  8395. * Set the value of an uniform to an array of float32 (stored as matrices)
  8396. * @param uniform defines the webGL uniform location where to store the value
  8397. * @param matrices defines the array of float32 to store
  8398. */
  8399. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8400. /**
  8401. * Set the value of an uniform to a matrix
  8402. * @param uniform defines the webGL uniform location where to store the value
  8403. * @param matrix defines the matrix to store
  8404. */
  8405. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8406. /**
  8407. * Set the value of an uniform to a matrix (3x3)
  8408. * @param uniform defines the webGL uniform location where to store the value
  8409. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8410. */
  8411. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8412. /**
  8413. * Set the value of an uniform to a matrix (2x2)
  8414. * @param uniform defines the webGL uniform location where to store the value
  8415. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8416. */
  8417. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8418. /**
  8419. * Set the value of an uniform to a number (int)
  8420. * @param uniform defines the webGL uniform location where to store the value
  8421. * @param value defines the int number to store
  8422. */
  8423. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8424. /**
  8425. * Set the value of an uniform to a number (float)
  8426. * @param uniform defines the webGL uniform location where to store the value
  8427. * @param value defines the float number to store
  8428. */
  8429. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8430. /**
  8431. * Set the value of an uniform to a vec2
  8432. * @param uniform defines the webGL uniform location where to store the value
  8433. * @param x defines the 1st component of the value
  8434. * @param y defines the 2nd component of the value
  8435. */
  8436. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8437. /**
  8438. * Set the value of an uniform to a vec3
  8439. * @param uniform defines the webGL uniform location where to store the value
  8440. * @param x defines the 1st component of the value
  8441. * @param y defines the 2nd component of the value
  8442. * @param z defines the 3rd component of the value
  8443. */
  8444. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8445. /**
  8446. * Set the value of an uniform to a boolean
  8447. * @param uniform defines the webGL uniform location where to store the value
  8448. * @param bool defines the boolean to store
  8449. */
  8450. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8451. /**
  8452. * Set the value of an uniform to a vec4
  8453. * @param uniform defines the webGL uniform location where to store the value
  8454. * @param x defines the 1st component of the value
  8455. * @param y defines the 2nd component of the value
  8456. * @param z defines the 3rd component of the value
  8457. * @param w defines the 4th component of the value
  8458. */
  8459. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8460. /**
  8461. * Set the value of an uniform to a Color3
  8462. * @param uniform defines the webGL uniform location where to store the value
  8463. * @param color3 defines the color to store
  8464. */
  8465. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8466. /**
  8467. * Set the value of an uniform to a Color3 and an alpha value
  8468. * @param uniform defines the webGL uniform location where to store the value
  8469. * @param color3 defines the color to store
  8470. * @param alpha defines the alpha component to store
  8471. */
  8472. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8473. /**
  8474. * Sets a Color4 on a uniform variable
  8475. * @param uniform defines the uniform location
  8476. * @param color4 defines the value to be set
  8477. */
  8478. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8479. /**
  8480. * Set various states to the webGL context
  8481. * @param culling defines backface culling state
  8482. * @param zOffset defines the value to apply to zOffset (0 by default)
  8483. * @param force defines if states must be applied even if cache is up to date
  8484. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8485. */
  8486. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8487. /**
  8488. * Set the z offset to apply to current rendering
  8489. * @param value defines the offset to apply
  8490. */
  8491. setZOffset(value: number): void;
  8492. /**
  8493. * Gets the current value of the zOffset
  8494. * @returns the current zOffset state
  8495. */
  8496. getZOffset(): number;
  8497. /**
  8498. * Enable or disable depth buffering
  8499. * @param enable defines the state to set
  8500. */
  8501. setDepthBuffer(enable: boolean): void;
  8502. /**
  8503. * Gets a boolean indicating if depth writing is enabled
  8504. * @returns the current depth writing state
  8505. */
  8506. getDepthWrite(): boolean;
  8507. /**
  8508. * Enable or disable depth writing
  8509. * @param enable defines the state to set
  8510. */
  8511. setDepthWrite(enable: boolean): void;
  8512. /**
  8513. * Enable or disable color writing
  8514. * @param enable defines the state to set
  8515. */
  8516. setColorWrite(enable: boolean): void;
  8517. /**
  8518. * Gets a boolean indicating if color writing is enabled
  8519. * @returns the current color writing state
  8520. */
  8521. getColorWrite(): boolean;
  8522. /**
  8523. * Sets alpha constants used by some alpha blending modes
  8524. * @param r defines the red component
  8525. * @param g defines the green component
  8526. * @param b defines the blue component
  8527. * @param a defines the alpha component
  8528. */
  8529. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8530. /**
  8531. * Sets the current alpha mode
  8532. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8533. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8534. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8535. */
  8536. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8537. /**
  8538. * Gets the current alpha mode
  8539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8540. * @returns the current alpha mode
  8541. */
  8542. getAlphaMode(): number;
  8543. /**
  8544. * Clears the list of texture accessible through engine.
  8545. * This can help preventing texture load conflict due to name collision.
  8546. */
  8547. clearInternalTexturesCache(): void;
  8548. /**
  8549. * Force the entire cache to be cleared
  8550. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8551. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8552. */
  8553. wipeCaches(bruteForce?: boolean): void;
  8554. /**
  8555. * Set the compressed texture format to use, based on the formats you have, and the formats
  8556. * supported by the hardware / browser.
  8557. *
  8558. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8559. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8560. * to API arguments needed to compressed textures. This puts the burden on the container
  8561. * generator to house the arcane code for determining these for current & future formats.
  8562. *
  8563. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8564. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8565. *
  8566. * Note: The result of this call is not taken into account when a texture is base64.
  8567. *
  8568. * @param formatsAvailable defines the list of those format families you have created
  8569. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8570. *
  8571. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8572. * @returns The extension selected.
  8573. */
  8574. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8575. private _getSamplingParameters;
  8576. private _partialLoadImg;
  8577. private _cascadeLoadImgs;
  8578. /** @hidden */
  8579. /**
  8580. * Usually called from BABYLON.Texture.ts.
  8581. * Passed information to create a WebGLTexture
  8582. * @param urlArg defines a value which contains one of the following:
  8583. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8584. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8585. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8587. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8588. * @param scene needed for loading to the correct scene
  8589. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8590. * @param onLoad optional callback to be called upon successful completion
  8591. * @param onError optional callback to be called upon failure
  8592. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  8593. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8594. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8595. * @param forcedExtension defines the extension to use to pick the right loader
  8596. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8597. */
  8598. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  8599. private _rescaleTexture;
  8600. /**
  8601. * Update a raw texture
  8602. * @param texture defines the texture to update
  8603. * @param data defines the data to store in the texture
  8604. * @param format defines the format of the data
  8605. * @param invertY defines if data must be stored with Y axis inverted
  8606. * @param compression defines the compression used (null by default)
  8607. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8608. */
  8609. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8610. /**
  8611. * Creates a raw texture
  8612. * @param data defines the data to store in the texture
  8613. * @param width defines the width of the texture
  8614. * @param height defines the height of the texture
  8615. * @param format defines the format of the data
  8616. * @param generateMipMaps defines if the engine should generate the mip levels
  8617. * @param invertY defines if data must be stored with Y axis inverted
  8618. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8619. * @param compression defines the compression used (null by default)
  8620. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8621. * @returns the raw texture inside an InternalTexture
  8622. */
  8623. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8624. private _unpackFlipYCached;
  8625. /**
  8626. * In case you are sharing the context with other applications, it might
  8627. * be interested to not cache the unpack flip y state to ensure a consistent
  8628. * value would be set.
  8629. */
  8630. enableUnpackFlipYCached: boolean;
  8631. /** @hidden */
  8632. /** @hidden */
  8633. /**
  8634. * Creates a dynamic texture
  8635. * @param width defines the width of the texture
  8636. * @param height defines the height of the texture
  8637. * @param generateMipMaps defines if the engine should generate the mip levels
  8638. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8639. * @returns the dynamic texture inside an InternalTexture
  8640. */
  8641. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8642. /**
  8643. * Update the sampling mode of a given texture
  8644. * @param samplingMode defines the required sampling mode
  8645. * @param texture defines the texture to update
  8646. */
  8647. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8648. /**
  8649. * Update the content of a dynamic texture
  8650. * @param texture defines the texture to update
  8651. * @param canvas defines the canvas containing the source
  8652. * @param invertY defines if data must be stored with Y axis inverted
  8653. * @param premulAlpha defines if alpha is stored as premultiplied
  8654. * @param format defines the format of the data
  8655. */
  8656. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8657. /**
  8658. * Update a video texture
  8659. * @param texture defines the texture to update
  8660. * @param video defines the video element to use
  8661. * @param invertY defines if data must be stored with Y axis inverted
  8662. */
  8663. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8664. /**
  8665. * Updates a depth texture Comparison Mode and Function.
  8666. * If the comparison Function is equal to 0, the mode will be set to none.
  8667. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8668. * @param texture The texture to set the comparison function for
  8669. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8670. */
  8671. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8672. private _setupDepthStencilTexture;
  8673. /**
  8674. * Creates a depth stencil texture.
  8675. * This is only available in WebGL 2 or with the depth texture extension available.
  8676. * @param size The size of face edge in the texture.
  8677. * @param options The options defining the texture.
  8678. * @returns The texture
  8679. */
  8680. createDepthStencilTexture(size: number | {
  8681. width: number;
  8682. height: number;
  8683. }, options: DepthTextureCreationOptions): InternalTexture;
  8684. /**
  8685. * Creates a depth stencil texture.
  8686. * This is only available in WebGL 2 or with the depth texture extension available.
  8687. * @param size The size of face edge in the texture.
  8688. * @param options The options defining the texture.
  8689. * @returns The texture
  8690. */
  8691. private _createDepthStencilTexture;
  8692. /**
  8693. * Creates a depth stencil cube texture.
  8694. * This is only available in WebGL 2.
  8695. * @param size The size of face edge in the cube texture.
  8696. * @param options The options defining the cube texture.
  8697. * @returns The cube texture
  8698. */
  8699. private _createDepthStencilCubeTexture;
  8700. /**
  8701. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8702. * @param renderTarget The render target to set the frame buffer for
  8703. */
  8704. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8705. /**
  8706. * Creates a new render target texture
  8707. * @param size defines the size of the texture
  8708. * @param options defines the options used to create the texture
  8709. * @returns a new render target texture stored in an InternalTexture
  8710. */
  8711. createRenderTargetTexture(size: number | {
  8712. width: number;
  8713. height: number;
  8714. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8715. /**
  8716. * Create a multi render target texture
  8717. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8718. * @param size defines the size of the texture
  8719. * @param options defines the creation options
  8720. * @returns the cube texture as an InternalTexture
  8721. */
  8722. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8723. private _setupFramebufferDepthAttachments;
  8724. /**
  8725. * Updates the sample count of a render target texture
  8726. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8727. * @param texture defines the texture to update
  8728. * @param samples defines the sample count to set
  8729. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8730. */
  8731. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8732. /**
  8733. * Update the sample count for a given multiple render target texture
  8734. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8735. * @param textures defines the textures to update
  8736. * @param samples defines the sample count to set
  8737. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8738. */
  8739. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8740. /** @hidden */
  8741. /** @hidden */
  8742. /** @hidden */
  8743. /** @hidden */
  8744. /**
  8745. * Creates a new render target cube texture
  8746. * @param size defines the size of the texture
  8747. * @param options defines the options used to create the texture
  8748. * @returns a new render target cube texture stored in an InternalTexture
  8749. */
  8750. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8751. /**
  8752. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8753. * @param rootUrl defines the url where the file to load is located
  8754. * @param scene defines the current scene
  8755. * @param lodScale defines scale to apply to the mip map selection
  8756. * @param lodOffset defines offset to apply to the mip map selection
  8757. * @param onLoad defines an optional callback raised when the texture is loaded
  8758. * @param onError defines an optional callback raised if there is an issue to load the texture
  8759. * @param format defines the format of the data
  8760. * @param forcedExtension defines the extension to use to pick the right loader
  8761. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8762. * @returns the cube texture as an InternalTexture
  8763. */
  8764. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8765. /**
  8766. * Creates a cube texture
  8767. * @param rootUrl defines the url where the files to load is located
  8768. * @param scene defines the current scene
  8769. * @param files defines the list of files to load (1 per face)
  8770. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8771. * @param onLoad defines an optional callback raised when the texture is loaded
  8772. * @param onError defines an optional callback raised if there is an issue to load the texture
  8773. * @param format defines the format of the data
  8774. * @param forcedExtension defines the extension to use to pick the right loader
  8775. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8776. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8777. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8778. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8779. * @returns the cube texture as an InternalTexture
  8780. */
  8781. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  8782. /**
  8783. * @hidden
  8784. */
  8785. /**
  8786. * Update a raw cube texture
  8787. * @param texture defines the texture to udpdate
  8788. * @param data defines the data to store
  8789. * @param format defines the data format
  8790. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8791. * @param invertY defines if data must be stored with Y axis inverted
  8792. * @param compression defines the compression used (null by default)
  8793. * @param level defines which level of the texture to update
  8794. */
  8795. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8796. /**
  8797. * Creates a new raw cube texture
  8798. * @param data defines the array of data to use to create each face
  8799. * @param size defines the size of the textures
  8800. * @param format defines the format of the data
  8801. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8802. * @param generateMipMaps defines if the engine should generate the mip levels
  8803. * @param invertY defines if data must be stored with Y axis inverted
  8804. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8805. * @param compression defines the compression used (null by default)
  8806. * @returns the cube texture as an InternalTexture
  8807. */
  8808. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8809. /**
  8810. * Creates a new raw cube texture from a specified url
  8811. * @param url defines the url where the data is located
  8812. * @param scene defines the current scene
  8813. * @param size defines the size of the textures
  8814. * @param format defines the format of the data
  8815. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8816. * @param noMipmap defines if the engine should avoid generating the mip levels
  8817. * @param callback defines a callback used to extract texture data from loaded data
  8818. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8819. * @param onLoad defines a callback called when texture is loaded
  8820. * @param onError defines a callback called if there is an error
  8821. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8822. * @param invertY defines if data must be stored with Y axis inverted
  8823. * @returns the cube texture as an InternalTexture
  8824. */
  8825. 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;
  8826. /**
  8827. * Update a raw 3D texture
  8828. * @param texture defines the texture to update
  8829. * @param data defines the data to store
  8830. * @param format defines the data format
  8831. * @param invertY defines if data must be stored with Y axis inverted
  8832. * @param compression defines the used compression (can be null)
  8833. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8834. */
  8835. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8836. /**
  8837. * Creates a new raw 3D texture
  8838. * @param data defines the data used to create the texture
  8839. * @param width defines the width of the texture
  8840. * @param height defines the height of the texture
  8841. * @param depth defines the depth of the texture
  8842. * @param format defines the format of the texture
  8843. * @param generateMipMaps defines if the engine must generate mip levels
  8844. * @param invertY defines if data must be stored with Y axis inverted
  8845. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8846. * @param compression defines the compressed used (can be null)
  8847. * @param textureType defines the compressed used (can be null)
  8848. * @returns a new raw 3D texture (stored in an InternalTexture)
  8849. */
  8850. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8851. private _prepareWebGLTextureContinuation;
  8852. private _prepareWebGLTexture;
  8853. private _convertRGBtoRGBATextureData;
  8854. /** @hidden */
  8855. /** @hidden */
  8856. private setProgram;
  8857. private _boundUniforms;
  8858. /**
  8859. * Binds an effect to the webGL context
  8860. * @param effect defines the effect to bind
  8861. */
  8862. bindSamplers(effect: Effect): void;
  8863. private _moveBoundTextureOnTop;
  8864. private _getCorrectTextureChannel;
  8865. private _linkTrackers;
  8866. private _removeDesignatedSlot;
  8867. private _activateCurrentTexture;
  8868. /** @hidden */
  8869. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8870. /** @hidden */
  8871. /**
  8872. * Sets a texture to the webGL context from a postprocess
  8873. * @param channel defines the channel to use
  8874. * @param postProcess defines the source postprocess
  8875. */
  8876. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8877. /**
  8878. * Binds the output of the passed in post process to the texture channel specified
  8879. * @param channel The channel the texture should be bound to
  8880. * @param postProcess The post process which's output should be bound
  8881. */
  8882. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8883. /**
  8884. * Unbind all textures from the webGL context
  8885. */
  8886. unbindAllTextures(): void;
  8887. /**
  8888. * Sets a texture to the according uniform.
  8889. * @param channel The texture channel
  8890. * @param uniform The uniform to set
  8891. * @param texture The texture to apply
  8892. */
  8893. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8894. /**
  8895. * Sets a depth stencil texture from a render target to the according uniform.
  8896. * @param channel The texture channel
  8897. * @param uniform The uniform to set
  8898. * @param texture The render target texture containing the depth stencil texture to apply
  8899. */
  8900. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8901. private _bindSamplerUniformToChannel;
  8902. private _getTextureWrapMode;
  8903. private _setTexture;
  8904. /**
  8905. * Sets an array of texture to the webGL context
  8906. * @param channel defines the channel where the texture array must be set
  8907. * @param uniform defines the associated uniform location
  8908. * @param textures defines the array of textures to bind
  8909. */
  8910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8911. /** @hidden */
  8912. private _setTextureParameterFloat;
  8913. private _setTextureParameterInteger;
  8914. /**
  8915. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8916. * @param x defines the x coordinate of the rectangle where pixels must be read
  8917. * @param y defines the y coordinate of the rectangle where pixels must be read
  8918. * @param width defines the width of the rectangle where pixels must be read
  8919. * @param height defines the height of the rectangle where pixels must be read
  8920. * @returns a Uint8Array containing RGBA colors
  8921. */
  8922. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8923. /**
  8924. * Add an externaly attached data from its key.
  8925. * This method call will fail and return false, if such key already exists.
  8926. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8927. * @param key the unique key that identifies the data
  8928. * @param data the data object to associate to the key for this Engine instance
  8929. * @return true if no such key were already present and the data was added successfully, false otherwise
  8930. */
  8931. addExternalData<T>(key: string, data: T): boolean;
  8932. /**
  8933. * Get an externaly attached data from its key
  8934. * @param key the unique key that identifies the data
  8935. * @return the associated data, if present (can be null), or undefined if not present
  8936. */
  8937. getExternalData<T>(key: string): T;
  8938. /**
  8939. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8940. * @param key the unique key that identifies the data
  8941. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8942. * @return the associated data, can be null if the factory returned null.
  8943. */
  8944. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8945. /**
  8946. * Remove an externaly attached data from the Engine instance
  8947. * @param key the unique key that identifies the data
  8948. * @return true if the data was successfully removed, false if it doesn't exist
  8949. */
  8950. removeExternalData(key: string): boolean;
  8951. /**
  8952. * Unbind all vertex attributes from the webGL context
  8953. */
  8954. unbindAllAttributes(): void;
  8955. /**
  8956. * 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
  8957. */
  8958. releaseEffects(): void;
  8959. /**
  8960. * Dispose and release all associated resources
  8961. */
  8962. dispose(): void;
  8963. /**
  8964. * Display the loading screen
  8965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8966. */
  8967. displayLoadingUI(): void;
  8968. /**
  8969. * Hide the loading screen
  8970. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8971. */
  8972. hideLoadingUI(): void;
  8973. /**
  8974. * Gets the current loading screen object
  8975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8976. */
  8977. /**
  8978. * Sets the current loading screen object
  8979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8980. */
  8981. loadingScreen: ILoadingScreen;
  8982. /**
  8983. * Sets the current loading screen text
  8984. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8985. */
  8986. loadingUIText: string;
  8987. /**
  8988. * Sets the current loading screen background color
  8989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8990. */
  8991. loadingUIBackgroundColor: string;
  8992. /**
  8993. * Attach a new callback raised when context lost event is fired
  8994. * @param callback defines the callback to call
  8995. */
  8996. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8997. /**
  8998. * Attach a new callback raised when context restored event is fired
  8999. * @param callback defines the callback to call
  9000. */
  9001. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9002. /**
  9003. * Gets the source code of the vertex shader associated with a specific webGL program
  9004. * @param program defines the program to use
  9005. * @returns a string containing the source code of the vertex shader associated with the program
  9006. */
  9007. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9008. /**
  9009. * Gets the source code of the fragment shader associated with a specific webGL program
  9010. * @param program defines the program to use
  9011. * @returns a string containing the source code of the fragment shader associated with the program
  9012. */
  9013. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9014. /**
  9015. * Get the current error code of the webGL context
  9016. * @returns the error code
  9017. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9018. */
  9019. getError(): number;
  9020. /**
  9021. * Gets the current framerate
  9022. * @returns a number representing the framerate
  9023. */
  9024. getFps(): number;
  9025. /**
  9026. * Gets the time spent between current and previous frame
  9027. * @returns a number representing the delta time in ms
  9028. */
  9029. getDeltaTime(): number;
  9030. private _measureFps;
  9031. /** @hidden */
  9032. private _canRenderToFloatFramebuffer;
  9033. private _canRenderToHalfFloatFramebuffer;
  9034. private _canRenderToFramebuffer;
  9035. /** @hidden */
  9036. private _getInternalFormat;
  9037. /** @hidden */
  9038. /** @hidden */
  9039. /** @hidden */
  9040. /** @hidden */
  9041. private _partialLoadFile;
  9042. private _cascadeLoadFiles;
  9043. /**
  9044. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9045. * @returns true if the engine can be created
  9046. * @ignorenaming
  9047. */
  9048. static isSupported(): boolean;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. class NullEngineOptions {
  9053. renderWidth: number;
  9054. renderHeight: number;
  9055. textureSize: number;
  9056. deterministicLockstep: boolean;
  9057. lockstepMaxSteps: number;
  9058. }
  9059. /**
  9060. * The null engine class provides support for headless version of babylon.js.
  9061. * This can be used in server side scenario or for testing purposes
  9062. */
  9063. class NullEngine extends Engine {
  9064. private _options;
  9065. isDeterministicLockStep(): boolean;
  9066. getLockstepMaxSteps(): number;
  9067. getHardwareScalingLevel(): number;
  9068. constructor(options?: NullEngineOptions);
  9069. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9070. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9071. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9072. getRenderWidth(useScreen?: boolean): number;
  9073. getRenderHeight(useScreen?: boolean): number;
  9074. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9075. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9076. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9077. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9078. bindSamplers(effect: Effect): void;
  9079. enableEffect(effect: Effect): void;
  9080. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9081. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9082. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9083. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9084. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9085. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9086. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9087. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9088. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9089. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9090. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9091. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9092. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9093. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9094. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9095. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9096. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9097. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9098. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9099. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9100. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9101. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9102. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9103. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9104. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9105. bindBuffers(vertexBuffers: {
  9106. [key: string]: VertexBuffer;
  9107. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9108. wipeCaches(bruteForce?: boolean): void;
  9109. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9110. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9111. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9112. /** @hidden */
  9113. /** @hidden */
  9114. 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;
  9115. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9116. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9117. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9118. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9119. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9120. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9121. /**
  9122. * @hidden
  9123. * Get the current error code of the webGL context
  9124. * @returns the error code
  9125. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9126. */
  9127. getError(): number;
  9128. /** @hidden */
  9129. /** @hidden */
  9130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9131. /**
  9132. * Updates a dynamic vertex buffer.
  9133. * @param vertexBuffer the vertex buffer to update
  9134. * @param data the data used to update the vertex buffer
  9135. * @param byteOffset the byte offset of the data (optional)
  9136. * @param byteLength the byte length of the data (optional)
  9137. */
  9138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9139. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9140. /** @hidden */
  9141. /** @hidden */
  9142. releaseEffects(): void;
  9143. displayLoadingUI(): void;
  9144. hideLoadingUI(): void;
  9145. /** @hidden */
  9146. /** @hidden */
  9147. /** @hidden */
  9148. /** @hidden */
  9149. }
  9150. }
  9151. interface WebGLRenderingContext {
  9152. readonly RASTERIZER_DISCARD: number;
  9153. readonly DEPTH_COMPONENT24: number;
  9154. readonly TEXTURE_3D: number;
  9155. readonly TEXTURE_2D_ARRAY: number;
  9156. readonly TEXTURE_COMPARE_FUNC: number;
  9157. readonly TEXTURE_COMPARE_MODE: number;
  9158. readonly COMPARE_REF_TO_TEXTURE: number;
  9159. readonly TEXTURE_WRAP_R: number;
  9160. readonly HALF_FLOAT: number;
  9161. readonly RGB8: number;
  9162. readonly RED_INTEGER: number;
  9163. readonly RG_INTEGER: number;
  9164. readonly RGB_INTEGER: number;
  9165. readonly RGBA_INTEGER: number;
  9166. readonly R8_SNORM: number;
  9167. readonly RG8_SNORM: number;
  9168. readonly RGB8_SNORM: number;
  9169. readonly RGBA8_SNORM: number;
  9170. readonly R8I: number;
  9171. readonly RG8I: number;
  9172. readonly RGB8I: number;
  9173. readonly RGBA8I: number;
  9174. readonly R8UI: number;
  9175. readonly RG8UI: number;
  9176. readonly RGB8UI: number;
  9177. readonly RGBA8UI: number;
  9178. readonly R16I: number;
  9179. readonly RG16I: number;
  9180. readonly RGB16I: number;
  9181. readonly RGBA16I: number;
  9182. readonly R16UI: number;
  9183. readonly RG16UI: number;
  9184. readonly RGB16UI: number;
  9185. readonly RGBA16UI: number;
  9186. readonly R32I: number;
  9187. readonly RG32I: number;
  9188. readonly RGB32I: number;
  9189. readonly RGBA32I: number;
  9190. readonly R32UI: number;
  9191. readonly RG32UI: number;
  9192. readonly RGB32UI: number;
  9193. readonly RGBA32UI: number;
  9194. readonly RGB10_A2UI: number;
  9195. readonly R11F_G11F_B10F: number;
  9196. readonly RGB9_E5: number;
  9197. readonly RGB10_A2: number;
  9198. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9199. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9200. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9201. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9202. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9203. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9204. 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;
  9205. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9206. readonly TRANSFORM_FEEDBACK: number;
  9207. readonly INTERLEAVED_ATTRIBS: number;
  9208. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9209. createTransformFeedback(): WebGLTransformFeedback;
  9210. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9211. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9212. beginTransformFeedback(primitiveMode: number): void;
  9213. endTransformFeedback(): void;
  9214. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9215. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9216. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9217. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9218. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9219. }
  9220. interface ImageBitmap {
  9221. readonly width: number;
  9222. readonly height: number;
  9223. close(): void;
  9224. }
  9225. interface WebGLQuery extends WebGLObject {
  9226. }
  9227. declare var WebGLQuery: {
  9228. prototype: WebGLQuery;
  9229. new (): WebGLQuery;
  9230. };
  9231. interface WebGLSampler extends WebGLObject {
  9232. }
  9233. declare var WebGLSampler: {
  9234. prototype: WebGLSampler;
  9235. new (): WebGLSampler;
  9236. };
  9237. interface WebGLSync extends WebGLObject {
  9238. }
  9239. declare var WebGLSync: {
  9240. prototype: WebGLSync;
  9241. new (): WebGLSync;
  9242. };
  9243. interface WebGLTransformFeedback extends WebGLObject {
  9244. }
  9245. declare var WebGLTransformFeedback: {
  9246. prototype: WebGLTransformFeedback;
  9247. new (): WebGLTransformFeedback;
  9248. };
  9249. interface WebGLVertexArrayObject extends WebGLObject {
  9250. }
  9251. declare var WebGLVertexArrayObject: {
  9252. prototype: WebGLVertexArrayObject;
  9253. new (): WebGLVertexArrayObject;
  9254. };
  9255. declare module BABYLON {
  9256. class KeyboardEventTypes {
  9257. private static _KEYDOWN: number;
  9258. private static _KEYUP: number;
  9259. static readonly KEYDOWN: number;
  9260. static readonly KEYUP: number;
  9261. }
  9262. class KeyboardInfo {
  9263. type: number;
  9264. event: KeyboardEvent;
  9265. constructor(type: number, event: KeyboardEvent);
  9266. }
  9267. /**
  9268. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9269. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9270. */
  9271. class KeyboardInfoPre extends KeyboardInfo {
  9272. constructor(type: number, event: KeyboardEvent);
  9273. skipOnPointerObservable: boolean;
  9274. }
  9275. }
  9276. declare module BABYLON {
  9277. class PointerEventTypes {
  9278. private static _POINTERDOWN: number;
  9279. private static _POINTERUP: number;
  9280. private static _POINTERMOVE: number;
  9281. private static _POINTERWHEEL: number;
  9282. private static _POINTERPICK: number;
  9283. private static _POINTERTAP: number;
  9284. private static _POINTERDOUBLETAP: number;
  9285. static readonly POINTERDOWN: number;
  9286. static readonly POINTERUP: number;
  9287. static readonly POINTERMOVE: number;
  9288. static readonly POINTERWHEEL: number;
  9289. static readonly POINTERPICK: number;
  9290. static readonly POINTERTAP: number;
  9291. static readonly POINTERDOUBLETAP: number;
  9292. }
  9293. class PointerInfoBase {
  9294. type: number;
  9295. event: PointerEvent | MouseWheelEvent;
  9296. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9297. }
  9298. /**
  9299. * This class is used to store pointer related info for the onPrePointerObservable event.
  9300. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9301. */
  9302. class PointerInfoPre extends PointerInfoBase {
  9303. /**
  9304. * Ray from a pointer if availible (eg. 6dof controller)
  9305. */
  9306. ray: Nullable<Ray>;
  9307. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9308. localPosition: Vector2;
  9309. skipOnPointerObservable: boolean;
  9310. }
  9311. /**
  9312. * This type contains all the data related to a pointer event in Babylon.js.
  9313. * 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.
  9314. */
  9315. class PointerInfo extends PointerInfoBase {
  9316. pickInfo: Nullable<PickingInfo>;
  9317. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9318. }
  9319. }
  9320. declare module BABYLON {
  9321. class StickValues {
  9322. x: number;
  9323. y: number;
  9324. constructor(x: number, y: number);
  9325. }
  9326. interface GamepadButtonChanges {
  9327. changed: boolean;
  9328. pressChanged: boolean;
  9329. touchChanged: boolean;
  9330. valueChanged: boolean;
  9331. }
  9332. class Gamepad {
  9333. id: string;
  9334. index: number;
  9335. browserGamepad: any;
  9336. type: number;
  9337. private _leftStick;
  9338. private _rightStick;
  9339. /** @hidden */
  9340. private _leftStickAxisX;
  9341. private _leftStickAxisY;
  9342. private _rightStickAxisX;
  9343. private _rightStickAxisY;
  9344. private _onleftstickchanged;
  9345. private _onrightstickchanged;
  9346. static GAMEPAD: number;
  9347. static GENERIC: number;
  9348. static XBOX: number;
  9349. static POSE_ENABLED: number;
  9350. protected _invertLeftStickY: boolean;
  9351. readonly isConnected: boolean;
  9352. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9353. onleftstickchanged(callback: (values: StickValues) => void): void;
  9354. onrightstickchanged(callback: (values: StickValues) => void): void;
  9355. leftStick: StickValues;
  9356. rightStick: StickValues;
  9357. update(): void;
  9358. dispose(): void;
  9359. }
  9360. class GenericPad extends Gamepad {
  9361. private _buttons;
  9362. private _onbuttondown;
  9363. private _onbuttonup;
  9364. onButtonDownObservable: Observable<number>;
  9365. onButtonUpObservable: Observable<number>;
  9366. onbuttondown(callback: (buttonPressed: number) => void): void;
  9367. onbuttonup(callback: (buttonReleased: number) => void): void;
  9368. constructor(id: string, index: number, browserGamepad: any);
  9369. private _setButtonValue;
  9370. update(): void;
  9371. dispose(): void;
  9372. }
  9373. }
  9374. declare module BABYLON {
  9375. class GamepadManager {
  9376. private _scene?;
  9377. private _babylonGamepads;
  9378. private _oneGamepadConnected;
  9379. /** @hidden */
  9380. private _gamepadEventSupported;
  9381. private _gamepadSupport;
  9382. onGamepadConnectedObservable: Observable<Gamepad>;
  9383. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9384. private _onGamepadConnectedEvent;
  9385. private _onGamepadDisconnectedEvent;
  9386. constructor(_scene?: Scene | undefined);
  9387. readonly gamepads: Gamepad[];
  9388. getGamepadByType(type?: number): Nullable<Gamepad>;
  9389. dispose(): void;
  9390. private _addNewGamepad;
  9391. private _startMonitoringGamepads;
  9392. private _stopMonitoringGamepads;
  9393. /** @hidden */
  9394. private _updateGamepadObjects;
  9395. }
  9396. }
  9397. declare module BABYLON {
  9398. interface Scene {
  9399. /** @hidden */
  9400. /**
  9401. * Gets the gamepad manager associated with the scene
  9402. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9403. */
  9404. gamepadManager: GamepadManager;
  9405. }
  9406. interface FreeCameraInputsManager {
  9407. addGamepad(): FreeCameraInputsManager;
  9408. }
  9409. interface ArcRotateCameraInputsManager {
  9410. addGamepad(): ArcRotateCameraInputsManager;
  9411. }
  9412. /**
  9413. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9414. */
  9415. class GamepadSystemSceneComponent implements ISceneComponent {
  9416. /**
  9417. * The component name helpfull to identify the component in the list of scene components.
  9418. */
  9419. readonly name: string;
  9420. /**
  9421. * The scene the component belongs to.
  9422. */
  9423. scene: Scene;
  9424. /**
  9425. * Creates a new instance of the component for the given scene
  9426. * @param scene Defines the scene to register the component in
  9427. */
  9428. constructor(scene: Scene);
  9429. /**
  9430. * Registers the component in a given scene
  9431. */
  9432. register(): void;
  9433. /**
  9434. * Rebuilds the elements related to this component in case of
  9435. * context lost for instance.
  9436. */
  9437. rebuild(): void;
  9438. /**
  9439. * Disposes the component and the associated ressources
  9440. */
  9441. dispose(): void;
  9442. private _beforeCameraUpdate;
  9443. }
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Defines supported buttons for XBox360 compatible gamepads
  9448. */
  9449. enum Xbox360Button {
  9450. /** A */
  9451. A = 0,
  9452. /** B */
  9453. B = 1,
  9454. /** X */
  9455. X = 2,
  9456. /** Y */
  9457. Y = 3,
  9458. /** Start */
  9459. Start = 4,
  9460. /** Back */
  9461. Back = 5,
  9462. /** Left button */
  9463. LB = 6,
  9464. /** Right button */
  9465. RB = 7,
  9466. /** Left stick */
  9467. LeftStick = 8,
  9468. /** Right stick */
  9469. RightStick = 9
  9470. }
  9471. /** Defines values for XBox360 DPad */
  9472. enum Xbox360Dpad {
  9473. /** Up */
  9474. Up = 0,
  9475. /** Down */
  9476. Down = 1,
  9477. /** Left */
  9478. Left = 2,
  9479. /** Right */
  9480. Right = 3
  9481. }
  9482. /**
  9483. * Defines a XBox360 gamepad
  9484. */
  9485. class Xbox360Pad extends Gamepad {
  9486. private _leftTrigger;
  9487. private _rightTrigger;
  9488. private _onlefttriggerchanged;
  9489. private _onrighttriggerchanged;
  9490. private _onbuttondown;
  9491. private _onbuttonup;
  9492. private _ondpaddown;
  9493. private _ondpadup;
  9494. /** Observable raised when a button is pressed */
  9495. onButtonDownObservable: Observable<Xbox360Button>;
  9496. /** Observable raised when a button is released */
  9497. onButtonUpObservable: Observable<Xbox360Button>;
  9498. /** Observable raised when a pad is pressed */
  9499. onPadDownObservable: Observable<Xbox360Dpad>;
  9500. /** Observable raised when a pad is released */
  9501. onPadUpObservable: Observable<Xbox360Dpad>;
  9502. private _buttonA;
  9503. private _buttonB;
  9504. private _buttonX;
  9505. private _buttonY;
  9506. private _buttonBack;
  9507. private _buttonStart;
  9508. private _buttonLB;
  9509. private _buttonRB;
  9510. private _buttonLeftStick;
  9511. private _buttonRightStick;
  9512. private _dPadUp;
  9513. private _dPadDown;
  9514. private _dPadLeft;
  9515. private _dPadRight;
  9516. private _isXboxOnePad;
  9517. /**
  9518. * Creates a new XBox360 gamepad object
  9519. * @param id defines the id of this gamepad
  9520. * @param index defines its index
  9521. * @param gamepad defines the internal HTML gamepad object
  9522. * @param xboxOne defines if it is a XBox One gamepad
  9523. */
  9524. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9525. /**
  9526. * Defines the callback to call when left trigger is pressed
  9527. * @param callback defines the callback to use
  9528. */
  9529. onlefttriggerchanged(callback: (value: number) => void): void;
  9530. /**
  9531. * Defines the callback to call when right trigger is pressed
  9532. * @param callback defines the callback to use
  9533. */
  9534. onrighttriggerchanged(callback: (value: number) => void): void;
  9535. /**
  9536. * Gets or sets left trigger value
  9537. */
  9538. leftTrigger: number;
  9539. /**
  9540. * Gets or sets right trigger value
  9541. */
  9542. rightTrigger: number;
  9543. /**
  9544. * Defines the callback to call when a button is pressed
  9545. * @param callback defines the callback to use
  9546. */
  9547. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9548. /**
  9549. * Defines the callback to call when a button is released
  9550. * @param callback defines the callback to use
  9551. */
  9552. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9553. /**
  9554. * Defines the callback to call when a pad is pressed
  9555. * @param callback defines the callback to use
  9556. */
  9557. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9558. /**
  9559. * Defines the callback to call when a pad is released
  9560. * @param callback defines the callback to use
  9561. */
  9562. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9563. private _setButtonValue;
  9564. private _setDPadValue;
  9565. /** Gets or sets value of A button */
  9566. buttonA: number;
  9567. /** Gets or sets value of B button */
  9568. buttonB: number;
  9569. /** Gets or sets value of X button */
  9570. buttonX: number;
  9571. /** Gets or sets value of Y button */
  9572. buttonY: number;
  9573. /** Gets or sets value of Start button */
  9574. buttonStart: number;
  9575. /** Gets or sets value of Back button */
  9576. buttonBack: number;
  9577. /** Gets or sets value of Left button */
  9578. buttonLB: number;
  9579. /** Gets or sets value of Right button */
  9580. buttonRB: number;
  9581. /** Gets or sets value of left stick */
  9582. buttonLeftStick: number;
  9583. /** Gets or sets value of right stick */
  9584. buttonRightStick: number;
  9585. /** Gets or sets value of DPad up */
  9586. dPadUp: number;
  9587. /** Gets or sets value of DPad down */
  9588. dPadDown: number;
  9589. /** Gets or sets value of DPad left */
  9590. dPadLeft: number;
  9591. /** Gets or sets value of DPad right */
  9592. dPadRight: number;
  9593. /**
  9594. * Force the gamepad to synchronize with device values
  9595. */
  9596. update(): void;
  9597. dispose(): void;
  9598. }
  9599. }
  9600. declare module BABYLON {
  9601. /**
  9602. * Single axis drag gizmo
  9603. */
  9604. class AxisDragGizmo extends Gizmo {
  9605. /**
  9606. * Drag behavior responsible for the gizmos dragging interactions
  9607. */
  9608. dragBehavior: PointerDragBehavior;
  9609. private _pointerObserver;
  9610. /**
  9611. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9612. */
  9613. snapDistance: number;
  9614. /**
  9615. * Event that fires each time the gizmo snaps to a new location.
  9616. * * snapDistance is the the change in distance
  9617. */
  9618. onSnapObservable: Observable<{
  9619. snapDistance: number;
  9620. }>;
  9621. /**
  9622. * Creates an AxisDragGizmo
  9623. * @param gizmoLayer The utility layer the gizmo will be added to
  9624. * @param dragAxis The axis which the gizmo will be able to drag on
  9625. * @param color The color of the gizmo
  9626. */
  9627. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9628. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9629. /**
  9630. * Disposes of the gizmo
  9631. */
  9632. dispose(): void;
  9633. }
  9634. }
  9635. declare module BABYLON {
  9636. /**
  9637. * Single axis scale gizmo
  9638. */
  9639. class AxisScaleGizmo extends Gizmo {
  9640. private _coloredMaterial;
  9641. /**
  9642. * Drag behavior responsible for the gizmos dragging interactions
  9643. */
  9644. dragBehavior: PointerDragBehavior;
  9645. private _pointerObserver;
  9646. /**
  9647. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9648. */
  9649. snapDistance: number;
  9650. /**
  9651. * Event that fires each time the gizmo snaps to a new location.
  9652. * * snapDistance is the the change in distance
  9653. */
  9654. onSnapObservable: Observable<{
  9655. snapDistance: number;
  9656. }>;
  9657. /**
  9658. * If the scaling operation should be done on all axis (default: false)
  9659. */
  9660. uniformScaling: boolean;
  9661. /**
  9662. * Creates an AxisScaleGizmo
  9663. * @param gizmoLayer The utility layer the gizmo will be added to
  9664. * @param dragAxis The axis which the gizmo will be able to scale on
  9665. * @param color The color of the gizmo
  9666. */
  9667. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9668. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9669. /**
  9670. * Disposes of the gizmo
  9671. */
  9672. dispose(): void;
  9673. /**
  9674. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9675. * @param mesh The mesh to replace the default mesh of the gizmo
  9676. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9677. */
  9678. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9679. }
  9680. }
  9681. declare module BABYLON {
  9682. /**
  9683. * Bounding box gizmo
  9684. */
  9685. class BoundingBoxGizmo extends Gizmo {
  9686. private _lineBoundingBox;
  9687. private _rotateSpheresParent;
  9688. private _scaleBoxesParent;
  9689. private _boundingDimensions;
  9690. private _renderObserver;
  9691. private _pointerObserver;
  9692. private _scaleDragSpeed;
  9693. private _tmpQuaternion;
  9694. private _tmpVector;
  9695. private _tmpRotationMatrix;
  9696. /**
  9697. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  9698. */
  9699. ignoreChildren: boolean;
  9700. /**
  9701. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  9702. */
  9703. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  9704. /**
  9705. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9706. */
  9707. rotationSphereSize: number;
  9708. /**
  9709. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9710. */
  9711. scaleBoxSize: number;
  9712. /**
  9713. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  9714. */
  9715. fixedDragMeshScreenSize: boolean;
  9716. /**
  9717. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9718. */
  9719. fixedDragMeshScreenSizeDistanceFactor: number;
  9720. /**
  9721. * Fired when a rotation sphere or scale box is dragged
  9722. */
  9723. onDragStartObservable: Observable<{}>;
  9724. /**
  9725. * Fired when a scale box is dragged
  9726. */
  9727. onScaleBoxDragObservable: Observable<{}>;
  9728. /**
  9729. * Fired when a scale box drag is ended
  9730. */
  9731. onScaleBoxDragEndObservable: Observable<{}>;
  9732. /**
  9733. * Fired when a rotation sphere is dragged
  9734. */
  9735. onRotationSphereDragObservable: Observable<{}>;
  9736. /**
  9737. * Fired when a rotation sphere drag is ended
  9738. */
  9739. onRotationSphereDragEndObservable: Observable<{}>;
  9740. /**
  9741. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  9742. */
  9743. scalePivot: Nullable<Vector3>;
  9744. private _anchorMesh;
  9745. private _existingMeshScale;
  9746. private static _PivotCached;
  9747. private static _OldPivotPoint;
  9748. private static _PivotTranslation;
  9749. private static _PivotTmpVector;
  9750. /** @hidden */
  9751. private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  9752. /** @hidden */
  9753. private static _RestorePivotPoint(mesh: AbstractMesh): void;
  9754. /**
  9755. * Creates an BoundingBoxGizmo
  9756. * @param gizmoLayer The utility layer the gizmo will be added to
  9757. * @param color The color of the gizmo
  9758. */
  9759. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9760. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9761. private _selectNode;
  9762. /**
  9763. * Updates the bounding box information for the Gizmo
  9764. */
  9765. updateBoundingBox(): void;
  9766. /**
  9767. * Enables rotation on the specified axis and disables rotation on the others
  9768. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9769. */
  9770. setEnabledRotationAxis(axis: string): void;
  9771. /**
  9772. * Disposes of the gizmo
  9773. */
  9774. dispose(): void;
  9775. /**
  9776. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  9777. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  9778. * @returns the bounding box mesh with the passed in mesh as a child
  9779. */
  9780. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  9781. /**
  9782. * CustomMeshes are not supported by this gizmo
  9783. * @param mesh The mesh to replace the default mesh of the gizmo
  9784. */
  9785. setCustomMesh(mesh: Mesh): void;
  9786. }
  9787. }
  9788. declare module BABYLON {
  9789. /**
  9790. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9791. */
  9792. class Gizmo implements IDisposable {
  9793. /** The utility layer the gizmo will be added to */
  9794. gizmoLayer: UtilityLayerRenderer;
  9795. /**
  9796. * The root mesh of the gizmo
  9797. */
  9798. protected _rootMesh: Mesh;
  9799. private _attachedMesh;
  9800. /**
  9801. * Ratio for the scale of the gizmo (Default: 1)
  9802. */
  9803. scaleRatio: number;
  9804. private _tmpMatrix;
  9805. /**
  9806. * If a custom mesh has been set (Default: false)
  9807. */
  9808. protected _customMeshSet: boolean;
  9809. /**
  9810. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9811. * * When set, interactions will be enabled
  9812. */
  9813. attachedMesh: Nullable<AbstractMesh>;
  9814. /**
  9815. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9816. * @param mesh The mesh to replace the default mesh of the gizmo
  9817. */
  9818. setCustomMesh(mesh: Mesh): void;
  9819. /**
  9820. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9821. */
  9822. updateGizmoRotationToMatchAttachedMesh: boolean;
  9823. /**
  9824. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9825. */
  9826. updateGizmoPositionToMatchAttachedMesh: boolean;
  9827. /**
  9828. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9829. */
  9830. protected _updateScale: boolean;
  9831. protected _interactionsEnabled: boolean;
  9832. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9833. private _beforeRenderObserver;
  9834. /**
  9835. * Creates a gizmo
  9836. * @param gizmoLayer The utility layer the gizmo will be added to
  9837. */
  9838. constructor(
  9839. /** The utility layer the gizmo will be added to */
  9840. gizmoLayer?: UtilityLayerRenderer);
  9841. private _tempVector;
  9842. /**
  9843. * @hidden
  9844. * Updates the gizmo to match the attached mesh's position/rotation
  9845. */
  9846. protected _update(): void;
  9847. /**
  9848. * Disposes of the gizmo
  9849. */
  9850. dispose(): void;
  9851. }
  9852. }
  9853. declare module BABYLON {
  9854. /**
  9855. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9856. */
  9857. class GizmoManager implements IDisposable {
  9858. private scene;
  9859. /**
  9860. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  9861. */
  9862. gizmos: {
  9863. positionGizmo: Nullable<PositionGizmo>;
  9864. rotationGizmo: Nullable<RotationGizmo>;
  9865. scaleGizmo: Nullable<ScaleGizmo>;
  9866. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  9867. };
  9868. private _gizmosEnabled;
  9869. private _pointerObserver;
  9870. private _attachedMesh;
  9871. private _boundingBoxColor;
  9872. private _dragBehavior;
  9873. /**
  9874. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  9875. */
  9876. attachableMeshes: Nullable<Array<AbstractMesh>>;
  9877. /**
  9878. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  9879. */
  9880. usePointerToAttachGizmos: boolean;
  9881. /**
  9882. * Instatiates a gizmo manager
  9883. * @param scene the scene to overlay the gizmos on top of
  9884. */
  9885. constructor(scene: Scene);
  9886. /**
  9887. * Attaches a set of gizmos to the specified mesh
  9888. * @param mesh The mesh the gizmo's should be attached to
  9889. */
  9890. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  9891. /**
  9892. * If the position gizmo is enabled
  9893. */
  9894. positionGizmoEnabled: boolean;
  9895. /**
  9896. * If the rotation gizmo is enabled
  9897. */
  9898. rotationGizmoEnabled: boolean;
  9899. /**
  9900. * If the scale gizmo is enabled
  9901. */
  9902. scaleGizmoEnabled: boolean;
  9903. /**
  9904. * If the boundingBox gizmo is enabled
  9905. */
  9906. boundingBoxGizmoEnabled: boolean;
  9907. /**
  9908. * Disposes of the gizmo manager
  9909. */
  9910. dispose(): void;
  9911. }
  9912. }
  9913. declare module BABYLON {
  9914. /**
  9915. * Single plane rotation gizmo
  9916. */
  9917. class PlaneRotationGizmo extends Gizmo {
  9918. /**
  9919. * Drag behavior responsible for the gizmos dragging interactions
  9920. */
  9921. dragBehavior: PointerDragBehavior;
  9922. private _pointerObserver;
  9923. /**
  9924. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  9925. */
  9926. snapDistance: number;
  9927. /**
  9928. * Event that fires each time the gizmo snaps to a new location.
  9929. * * snapDistance is the the change in distance
  9930. */
  9931. onSnapObservable: Observable<{
  9932. snapDistance: number;
  9933. }>;
  9934. /**
  9935. * Creates a PlaneRotationGizmo
  9936. * @param gizmoLayer The utility layer the gizmo will be added to
  9937. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9938. * @param color The color of the gizmo
  9939. */
  9940. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9942. /**
  9943. * Disposes of the gizmo
  9944. */
  9945. dispose(): void;
  9946. }
  9947. }
  9948. declare module BABYLON {
  9949. /**
  9950. * Gizmo that enables dragging a mesh along 3 axis
  9951. */
  9952. class PositionGizmo extends Gizmo {
  9953. /**
  9954. * Internal gizmo used for interactions on the x axis
  9955. */
  9956. xGizmo: AxisDragGizmo;
  9957. /**
  9958. * Internal gizmo used for interactions on the y axis
  9959. */
  9960. yGizmo: AxisDragGizmo;
  9961. /**
  9962. * Internal gizmo used for interactions on the z axis
  9963. */
  9964. zGizmo: AxisDragGizmo;
  9965. attachedMesh: Nullable<AbstractMesh>;
  9966. /**
  9967. * Creates a PositionGizmo
  9968. * @param gizmoLayer The utility layer the gizmo will be added to
  9969. */
  9970. constructor(gizmoLayer?: UtilityLayerRenderer);
  9971. updateGizmoRotationToMatchAttachedMesh: boolean;
  9972. /**
  9973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9974. */
  9975. snapDistance: number;
  9976. /**
  9977. * Ratio for the scale of the gizmo (Default: 1)
  9978. */
  9979. scaleRatio: number;
  9980. /**
  9981. * Disposes of the gizmo
  9982. */
  9983. dispose(): void;
  9984. /**
  9985. * CustomMeshes are not supported by this gizmo
  9986. * @param mesh The mesh to replace the default mesh of the gizmo
  9987. */
  9988. setCustomMesh(mesh: Mesh): void;
  9989. }
  9990. }
  9991. declare module BABYLON {
  9992. /**
  9993. * Gizmo that enables rotating a mesh along 3 axis
  9994. */
  9995. class RotationGizmo extends Gizmo {
  9996. /**
  9997. * Internal gizmo used for interactions on the x axis
  9998. */
  9999. xGizmo: PlaneRotationGizmo;
  10000. /**
  10001. * Internal gizmo used for interactions on the y axis
  10002. */
  10003. yGizmo: PlaneRotationGizmo;
  10004. /**
  10005. * Internal gizmo used for interactions on the z axis
  10006. */
  10007. zGizmo: PlaneRotationGizmo;
  10008. attachedMesh: Nullable<AbstractMesh>;
  10009. /**
  10010. * Creates a RotationGizmo
  10011. * @param gizmoLayer The utility layer the gizmo will be added to
  10012. */
  10013. constructor(gizmoLayer?: UtilityLayerRenderer);
  10014. updateGizmoRotationToMatchAttachedMesh: boolean;
  10015. /**
  10016. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10017. */
  10018. snapDistance: number;
  10019. /**
  10020. * Ratio for the scale of the gizmo (Default: 1)
  10021. */
  10022. scaleRatio: number;
  10023. /**
  10024. * Disposes of the gizmo
  10025. */
  10026. dispose(): void;
  10027. /**
  10028. * CustomMeshes are not supported by this gizmo
  10029. * @param mesh The mesh to replace the default mesh of the gizmo
  10030. */
  10031. setCustomMesh(mesh: Mesh): void;
  10032. }
  10033. }
  10034. declare module BABYLON {
  10035. /**
  10036. * Gizmo that enables scaling a mesh along 3 axis
  10037. */
  10038. class ScaleGizmo extends Gizmo {
  10039. /**
  10040. * Internal gizmo used for interactions on the x axis
  10041. */
  10042. xGizmo: AxisScaleGizmo;
  10043. /**
  10044. * Internal gizmo used for interactions on the y axis
  10045. */
  10046. yGizmo: AxisScaleGizmo;
  10047. /**
  10048. * Internal gizmo used for interactions on the z axis
  10049. */
  10050. zGizmo: AxisScaleGizmo;
  10051. /**
  10052. * @hidden
  10053. * Internal gizmo used to scale all axis equally
  10054. */
  10055. private _uniformGizmo;
  10056. attachedMesh: Nullable<AbstractMesh>;
  10057. /**
  10058. * Creates a ScaleGizmo
  10059. * @param gizmoLayer The utility layer the gizmo will be added to
  10060. */
  10061. constructor(gizmoLayer?: UtilityLayerRenderer);
  10062. updateGizmoRotationToMatchAttachedMesh: boolean;
  10063. /**
  10064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10065. */
  10066. snapDistance: number;
  10067. /**
  10068. * Ratio for the scale of the gizmo (Default: 1)
  10069. */
  10070. scaleRatio: number;
  10071. /**
  10072. * Disposes of the gizmo
  10073. */
  10074. dispose(): void;
  10075. }
  10076. }
  10077. declare module BABYLON {
  10078. /**
  10079. * Represents the different options available during the creation of
  10080. * a Environment helper.
  10081. *
  10082. * This can control the default ground, skybox and image processing setup of your scene.
  10083. */
  10084. interface IEnvironmentHelperOptions {
  10085. /**
  10086. * Specifies wether or not to create a ground.
  10087. * True by default.
  10088. */
  10089. createGround: boolean;
  10090. /**
  10091. * Specifies the ground size.
  10092. * 15 by default.
  10093. */
  10094. groundSize: number;
  10095. /**
  10096. * The texture used on the ground for the main color.
  10097. * Comes from the BabylonJS CDN by default.
  10098. *
  10099. * Remarks: Can be either a texture or a url.
  10100. */
  10101. groundTexture: string | BaseTexture;
  10102. /**
  10103. * The color mixed in the ground texture by default.
  10104. * BabylonJS clearColor by default.
  10105. */
  10106. groundColor: Color3;
  10107. /**
  10108. * Specifies the ground opacity.
  10109. * 1 by default.
  10110. */
  10111. groundOpacity: number;
  10112. /**
  10113. * Enables the ground to receive shadows.
  10114. * True by default.
  10115. */
  10116. enableGroundShadow: boolean;
  10117. /**
  10118. * Helps preventing the shadow to be fully black on the ground.
  10119. * 0.5 by default.
  10120. */
  10121. groundShadowLevel: number;
  10122. /**
  10123. * Creates a mirror texture attach to the ground.
  10124. * false by default.
  10125. */
  10126. enableGroundMirror: boolean;
  10127. /**
  10128. * Specifies the ground mirror size ratio.
  10129. * 0.3 by default as the default kernel is 64.
  10130. */
  10131. groundMirrorSizeRatio: number;
  10132. /**
  10133. * Specifies the ground mirror blur kernel size.
  10134. * 64 by default.
  10135. */
  10136. groundMirrorBlurKernel: number;
  10137. /**
  10138. * Specifies the ground mirror visibility amount.
  10139. * 1 by default
  10140. */
  10141. groundMirrorAmount: number;
  10142. /**
  10143. * Specifies the ground mirror reflectance weight.
  10144. * This uses the standard weight of the background material to setup the fresnel effect
  10145. * of the mirror.
  10146. * 1 by default.
  10147. */
  10148. groundMirrorFresnelWeight: number;
  10149. /**
  10150. * Specifies the ground mirror Falloff distance.
  10151. * This can helps reducing the size of the reflection.
  10152. * 0 by Default.
  10153. */
  10154. groundMirrorFallOffDistance: number;
  10155. /**
  10156. * Specifies the ground mirror texture type.
  10157. * Unsigned Int by Default.
  10158. */
  10159. groundMirrorTextureType: number;
  10160. /**
  10161. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10162. * the shown objects.
  10163. */
  10164. groundYBias: number;
  10165. /**
  10166. * Specifies wether or not to create a skybox.
  10167. * True by default.
  10168. */
  10169. createSkybox: boolean;
  10170. /**
  10171. * Specifies the skybox size.
  10172. * 20 by default.
  10173. */
  10174. skyboxSize: number;
  10175. /**
  10176. * The texture used on the skybox for the main color.
  10177. * Comes from the BabylonJS CDN by default.
  10178. *
  10179. * Remarks: Can be either a texture or a url.
  10180. */
  10181. skyboxTexture: string | BaseTexture;
  10182. /**
  10183. * The color mixed in the skybox texture by default.
  10184. * BabylonJS clearColor by default.
  10185. */
  10186. skyboxColor: Color3;
  10187. /**
  10188. * The background rotation around the Y axis of the scene.
  10189. * This helps aligning the key lights of your scene with the background.
  10190. * 0 by default.
  10191. */
  10192. backgroundYRotation: number;
  10193. /**
  10194. * Compute automatically the size of the elements to best fit with the scene.
  10195. */
  10196. sizeAuto: boolean;
  10197. /**
  10198. * Default position of the rootMesh if autoSize is not true.
  10199. */
  10200. rootPosition: Vector3;
  10201. /**
  10202. * Sets up the image processing in the scene.
  10203. * true by default.
  10204. */
  10205. setupImageProcessing: boolean;
  10206. /**
  10207. * The texture used as your environment texture in the scene.
  10208. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10209. *
  10210. * Remarks: Can be either a texture or a url.
  10211. */
  10212. environmentTexture: string | BaseTexture;
  10213. /**
  10214. * The value of the exposure to apply to the scene.
  10215. * 0.6 by default if setupImageProcessing is true.
  10216. */
  10217. cameraExposure: number;
  10218. /**
  10219. * The value of the contrast to apply to the scene.
  10220. * 1.6 by default if setupImageProcessing is true.
  10221. */
  10222. cameraContrast: number;
  10223. /**
  10224. * Specifies wether or not tonemapping should be enabled in the scene.
  10225. * true by default if setupImageProcessing is true.
  10226. */
  10227. toneMappingEnabled: boolean;
  10228. }
  10229. /**
  10230. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10231. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10232. * It also helps with the default setup of your imageProcessing configuration.
  10233. */
  10234. class EnvironmentHelper {
  10235. /**
  10236. * Default ground texture URL.
  10237. */
  10238. private static _groundTextureCDNUrl;
  10239. /**
  10240. * Default skybox texture URL.
  10241. */
  10242. private static _skyboxTextureCDNUrl;
  10243. /**
  10244. * Default environment texture URL.
  10245. */
  10246. private static _environmentTextureCDNUrl;
  10247. /**
  10248. * Creates the default options for the helper.
  10249. */
  10250. private static _getDefaultOptions;
  10251. private _rootMesh;
  10252. /**
  10253. * Gets the root mesh created by the helper.
  10254. */
  10255. readonly rootMesh: Mesh;
  10256. private _skybox;
  10257. /**
  10258. * Gets the skybox created by the helper.
  10259. */
  10260. readonly skybox: Nullable<Mesh>;
  10261. private _skyboxTexture;
  10262. /**
  10263. * Gets the skybox texture created by the helper.
  10264. */
  10265. readonly skyboxTexture: Nullable<BaseTexture>;
  10266. private _skyboxMaterial;
  10267. /**
  10268. * Gets the skybox material created by the helper.
  10269. */
  10270. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10271. private _ground;
  10272. /**
  10273. * Gets the ground mesh created by the helper.
  10274. */
  10275. readonly ground: Nullable<Mesh>;
  10276. private _groundTexture;
  10277. /**
  10278. * Gets the ground texture created by the helper.
  10279. */
  10280. readonly groundTexture: Nullable<BaseTexture>;
  10281. private _groundMirror;
  10282. /**
  10283. * Gets the ground mirror created by the helper.
  10284. */
  10285. readonly groundMirror: Nullable<MirrorTexture>;
  10286. /**
  10287. * Gets the ground mirror render list to helps pushing the meshes
  10288. * you wish in the ground reflection.
  10289. */
  10290. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10291. private _groundMaterial;
  10292. /**
  10293. * Gets the ground material created by the helper.
  10294. */
  10295. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10296. /**
  10297. * Stores the creation options.
  10298. */
  10299. private readonly _scene;
  10300. private _options;
  10301. /**
  10302. * This observable will be notified with any error during the creation of the environment,
  10303. * mainly texture creation errors.
  10304. */
  10305. onErrorObservable: Observable<{
  10306. message?: string;
  10307. exception?: any;
  10308. }>;
  10309. /**
  10310. * constructor
  10311. * @param options
  10312. * @param scene The scene to add the material to
  10313. */
  10314. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10315. /**
  10316. * Updates the background according to the new options
  10317. * @param options
  10318. */
  10319. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10320. /**
  10321. * Sets the primary color of all the available elements.
  10322. * @param color the main color to affect to the ground and the background
  10323. */
  10324. setMainColor(color: Color3): void;
  10325. /**
  10326. * Setup the image processing according to the specified options.
  10327. */
  10328. private _setupImageProcessing;
  10329. /**
  10330. * Setup the environment texture according to the specified options.
  10331. */
  10332. private _setupEnvironmentTexture;
  10333. /**
  10334. * Setup the background according to the specified options.
  10335. */
  10336. private _setupBackground;
  10337. /**
  10338. * Get the scene sizes according to the setup.
  10339. */
  10340. private _getSceneSize;
  10341. /**
  10342. * Setup the ground according to the specified options.
  10343. */
  10344. private _setupGround;
  10345. /**
  10346. * Setup the ground material according to the specified options.
  10347. */
  10348. private _setupGroundMaterial;
  10349. /**
  10350. * Setup the ground diffuse texture according to the specified options.
  10351. */
  10352. private _setupGroundDiffuseTexture;
  10353. /**
  10354. * Setup the ground mirror texture according to the specified options.
  10355. */
  10356. private _setupGroundMirrorTexture;
  10357. /**
  10358. * Setup the ground to receive the mirror texture.
  10359. */
  10360. private _setupMirrorInGroundMaterial;
  10361. /**
  10362. * Setup the skybox according to the specified options.
  10363. */
  10364. private _setupSkybox;
  10365. /**
  10366. * Setup the skybox material according to the specified options.
  10367. */
  10368. private _setupSkyboxMaterial;
  10369. /**
  10370. * Setup the skybox reflection texture according to the specified options.
  10371. */
  10372. private _setupSkyboxReflectionTexture;
  10373. private _errorHandler;
  10374. /**
  10375. * Dispose all the elements created by the Helper.
  10376. */
  10377. dispose(): void;
  10378. }
  10379. }
  10380. declare module BABYLON {
  10381. /**
  10382. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10383. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10384. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10385. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10386. */
  10387. class PhotoDome extends TransformNode {
  10388. private _useDirectMapping;
  10389. /**
  10390. * The texture being displayed on the sphere
  10391. */
  10392. protected _photoTexture: Texture;
  10393. /**
  10394. * Gets or sets the texture being displayed on the sphere
  10395. */
  10396. photoTexture: Texture;
  10397. /**
  10398. * Observable raised when an error occured while loading the 360 image
  10399. */
  10400. onLoadErrorObservable: Observable<string>;
  10401. /**
  10402. * The skybox material
  10403. */
  10404. protected _material: BackgroundMaterial;
  10405. /**
  10406. * The surface used for the skybox
  10407. */
  10408. protected _mesh: Mesh;
  10409. /**
  10410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10411. * Also see the options.resolution property.
  10412. */
  10413. fovMultiplier: number;
  10414. /**
  10415. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10416. * @param name Element's name, child elements will append suffixes for their own names.
  10417. * @param urlsOfPhoto defines the url of the photo to display
  10418. * @param options defines an object containing optional or exposed sub element properties
  10419. * @param onError defines a callback called when an error occured while loading the texture
  10420. */
  10421. constructor(name: string, urlOfPhoto: string, options: {
  10422. resolution?: number;
  10423. size?: number;
  10424. useDirectMapping?: boolean;
  10425. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10426. /**
  10427. * Releases resources associated with this node.
  10428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10430. */
  10431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10432. }
  10433. }
  10434. declare module BABYLON {
  10435. interface Scene {
  10436. /**
  10437. * Creates a default light for the scene.
  10438. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  10439. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  10440. */
  10441. createDefaultLight(replace?: boolean): void;
  10442. /**
  10443. * Creates a default camera for the scene.
  10444. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  10445. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10446. * @param replace has default false, when true replaces the active camera in the scene
  10447. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  10448. */
  10449. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10450. /**
  10451. * Creates a default camera and a default light.
  10452. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  10453. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10454. * @param replace has the default false, when true replaces the active camera/light in the scene
  10455. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  10456. */
  10457. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10458. /**
  10459. * Creates a new sky box
  10460. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  10461. * @param environmentTexture defines the texture to use as environment texture
  10462. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  10463. * @param scale defines the overall scale of the skybox
  10464. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  10465. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  10466. * @returns a new mesh holding the sky box
  10467. */
  10468. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  10469. /**
  10470. * Creates a new environment
  10471. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  10472. * @param options defines the options you can use to configure the environment
  10473. * @returns the new EnvironmentHelper
  10474. */
  10475. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  10476. /**
  10477. * Creates a new VREXperienceHelper
  10478. * @see http://doc.babylonjs.com/how_to/webvr_helper
  10479. * @param webVROptions defines the options used to create the new VREXperienceHelper
  10480. * @returns a new VREXperienceHelper
  10481. */
  10482. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  10483. }
  10484. }
  10485. declare module BABYLON {
  10486. /**
  10487. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10488. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10489. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10490. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10491. */
  10492. class VideoDome extends TransformNode {
  10493. private _useDirectMapping;
  10494. /**
  10495. * The video texture being displayed on the sphere
  10496. */
  10497. protected _videoTexture: VideoTexture;
  10498. /**
  10499. * Gets the video texture being displayed on the sphere
  10500. */
  10501. readonly videoTexture: VideoTexture;
  10502. /**
  10503. * The skybox material
  10504. */
  10505. protected _material: BackgroundMaterial;
  10506. /**
  10507. * The surface used for the skybox
  10508. */
  10509. protected _mesh: Mesh;
  10510. /**
  10511. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10512. * Also see the options.resolution property.
  10513. */
  10514. fovMultiplier: number;
  10515. /**
  10516. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10517. * @param name Element's name, child elements will append suffixes for their own names.
  10518. * @param urlsOrVideo defines the url(s) or the video element to use
  10519. * @param options An object containing optional or exposed sub element properties
  10520. */
  10521. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10522. resolution?: number;
  10523. clickToPlay?: boolean;
  10524. autoPlay?: boolean;
  10525. loop?: boolean;
  10526. size?: number;
  10527. poster?: string;
  10528. useDirectMapping?: boolean;
  10529. }, scene: Scene);
  10530. /**
  10531. * Releases resources associated with this node.
  10532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10534. */
  10535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10536. }
  10537. }
  10538. declare module BABYLON {
  10539. /**
  10540. * This class can be used to get instrumentation data from a Babylon engine
  10541. */
  10542. class EngineInstrumentation implements IDisposable {
  10543. engine: Engine;
  10544. private _captureGPUFrameTime;
  10545. private _gpuFrameTimeToken;
  10546. private _gpuFrameTime;
  10547. private _captureShaderCompilationTime;
  10548. private _shaderCompilationTime;
  10549. private _onBeginFrameObserver;
  10550. private _onEndFrameObserver;
  10551. private _onBeforeShaderCompilationObserver;
  10552. private _onAfterShaderCompilationObserver;
  10553. /**
  10554. * Gets the perf counter used for GPU frame time
  10555. */
  10556. readonly gpuFrameTimeCounter: PerfCounter;
  10557. /**
  10558. * Gets the GPU frame time capture status
  10559. */
  10560. /**
  10561. * Enable or disable the GPU frame time capture
  10562. */
  10563. captureGPUFrameTime: boolean;
  10564. /**
  10565. * Gets the perf counter used for shader compilation time
  10566. */
  10567. readonly shaderCompilationTimeCounter: PerfCounter;
  10568. /**
  10569. * Gets the shader compilation time capture status
  10570. */
  10571. /**
  10572. * Enable or disable the shader compilation time capture
  10573. */
  10574. captureShaderCompilationTime: boolean;
  10575. constructor(engine: Engine);
  10576. dispose(): void;
  10577. }
  10578. }
  10579. declare module BABYLON {
  10580. /**
  10581. * This class can be used to get instrumentation data from a Babylon engine
  10582. */
  10583. class SceneInstrumentation implements IDisposable {
  10584. scene: Scene;
  10585. private _captureActiveMeshesEvaluationTime;
  10586. private _activeMeshesEvaluationTime;
  10587. private _captureRenderTargetsRenderTime;
  10588. private _renderTargetsRenderTime;
  10589. private _captureFrameTime;
  10590. private _frameTime;
  10591. private _captureRenderTime;
  10592. private _renderTime;
  10593. private _captureInterFrameTime;
  10594. private _interFrameTime;
  10595. private _captureParticlesRenderTime;
  10596. private _particlesRenderTime;
  10597. private _captureSpritesRenderTime;
  10598. private _spritesRenderTime;
  10599. private _capturePhysicsTime;
  10600. private _physicsTime;
  10601. private _captureAnimationsTime;
  10602. private _animationsTime;
  10603. private _captureCameraRenderTime;
  10604. private _cameraRenderTime;
  10605. private _onBeforeActiveMeshesEvaluationObserver;
  10606. private _onAfterActiveMeshesEvaluationObserver;
  10607. private _onBeforeRenderTargetsRenderObserver;
  10608. private _onAfterRenderTargetsRenderObserver;
  10609. private _onAfterRenderObserver;
  10610. private _onBeforeDrawPhaseObserver;
  10611. private _onAfterDrawPhaseObserver;
  10612. private _onBeforeAnimationsObserver;
  10613. private _onBeforeParticlesRenderingObserver;
  10614. private _onAfterParticlesRenderingObserver;
  10615. private _onBeforeSpritesRenderingObserver;
  10616. private _onAfterSpritesRenderingObserver;
  10617. private _onBeforePhysicsObserver;
  10618. private _onAfterPhysicsObserver;
  10619. private _onAfterAnimationsObserver;
  10620. private _onBeforeCameraRenderObserver;
  10621. private _onAfterCameraRenderObserver;
  10622. /**
  10623. * Gets the perf counter used for active meshes evaluation time
  10624. */
  10625. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10626. /**
  10627. * Gets the active meshes evaluation time capture status
  10628. */
  10629. /**
  10630. * Enable or disable the active meshes evaluation time capture
  10631. */
  10632. captureActiveMeshesEvaluationTime: boolean;
  10633. /**
  10634. * Gets the perf counter used for render targets render time
  10635. */
  10636. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10637. /**
  10638. * Gets the render targets render time capture status
  10639. */
  10640. /**
  10641. * Enable or disable the render targets render time capture
  10642. */
  10643. captureRenderTargetsRenderTime: boolean;
  10644. /**
  10645. * Gets the perf counter used for particles render time
  10646. */
  10647. readonly particlesRenderTimeCounter: PerfCounter;
  10648. /**
  10649. * Gets the particles render time capture status
  10650. */
  10651. /**
  10652. * Enable or disable the particles render time capture
  10653. */
  10654. captureParticlesRenderTime: boolean;
  10655. /**
  10656. * Gets the perf counter used for sprites render time
  10657. */
  10658. readonly spritesRenderTimeCounter: PerfCounter;
  10659. /**
  10660. * Gets the sprites render time capture status
  10661. */
  10662. /**
  10663. * Enable or disable the sprites render time capture
  10664. */
  10665. captureSpritesRenderTime: boolean;
  10666. /**
  10667. * Gets the perf counter used for physics time
  10668. */
  10669. readonly physicsTimeCounter: PerfCounter;
  10670. /**
  10671. * Gets the physics time capture status
  10672. */
  10673. /**
  10674. * Enable or disable the physics time capture
  10675. */
  10676. capturePhysicsTime: boolean;
  10677. /**
  10678. * Gets the perf counter used for animations time
  10679. */
  10680. readonly animationsTimeCounter: PerfCounter;
  10681. /**
  10682. * Gets the animations time capture status
  10683. */
  10684. /**
  10685. * Enable or disable the animations time capture
  10686. */
  10687. captureAnimationsTime: boolean;
  10688. /**
  10689. * Gets the perf counter used for frame time capture
  10690. */
  10691. readonly frameTimeCounter: PerfCounter;
  10692. /**
  10693. * Gets the frame time capture status
  10694. */
  10695. /**
  10696. * Enable or disable the frame time capture
  10697. */
  10698. captureFrameTime: boolean;
  10699. /**
  10700. * Gets the perf counter used for inter-frames time capture
  10701. */
  10702. readonly interFrameTimeCounter: PerfCounter;
  10703. /**
  10704. * Gets the inter-frames time capture status
  10705. */
  10706. /**
  10707. * Enable or disable the inter-frames time capture
  10708. */
  10709. captureInterFrameTime: boolean;
  10710. /**
  10711. * Gets the perf counter used for render time capture
  10712. */
  10713. readonly renderTimeCounter: PerfCounter;
  10714. /**
  10715. * Gets the render time capture status
  10716. */
  10717. /**
  10718. * Enable or disable the render time capture
  10719. */
  10720. captureRenderTime: boolean;
  10721. /**
  10722. * Gets the perf counter used for camera render time capture
  10723. */
  10724. readonly cameraRenderTimeCounter: PerfCounter;
  10725. /**
  10726. * Gets the camera render time capture status
  10727. */
  10728. /**
  10729. * Enable or disable the camera render time capture
  10730. */
  10731. captureCameraRenderTime: boolean;
  10732. /**
  10733. * Gets the perf counter used for draw calls
  10734. */
  10735. readonly drawCallsCounter: PerfCounter;
  10736. /**
  10737. * Gets the perf counter used for texture collisions
  10738. */
  10739. readonly textureCollisionsCounter: PerfCounter;
  10740. constructor(scene: Scene);
  10741. dispose(): void;
  10742. }
  10743. }
  10744. declare module BABYLON {
  10745. /**
  10746. * @hidden
  10747. **/
  10748. class _TimeToken {
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /**
  10753. * Effect layer options. This helps customizing the behaviour
  10754. * of the effect layer.
  10755. */
  10756. interface IEffectLayerOptions {
  10757. /**
  10758. * Multiplication factor apply to the canvas size to compute the render target size
  10759. * used to generated the objects (the smaller the faster).
  10760. */
  10761. mainTextureRatio: number;
  10762. /**
  10763. * Enforces a fixed size texture to ensure effect stability across devices.
  10764. */
  10765. mainTextureFixedSize?: number;
  10766. /**
  10767. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10768. */
  10769. alphaBlendingMode: number;
  10770. /**
  10771. * The camera attached to the layer.
  10772. */
  10773. camera: Nullable<Camera>;
  10774. /**
  10775. * The rendering group to draw the layer in.
  10776. */
  10777. renderingGroupId: number;
  10778. }
  10779. /**
  10780. * The effect layer Helps adding post process effect blended with the main pass.
  10781. *
  10782. * This can be for instance use to generate glow or higlight effects on the scene.
  10783. *
  10784. * The effect layer class can not be used directly and is intented to inherited from to be
  10785. * customized per effects.
  10786. */
  10787. abstract class EffectLayer {
  10788. private _vertexBuffers;
  10789. private _indexBuffer;
  10790. private _cachedDefines;
  10791. private _effectLayerMapGenerationEffect;
  10792. private _effectLayerOptions;
  10793. private _mergeEffect;
  10794. protected _scene: Scene;
  10795. protected _engine: Engine;
  10796. protected _maxSize: number;
  10797. protected _mainTextureDesiredSize: ISize;
  10798. protected _mainTexture: RenderTargetTexture;
  10799. protected _shouldRender: boolean;
  10800. protected _postProcesses: PostProcess[];
  10801. protected _textures: BaseTexture[];
  10802. protected _emissiveTextureAndColor: {
  10803. texture: Nullable<BaseTexture>;
  10804. color: Color4;
  10805. };
  10806. /**
  10807. * The name of the layer
  10808. */
  10809. name: string;
  10810. /**
  10811. * The clear color of the texture used to generate the glow map.
  10812. */
  10813. neutralColor: Color4;
  10814. /**
  10815. * Specifies wether the highlight layer is enabled or not.
  10816. */
  10817. isEnabled: boolean;
  10818. /**
  10819. * Gets the camera attached to the layer.
  10820. */
  10821. readonly camera: Nullable<Camera>;
  10822. /**
  10823. * Gets the rendering group id the layer should render in.
  10824. */
  10825. readonly renderingGroupId: number;
  10826. /**
  10827. * An event triggered when the effect layer has been disposed.
  10828. */
  10829. onDisposeObservable: Observable<EffectLayer>;
  10830. /**
  10831. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10832. */
  10833. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10834. /**
  10835. * An event triggered when the generated texture is being merged in the scene.
  10836. */
  10837. onBeforeComposeObservable: Observable<EffectLayer>;
  10838. /**
  10839. * An event triggered when the generated texture has been merged in the scene.
  10840. */
  10841. onAfterComposeObservable: Observable<EffectLayer>;
  10842. /**
  10843. * An event triggered when the efffect layer changes its size.
  10844. */
  10845. onSizeChangedObservable: Observable<EffectLayer>;
  10846. /**
  10847. * Instantiates a new effect Layer and references it in the scene.
  10848. * @param name The name of the layer
  10849. * @param scene The scene to use the layer in
  10850. */
  10851. constructor(
  10852. /** The Friendly of the effect in the scene */
  10853. name: string, scene: Scene);
  10854. /**
  10855. * Get the effect name of the layer.
  10856. * @return The effect name
  10857. */
  10858. abstract getEffectName(): string;
  10859. /**
  10860. * Checks for the readiness of the element composing the layer.
  10861. * @param subMesh the mesh to check for
  10862. * @param useInstances specify wether or not to use instances to render the mesh
  10863. * @return true if ready otherwise, false
  10864. */
  10865. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10866. /**
  10867. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10868. * @returns true if the effect requires stencil during the main canvas render pass.
  10869. */
  10870. abstract needStencil(): boolean;
  10871. /**
  10872. * Create the merge effect. This is the shader use to blit the information back
  10873. * to the main canvas at the end of the scene rendering.
  10874. * @returns The effect containing the shader used to merge the effect on the main canvas
  10875. */
  10876. protected abstract _createMergeEffect(): Effect;
  10877. /**
  10878. * Creates the render target textures and post processes used in the effect layer.
  10879. */
  10880. protected abstract _createTextureAndPostProcesses(): void;
  10881. /**
  10882. * Implementation specific of rendering the generating effect on the main canvas.
  10883. * @param effect The effect used to render through
  10884. */
  10885. protected abstract _internalRender(effect: Effect): void;
  10886. /**
  10887. * Sets the required values for both the emissive texture and and the main color.
  10888. */
  10889. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10890. /**
  10891. * Free any resources and references associated to a mesh.
  10892. * Internal use
  10893. * @param mesh The mesh to free.
  10894. */
  10895. disposeMesh(mesh: Mesh): void;
  10896. /**
  10897. * Serializes this layer (Glow or Highlight for example)
  10898. * @returns a serialized layer object
  10899. */
  10900. abstract serialize?(): any;
  10901. /**
  10902. * Initializes the effect layer with the required options.
  10903. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10904. */
  10905. protected _init(options: Partial<IEffectLayerOptions>): void;
  10906. /**
  10907. * Generates the index buffer of the full screen quad blending to the main canvas.
  10908. */
  10909. private _generateIndexBuffer;
  10910. /**
  10911. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10912. */
  10913. private _genrateVertexBuffer;
  10914. /**
  10915. * Sets the main texture desired size which is the closest power of two
  10916. * of the engine canvas size.
  10917. */
  10918. private _setMainTextureSize;
  10919. /**
  10920. * Creates the main texture for the effect layer.
  10921. */
  10922. protected _createMainTexture(): void;
  10923. /**
  10924. * Checks for the readiness of the element composing the layer.
  10925. * @param subMesh the mesh to check for
  10926. * @param useInstances specify wether or not to use instances to render the mesh
  10927. * @param emissiveTexture the associated emissive texture used to generate the glow
  10928. * @return true if ready otherwise, false
  10929. */
  10930. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10931. /**
  10932. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10933. */
  10934. render(): void;
  10935. /**
  10936. * Determine if a given mesh will be used in the current effect.
  10937. * @param mesh mesh to test
  10938. * @returns true if the mesh will be used
  10939. */
  10940. hasMesh(mesh: AbstractMesh): boolean;
  10941. /**
  10942. * Returns true if the layer contains information to display, otherwise false.
  10943. * @returns true if the glow layer should be rendered
  10944. */
  10945. shouldRender(): boolean;
  10946. /**
  10947. * Returns true if the mesh should render, otherwise false.
  10948. * @param mesh The mesh to render
  10949. * @returns true if it should render otherwise false
  10950. */
  10951. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10952. /**
  10953. * Returns true if the mesh should render, otherwise false.
  10954. * @param mesh The mesh to render
  10955. * @returns true if it should render otherwise false
  10956. */
  10957. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10958. /**
  10959. * Renders the submesh passed in parameter to the generation map.
  10960. */
  10961. protected _renderSubMesh(subMesh: SubMesh): void;
  10962. /**
  10963. * Rebuild the required buffers.
  10964. * @hidden Internal use only.
  10965. */
  10966. /**
  10967. * Dispose only the render target textures and post process.
  10968. */
  10969. private _disposeTextureAndPostProcesses;
  10970. /**
  10971. * Dispose the highlight layer and free resources.
  10972. */
  10973. dispose(): void;
  10974. /**
  10975. * Gets the class name of the effect layer
  10976. * @returns the string with the class name of the effect layer
  10977. */
  10978. getClassName(): string;
  10979. /**
  10980. * Creates an effect layer from parsed effect layer data
  10981. * @param parsedEffectLayer defines effect layer data
  10982. * @param scene defines the current scene
  10983. * @param rootUrl defines the root URL containing the effect layer information
  10984. * @returns a parsed effect Layer
  10985. */
  10986. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. interface AbstractScene {
  10991. /**
  10992. * The list of effect layers (highlights/glow) added to the scene
  10993. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10994. * @see http://doc.babylonjs.com/how_to/glow_layer
  10995. */
  10996. effectLayers: Array<EffectLayer>;
  10997. /**
  10998. * Removes the given effect layer from this scene.
  10999. * @param toRemove defines the effect layer to remove
  11000. * @returns the index of the removed effect layer
  11001. */
  11002. removeEffectLayer(toRemove: EffectLayer): number;
  11003. /**
  11004. * Adds the given effect layer to this scene
  11005. * @param newEffectLayer defines the effect layer to add
  11006. */
  11007. addEffectLayer(newEffectLayer: EffectLayer): void;
  11008. }
  11009. /**
  11010. * Defines the layer scene component responsible to manage any effect layers
  11011. * in a given scene.
  11012. */
  11013. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11014. /**
  11015. * The component name helpfull to identify the component in the list of scene components.
  11016. */
  11017. readonly name: string;
  11018. /**
  11019. * The scene the component belongs to.
  11020. */
  11021. scene: Scene;
  11022. private _engine;
  11023. private _renderEffects;
  11024. private _needStencil;
  11025. private _previousStencilState;
  11026. /**
  11027. * Creates a new instance of the component for the given scene
  11028. * @param scene Defines the scene to register the component in
  11029. */
  11030. constructor(scene: Scene);
  11031. /**
  11032. * Registers the component in a given scene
  11033. */
  11034. register(): void;
  11035. /**
  11036. * Rebuilds the elements related to this component in case of
  11037. * context lost for instance.
  11038. */
  11039. rebuild(): void;
  11040. /**
  11041. * Serializes the component data to the specified json object
  11042. * @param serializationObject The object to serialize to
  11043. */
  11044. serialize(serializationObject: any): void;
  11045. /**
  11046. * Adds all the element from the container to the scene
  11047. * @param container the container holding the elements
  11048. */
  11049. addFromContainer(container: AbstractScene): void;
  11050. /**
  11051. * Removes all the elements in the container from the scene
  11052. * @param container contains the elements to remove
  11053. */
  11054. removeFromContainer(container: AbstractScene): void;
  11055. /**
  11056. * Disposes the component and the associated ressources.
  11057. */
  11058. dispose(): void;
  11059. private _isReadyForMesh;
  11060. private _renderMainTexture;
  11061. private _setStencil;
  11062. private _setStencilBack;
  11063. private _draw;
  11064. private _drawCamera;
  11065. private _drawRenderingGroup;
  11066. }
  11067. }
  11068. declare module BABYLON {
  11069. interface AbstractScene {
  11070. /**
  11071. * Return a the first highlight layer of the scene with a given name.
  11072. * @param name The name of the highlight layer to look for.
  11073. * @return The highlight layer if found otherwise null.
  11074. */
  11075. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11076. }
  11077. /**
  11078. * Glow layer options. This helps customizing the behaviour
  11079. * of the glow layer.
  11080. */
  11081. interface IGlowLayerOptions {
  11082. /**
  11083. * Multiplication factor apply to the canvas size to compute the render target size
  11084. * used to generated the glowing objects (the smaller the faster).
  11085. */
  11086. mainTextureRatio: number;
  11087. /**
  11088. * Enforces a fixed size texture to ensure resize independant blur.
  11089. */
  11090. mainTextureFixedSize?: number;
  11091. /**
  11092. * How big is the kernel of the blur texture.
  11093. */
  11094. blurKernelSize: number;
  11095. /**
  11096. * The camera attached to the layer.
  11097. */
  11098. camera: Nullable<Camera>;
  11099. /**
  11100. * Enable MSAA by chosing the number of samples.
  11101. */
  11102. mainTextureSamples?: number;
  11103. /**
  11104. * The rendering group to draw the layer in.
  11105. */
  11106. renderingGroupId: number;
  11107. }
  11108. /**
  11109. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11110. *
  11111. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11112. * glowy meshes to your scene.
  11113. *
  11114. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11115. */
  11116. class GlowLayer extends EffectLayer {
  11117. /**
  11118. * Effect Name of the layer.
  11119. */
  11120. static readonly EffectName: string;
  11121. /**
  11122. * The default blur kernel size used for the glow.
  11123. */
  11124. static DefaultBlurKernelSize: number;
  11125. /**
  11126. * The default texture size ratio used for the glow.
  11127. */
  11128. static DefaultTextureRatio: number;
  11129. /**
  11130. * Sets the kernel size of the blur.
  11131. */
  11132. /**
  11133. * Gets the kernel size of the blur.
  11134. */
  11135. blurKernelSize: number;
  11136. /**
  11137. * Sets the glow intensity.
  11138. */
  11139. /**
  11140. * Gets the glow intensity.
  11141. */
  11142. intensity: number;
  11143. private _options;
  11144. private _intensity;
  11145. private _horizontalBlurPostprocess1;
  11146. private _verticalBlurPostprocess1;
  11147. private _horizontalBlurPostprocess2;
  11148. private _verticalBlurPostprocess2;
  11149. private _blurTexture1;
  11150. private _blurTexture2;
  11151. private _postProcesses1;
  11152. private _postProcesses2;
  11153. private _includedOnlyMeshes;
  11154. private _excludedMeshes;
  11155. /**
  11156. * Callback used to let the user override the color selection on a per mesh basis
  11157. */
  11158. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11159. /**
  11160. * Callback used to let the user override the texture selection on a per mesh basis
  11161. */
  11162. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11163. /**
  11164. * Instantiates a new glow Layer and references it to the scene.
  11165. * @param name The name of the layer
  11166. * @param scene The scene to use the layer in
  11167. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11168. */
  11169. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11170. /**
  11171. * Get the effect name of the layer.
  11172. * @return The effect name
  11173. */
  11174. getEffectName(): string;
  11175. /**
  11176. * Create the merge effect. This is the shader use to blit the information back
  11177. * to the main canvas at the end of the scene rendering.
  11178. */
  11179. protected _createMergeEffect(): Effect;
  11180. /**
  11181. * Creates the render target textures and post processes used in the glow layer.
  11182. */
  11183. protected _createTextureAndPostProcesses(): void;
  11184. /**
  11185. * Checks for the readiness of the element composing the layer.
  11186. * @param subMesh the mesh to check for
  11187. * @param useInstances specify wether or not to use instances to render the mesh
  11188. * @param emissiveTexture the associated emissive texture used to generate the glow
  11189. * @return true if ready otherwise, false
  11190. */
  11191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11192. /**
  11193. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11194. */
  11195. needStencil(): boolean;
  11196. /**
  11197. * Implementation specific of rendering the generating effect on the main canvas.
  11198. * @param effect The effect used to render through
  11199. */
  11200. protected _internalRender(effect: Effect): void;
  11201. /**
  11202. * Sets the required values for both the emissive texture and and the main color.
  11203. */
  11204. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11205. /**
  11206. * Returns true if the mesh should render, otherwise false.
  11207. * @param mesh The mesh to render
  11208. * @returns true if it should render otherwise false
  11209. */
  11210. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11211. /**
  11212. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11213. * @param mesh The mesh to exclude from the glow layer
  11214. */
  11215. addExcludedMesh(mesh: Mesh): void;
  11216. /**
  11217. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11218. * @param mesh The mesh to remove
  11219. */
  11220. removeExcludedMesh(mesh: Mesh): void;
  11221. /**
  11222. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11223. * @param mesh The mesh to include in the glow layer
  11224. */
  11225. addIncludedOnlyMesh(mesh: Mesh): void;
  11226. /**
  11227. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11228. * @param mesh The mesh to remove
  11229. */
  11230. removeIncludedOnlyMesh(mesh: Mesh): void;
  11231. /**
  11232. * Determine if a given mesh will be used in the glow layer
  11233. * @param mesh The mesh to test
  11234. * @returns true if the mesh will be highlighted by the current glow layer
  11235. */
  11236. hasMesh(mesh: AbstractMesh): boolean;
  11237. /**
  11238. * Free any resources and references associated to a mesh.
  11239. * Internal use
  11240. * @param mesh The mesh to free.
  11241. * @hidden
  11242. */
  11243. /**
  11244. * Gets the class name of the effect layer
  11245. * @returns the string with the class name of the effect layer
  11246. */
  11247. getClassName(): string;
  11248. /**
  11249. * Serializes this glow layer
  11250. * @returns a serialized glow layer object
  11251. */
  11252. serialize(): any;
  11253. /**
  11254. * Creates a Glow Layer from parsed glow layer data
  11255. * @param parsedGlowLayer defines glow layer data
  11256. * @param scene defines the current scene
  11257. * @param rootUrl defines the root URL containing the glow layer information
  11258. * @returns a parsed Glow Layer
  11259. */
  11260. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11261. }
  11262. }
  11263. declare module BABYLON {
  11264. interface AbstractScene {
  11265. /**
  11266. * Return a the first highlight layer of the scene with a given name.
  11267. * @param name The name of the highlight layer to look for.
  11268. * @return The highlight layer if found otherwise null.
  11269. */
  11270. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11271. }
  11272. /**
  11273. * Highlight layer options. This helps customizing the behaviour
  11274. * of the highlight layer.
  11275. */
  11276. interface IHighlightLayerOptions {
  11277. /**
  11278. * Multiplication factor apply to the canvas size to compute the render target size
  11279. * used to generated the glowing objects (the smaller the faster).
  11280. */
  11281. mainTextureRatio: number;
  11282. /**
  11283. * Enforces a fixed size texture to ensure resize independant blur.
  11284. */
  11285. mainTextureFixedSize?: number;
  11286. /**
  11287. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11288. * of the picture to blur (the smaller the faster).
  11289. */
  11290. blurTextureSizeRatio: number;
  11291. /**
  11292. * How big in texel of the blur texture is the vertical blur.
  11293. */
  11294. blurVerticalSize: number;
  11295. /**
  11296. * How big in texel of the blur texture is the horizontal blur.
  11297. */
  11298. blurHorizontalSize: number;
  11299. /**
  11300. * Alpha blending mode used to apply the blur. Default is combine.
  11301. */
  11302. alphaBlendingMode: number;
  11303. /**
  11304. * The camera attached to the layer.
  11305. */
  11306. camera: Nullable<Camera>;
  11307. /**
  11308. * Should we display highlight as a solid stroke?
  11309. */
  11310. isStroke?: boolean;
  11311. /**
  11312. * The rendering group to draw the layer in.
  11313. */
  11314. renderingGroupId: number;
  11315. }
  11316. /**
  11317. * The highlight layer Helps adding a glow effect around a mesh.
  11318. *
  11319. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11320. * glowy meshes to your scene.
  11321. *
  11322. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11323. */
  11324. class HighlightLayer extends EffectLayer {
  11325. name: string;
  11326. /**
  11327. * Effect Name of the highlight layer.
  11328. */
  11329. static readonly EffectName: string;
  11330. /**
  11331. * The neutral color used during the preparation of the glow effect.
  11332. * This is black by default as the blend operation is a blend operation.
  11333. */
  11334. static NeutralColor: Color4;
  11335. /**
  11336. * Stencil value used for glowing meshes.
  11337. */
  11338. static GlowingMeshStencilReference: number;
  11339. /**
  11340. * Stencil value used for the other meshes in the scene.
  11341. */
  11342. static NormalMeshStencilReference: number;
  11343. /**
  11344. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11345. */
  11346. innerGlow: boolean;
  11347. /**
  11348. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11349. */
  11350. outerGlow: boolean;
  11351. /**
  11352. * Specifies the horizontal size of the blur.
  11353. */
  11354. /**
  11355. * Gets the horizontal size of the blur.
  11356. */
  11357. blurHorizontalSize: number;
  11358. /**
  11359. * Specifies the vertical size of the blur.
  11360. */
  11361. /**
  11362. * Gets the vertical size of the blur.
  11363. */
  11364. blurVerticalSize: number;
  11365. /**
  11366. * An event triggered when the highlight layer is being blurred.
  11367. */
  11368. onBeforeBlurObservable: Observable<HighlightLayer>;
  11369. /**
  11370. * An event triggered when the highlight layer has been blurred.
  11371. */
  11372. onAfterBlurObservable: Observable<HighlightLayer>;
  11373. private _instanceGlowingMeshStencilReference;
  11374. private _options;
  11375. private _downSamplePostprocess;
  11376. private _horizontalBlurPostprocess;
  11377. private _verticalBlurPostprocess;
  11378. private _blurTexture;
  11379. private _meshes;
  11380. private _excludedMeshes;
  11381. /**
  11382. * Instantiates a new highlight Layer and references it to the scene..
  11383. * @param name The name of the layer
  11384. * @param scene The scene to use the layer in
  11385. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11386. */
  11387. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11388. /**
  11389. * Get the effect name of the layer.
  11390. * @return The effect name
  11391. */
  11392. getEffectName(): string;
  11393. /**
  11394. * Create the merge effect. This is the shader use to blit the information back
  11395. * to the main canvas at the end of the scene rendering.
  11396. */
  11397. protected _createMergeEffect(): Effect;
  11398. /**
  11399. * Creates the render target textures and post processes used in the highlight layer.
  11400. */
  11401. protected _createTextureAndPostProcesses(): void;
  11402. /**
  11403. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11404. */
  11405. needStencil(): boolean;
  11406. /**
  11407. * Checks for the readiness of the element composing the layer.
  11408. * @param subMesh the mesh to check for
  11409. * @param useInstances specify wether or not to use instances to render the mesh
  11410. * @param emissiveTexture the associated emissive texture used to generate the glow
  11411. * @return true if ready otherwise, false
  11412. */
  11413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11414. /**
  11415. * Implementation specific of rendering the generating effect on the main canvas.
  11416. * @param effect The effect used to render through
  11417. */
  11418. protected _internalRender(effect: Effect): void;
  11419. /**
  11420. * Returns true if the layer contains information to display, otherwise false.
  11421. */
  11422. shouldRender(): boolean;
  11423. /**
  11424. * Returns true if the mesh should render, otherwise false.
  11425. * @param mesh The mesh to render
  11426. * @returns true if it should render otherwise false
  11427. */
  11428. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11429. /**
  11430. * Sets the required values for both the emissive texture and and the main color.
  11431. */
  11432. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11433. /**
  11434. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11435. * @param mesh The mesh to exclude from the highlight layer
  11436. */
  11437. addExcludedMesh(mesh: Mesh): void;
  11438. /**
  11439. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11440. * @param mesh The mesh to highlight
  11441. */
  11442. removeExcludedMesh(mesh: Mesh): void;
  11443. /**
  11444. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11445. * @param mesh mesh to test
  11446. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11447. */
  11448. hasMesh(mesh: AbstractMesh): boolean;
  11449. /**
  11450. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11451. * @param mesh The mesh to highlight
  11452. * @param color The color of the highlight
  11453. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11454. */
  11455. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11456. /**
  11457. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11458. * @param mesh The mesh to highlight
  11459. */
  11460. removeMesh(mesh: Mesh): void;
  11461. /**
  11462. * Force the stencil to the normal expected value for none glowing parts
  11463. */
  11464. private _defaultStencilReference;
  11465. /**
  11466. * Free any resources and references associated to a mesh.
  11467. * Internal use
  11468. * @param mesh The mesh to free.
  11469. * @hidden
  11470. */
  11471. /**
  11472. * Dispose the highlight layer and free resources.
  11473. */
  11474. dispose(): void;
  11475. /**
  11476. * Gets the class name of the effect layer
  11477. * @returns the string with the class name of the effect layer
  11478. */
  11479. getClassName(): string;
  11480. /**
  11481. * Serializes this Highlight layer
  11482. * @returns a serialized Highlight layer object
  11483. */
  11484. serialize(): any;
  11485. /**
  11486. * Creates a Highlight layer from parsed Highlight layer data
  11487. * @param parsedHightlightLayer defines the Highlight layer data
  11488. * @param scene defines the current scene
  11489. * @param rootUrl defines the root URL containing the Highlight layer information
  11490. * @returns a parsed Highlight layer
  11491. */
  11492. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11493. }
  11494. }
  11495. declare module BABYLON {
  11496. class Layer {
  11497. name: string;
  11498. texture: Nullable<Texture>;
  11499. isBackground: boolean;
  11500. color: Color4;
  11501. scale: Vector2;
  11502. offset: Vector2;
  11503. alphaBlendingMode: number;
  11504. alphaTest: boolean;
  11505. layerMask: number;
  11506. private _scene;
  11507. private _vertexBuffers;
  11508. private _indexBuffer;
  11509. private _effect;
  11510. private _alphaTestEffect;
  11511. /**
  11512. * An event triggered when the layer is disposed.
  11513. */
  11514. onDisposeObservable: Observable<Layer>;
  11515. private _onDisposeObserver;
  11516. onDispose: () => void;
  11517. /**
  11518. * An event triggered before rendering the scene
  11519. */
  11520. onBeforeRenderObservable: Observable<Layer>;
  11521. private _onBeforeRenderObserver;
  11522. onBeforeRender: () => void;
  11523. /**
  11524. * An event triggered after rendering the scene
  11525. */
  11526. onAfterRenderObservable: Observable<Layer>;
  11527. private _onAfterRenderObserver;
  11528. onAfterRender: () => void;
  11529. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11530. private _createIndexBuffer;
  11531. /** @hidden */
  11532. render(): void;
  11533. dispose(): void;
  11534. }
  11535. }
  11536. declare module BABYLON {
  11537. interface AbstractScene {
  11538. /**
  11539. * The list of layers (background and foreground) of the scene
  11540. */
  11541. layers: Array<Layer>;
  11542. }
  11543. /**
  11544. * Defines the layer scene component responsible to manage any layers
  11545. * in a given scene.
  11546. */
  11547. class LayerSceneComponent implements ISceneComponent {
  11548. /**
  11549. * The component name helpfull to identify the component in the list of scene components.
  11550. */
  11551. readonly name: string;
  11552. /**
  11553. * The scene the component belongs to.
  11554. */
  11555. scene: Scene;
  11556. private _engine;
  11557. /**
  11558. * Creates a new instance of the component for the given scene
  11559. * @param scene Defines the scene to register the component in
  11560. */
  11561. constructor(scene: Scene);
  11562. /**
  11563. * Registers the component in a given scene
  11564. */
  11565. register(): void;
  11566. /**
  11567. * Rebuilds the elements related to this component in case of
  11568. * context lost for instance.
  11569. */
  11570. rebuild(): void;
  11571. /**
  11572. * Disposes the component and the associated ressources.
  11573. */
  11574. dispose(): void;
  11575. private _draw;
  11576. private _drawBackground;
  11577. private _drawForeground;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. class LensFlare {
  11582. size: number;
  11583. position: number;
  11584. color: Color3;
  11585. texture: Nullable<Texture>;
  11586. alphaMode: number;
  11587. private _system;
  11588. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11589. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11590. dispose(): void;
  11591. }
  11592. }
  11593. declare module BABYLON {
  11594. class LensFlareSystem {
  11595. name: string;
  11596. lensFlares: LensFlare[];
  11597. borderLimit: number;
  11598. viewportBorder: number;
  11599. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11600. layerMask: number;
  11601. id: string;
  11602. private _scene;
  11603. private _emitter;
  11604. private _vertexBuffers;
  11605. private _indexBuffer;
  11606. private _effect;
  11607. private _positionX;
  11608. private _positionY;
  11609. private _isEnabled;
  11610. constructor(name: string, emitter: any, scene: Scene);
  11611. isEnabled: boolean;
  11612. getScene(): Scene;
  11613. getEmitter(): any;
  11614. setEmitter(newEmitter: any): void;
  11615. getEmitterPosition(): Vector3;
  11616. computeEffectivePosition(globalViewport: Viewport): boolean;
  11617. /** @hidden */
  11618. render(): boolean;
  11619. dispose(): void;
  11620. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11621. serialize(): any;
  11622. }
  11623. }
  11624. declare module BABYLON {
  11625. interface AbstractScene {
  11626. /**
  11627. * The list of lens flare system added to the scene
  11628. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11629. */
  11630. lensFlareSystems: Array<LensFlareSystem>;
  11631. /**
  11632. * Removes the given lens flare system from this scene.
  11633. * @param toRemove The lens flare system to remove
  11634. * @returns The index of the removed lens flare system
  11635. */
  11636. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11637. /**
  11638. * Adds the given lens flare system to this scene
  11639. * @param newLensFlareSystem The lens flare system to add
  11640. */
  11641. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11642. /**
  11643. * Gets a lens flare system using its name
  11644. * @param name defines the name to look for
  11645. * @returns the lens flare system or null if not found
  11646. */
  11647. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11648. /**
  11649. * Gets a lens flare system using its id
  11650. * @param id defines the id to look for
  11651. * @returns the lens flare system or null if not found
  11652. */
  11653. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11654. }
  11655. /**
  11656. * Defines the lens flare scene component responsible to manage any lens flares
  11657. * in a given scene.
  11658. */
  11659. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11660. /**
  11661. * The component name helpfull to identify the component in the list of scene components.
  11662. */
  11663. readonly name: string;
  11664. /**
  11665. * The scene the component belongs to.
  11666. */
  11667. scene: Scene;
  11668. /**
  11669. * Creates a new instance of the component for the given scene
  11670. * @param scene Defines the scene to register the component in
  11671. */
  11672. constructor(scene: Scene);
  11673. /**
  11674. * Registers the component in a given scene
  11675. */
  11676. register(): void;
  11677. /**
  11678. * Rebuilds the elements related to this component in case of
  11679. * context lost for instance.
  11680. */
  11681. rebuild(): void;
  11682. /**
  11683. * Adds all the element from the container to the scene
  11684. * @param container the container holding the elements
  11685. */
  11686. addFromContainer(container: AbstractScene): void;
  11687. /**
  11688. * Removes all the elements in the container from the scene
  11689. * @param container contains the elements to remove
  11690. */
  11691. removeFromContainer(container: AbstractScene): void;
  11692. /**
  11693. * Serializes the component data to the specified json object
  11694. * @param serializationObject The object to serialize to
  11695. */
  11696. serialize(serializationObject: any): void;
  11697. /**
  11698. * Disposes the component and the associated ressources.
  11699. */
  11700. dispose(): void;
  11701. private _draw;
  11702. }
  11703. }
  11704. declare module BABYLON {
  11705. /**
  11706. * A directional light is defined by a direction (what a surprise!).
  11707. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11708. * 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.
  11709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11710. */
  11711. class DirectionalLight extends ShadowLight {
  11712. private _shadowFrustumSize;
  11713. /**
  11714. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11715. */
  11716. /**
  11717. * Specifies a fix frustum size for the shadow generation.
  11718. */
  11719. shadowFrustumSize: number;
  11720. private _shadowOrthoScale;
  11721. /**
  11722. * Gets the shadow projection scale against the optimal computed one.
  11723. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11724. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11725. */
  11726. /**
  11727. * Sets the shadow projection scale against the optimal computed one.
  11728. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11729. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11730. */
  11731. shadowOrthoScale: number;
  11732. /**
  11733. * Automatically compute the projection matrix to best fit (including all the casters)
  11734. * on each frame.
  11735. */
  11736. autoUpdateExtends: boolean;
  11737. private _orthoLeft;
  11738. private _orthoRight;
  11739. private _orthoTop;
  11740. private _orthoBottom;
  11741. /**
  11742. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11743. * The directional light is emitted from everywhere in the given direction.
  11744. * It can cast shawdows.
  11745. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11746. * @param name The friendly name of the light
  11747. * @param direction The direction of the light
  11748. * @param scene The scene the light belongs to
  11749. */
  11750. constructor(name: string, direction: Vector3, scene: Scene);
  11751. /**
  11752. * Returns the string "DirectionalLight".
  11753. * @return The class name
  11754. */
  11755. getClassName(): string;
  11756. /**
  11757. * Returns the integer 1.
  11758. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11759. */
  11760. getTypeID(): number;
  11761. /**
  11762. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11763. * Returns the DirectionalLight Shadow projection matrix.
  11764. */
  11765. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11766. /**
  11767. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11768. * Returns the DirectionalLight Shadow projection matrix.
  11769. */
  11770. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11771. /**
  11772. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11773. * Returns the DirectionalLight Shadow projection matrix.
  11774. */
  11775. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11776. protected _buildUniformLayout(): void;
  11777. /**
  11778. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11779. * @param effect The effect to update
  11780. * @param lightIndex The index of the light in the effect to update
  11781. * @returns The directional light
  11782. */
  11783. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11784. /**
  11785. * Gets the minZ used for shadow according to both the scene and the light.
  11786. *
  11787. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11788. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11789. * @param activeCamera The camera we are returning the min for
  11790. * @returns the depth min z
  11791. */
  11792. getDepthMinZ(activeCamera: Camera): number;
  11793. /**
  11794. * Gets the maxZ used for shadow according to both the scene and the light.
  11795. *
  11796. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11797. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11798. * @param activeCamera The camera we are returning the max for
  11799. * @returns the depth max z
  11800. */
  11801. getDepthMaxZ(activeCamera: Camera): number;
  11802. /**
  11803. * Prepares the list of defines specific to the light type.
  11804. * @param defines the list of defines
  11805. * @param lightIndex defines the index of the light for the effect
  11806. */
  11807. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11808. }
  11809. }
  11810. declare module BABYLON {
  11811. /**
  11812. * The HemisphericLight simulates the ambient environment light,
  11813. * so the passed direction is the light reflection direction, not the incoming direction.
  11814. */
  11815. class HemisphericLight extends Light {
  11816. /**
  11817. * The groundColor is the light in the opposite direction to the one specified during creation.
  11818. * 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.
  11819. */
  11820. groundColor: Color3;
  11821. /**
  11822. * The light reflection direction, not the incoming direction.
  11823. */
  11824. direction: Vector3;
  11825. private _worldMatrix;
  11826. /**
  11827. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11828. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11829. * The HemisphericLight can't cast shadows.
  11830. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11831. * @param name The friendly name of the light
  11832. * @param direction The direction of the light reflection
  11833. * @param scene The scene the light belongs to
  11834. */
  11835. constructor(name: string, direction: Vector3, scene: Scene);
  11836. protected _buildUniformLayout(): void;
  11837. /**
  11838. * Returns the string "HemisphericLight".
  11839. * @return The class name
  11840. */
  11841. getClassName(): string;
  11842. /**
  11843. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11844. * Returns the updated direction.
  11845. * @param target The target the direction should point to
  11846. * @return The computed direction
  11847. */
  11848. setDirectionToTarget(target: Vector3): Vector3;
  11849. /**
  11850. * Returns the shadow generator associated to the light.
  11851. * @returns Always null for hemispheric lights because it does not support shadows.
  11852. */
  11853. getShadowGenerator(): Nullable<IShadowGenerator>;
  11854. /**
  11855. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11856. * @param effect The effect to update
  11857. * @param lightIndex The index of the light in the effect to update
  11858. * @returns The hemispheric light
  11859. */
  11860. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11861. /**
  11862. * @hidden internal use only.
  11863. */
  11864. /**
  11865. * Returns the integer 3.
  11866. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11867. */
  11868. getTypeID(): number;
  11869. /**
  11870. * Prepares the list of defines specific to the light type.
  11871. * @param defines the list of defines
  11872. * @param lightIndex defines the index of the light for the effect
  11873. */
  11874. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11875. }
  11876. }
  11877. declare module BABYLON {
  11878. /**
  11879. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11880. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11881. * 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.
  11882. */
  11883. abstract class Light extends Node {
  11884. /**
  11885. * Falloff Default: light is falling off following the material specification:
  11886. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11887. */
  11888. static readonly FALLOFF_DEFAULT: number;
  11889. /**
  11890. * Falloff Physical: light is falling off following the inverse squared distance law.
  11891. */
  11892. static readonly FALLOFF_PHYSICAL: number;
  11893. /**
  11894. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11895. * to enhance interoperability with other engines.
  11896. */
  11897. static readonly FALLOFF_GLTF: number;
  11898. /**
  11899. * Falloff Standard: light is falling off like in the standard material
  11900. * to enhance interoperability with other materials.
  11901. */
  11902. static readonly FALLOFF_STANDARD: number;
  11903. /**
  11904. * If every light affecting the material is in this lightmapMode,
  11905. * material.lightmapTexture adds or multiplies
  11906. * (depends on material.useLightmapAsShadowmap)
  11907. * after every other light calculations.
  11908. */
  11909. static readonly LIGHTMAP_DEFAULT: number;
  11910. /**
  11911. * material.lightmapTexture as only diffuse lighting from this light
  11912. * adds only specular lighting from this light
  11913. * adds dynamic shadows
  11914. */
  11915. static readonly LIGHTMAP_SPECULAR: number;
  11916. /**
  11917. * material.lightmapTexture as only lighting
  11918. * no light calculation from this light
  11919. * only adds dynamic shadows from this light
  11920. */
  11921. static readonly LIGHTMAP_SHADOWSONLY: number;
  11922. /**
  11923. * Each light type uses the default quantity according to its type:
  11924. * point/spot lights use luminous intensity
  11925. * directional lights use illuminance
  11926. */
  11927. static readonly INTENSITYMODE_AUTOMATIC: number;
  11928. /**
  11929. * lumen (lm)
  11930. */
  11931. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11932. /**
  11933. * candela (lm/sr)
  11934. */
  11935. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11936. /**
  11937. * lux (lm/m^2)
  11938. */
  11939. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11940. /**
  11941. * nit (cd/m^2)
  11942. */
  11943. static readonly INTENSITYMODE_LUMINANCE: number;
  11944. /**
  11945. * Light type const id of the point light.
  11946. */
  11947. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11948. /**
  11949. * Light type const id of the directional light.
  11950. */
  11951. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11952. /**
  11953. * Light type const id of the spot light.
  11954. */
  11955. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11956. /**
  11957. * Light type const id of the hemispheric light.
  11958. */
  11959. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11960. /**
  11961. * Diffuse gives the basic color to an object.
  11962. */
  11963. diffuse: Color3;
  11964. /**
  11965. * Specular produces a highlight color on an object.
  11966. * Note: This is note affecting PBR materials.
  11967. */
  11968. specular: Color3;
  11969. /**
  11970. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11971. * falling off base on range or angle.
  11972. * This can be set to any values in Light.FALLOFF_x.
  11973. *
  11974. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  11975. * other types of materials.
  11976. */
  11977. falloffType: number;
  11978. /**
  11979. * Strength of the light.
  11980. * Note: By default it is define in the framework own unit.
  11981. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11982. */
  11983. intensity: number;
  11984. private _range;
  11985. protected _inverseSquaredRange: number;
  11986. /**
  11987. * Defines how far from the source the light is impacting in scene units.
  11988. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11989. */
  11990. /**
  11991. * Defines how far from the source the light is impacting in scene units.
  11992. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11993. */
  11994. range: number;
  11995. /**
  11996. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11997. * of light.
  11998. */
  11999. private _photometricScale;
  12000. private _intensityMode;
  12001. /**
  12002. * Gets the photometric scale used to interpret the intensity.
  12003. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12004. */
  12005. /**
  12006. * Sets the photometric scale used to interpret the intensity.
  12007. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12008. */
  12009. intensityMode: number;
  12010. private _radius;
  12011. /**
  12012. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12013. */
  12014. /**
  12015. * sets the light radius used by PBR Materials to simulate soft area lights.
  12016. */
  12017. radius: number;
  12018. private _renderPriority;
  12019. /**
  12020. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12021. * exceeding the number allowed of the materials.
  12022. */
  12023. renderPriority: number;
  12024. private _shadowEnabled;
  12025. /**
  12026. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12027. * the current shadow generator.
  12028. */
  12029. /**
  12030. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12031. * the current shadow generator.
  12032. */
  12033. shadowEnabled: boolean;
  12034. private _includedOnlyMeshes;
  12035. /**
  12036. * Gets the only meshes impacted by this light.
  12037. */
  12038. /**
  12039. * Sets the only meshes impacted by this light.
  12040. */
  12041. includedOnlyMeshes: AbstractMesh[];
  12042. private _excludedMeshes;
  12043. /**
  12044. * Gets the meshes not impacted by this light.
  12045. */
  12046. /**
  12047. * Sets the meshes not impacted by this light.
  12048. */
  12049. excludedMeshes: AbstractMesh[];
  12050. private _excludeWithLayerMask;
  12051. /**
  12052. * Gets the layer id use to find what meshes are not impacted by the light.
  12053. * Inactive if 0
  12054. */
  12055. /**
  12056. * Sets the layer id use to find what meshes are not impacted by the light.
  12057. * Inactive if 0
  12058. */
  12059. excludeWithLayerMask: number;
  12060. private _includeOnlyWithLayerMask;
  12061. /**
  12062. * Gets the layer id use to find what meshes are impacted by the light.
  12063. * Inactive if 0
  12064. */
  12065. /**
  12066. * Sets the layer id use to find what meshes are impacted by the light.
  12067. * Inactive if 0
  12068. */
  12069. includeOnlyWithLayerMask: number;
  12070. private _lightmapMode;
  12071. /**
  12072. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12073. */
  12074. /**
  12075. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12076. */
  12077. lightmapMode: number;
  12078. private _parentedWorldMatrix;
  12079. /**
  12080. * Shadow generator associted to the light.
  12081. * @hidden Internal use only.
  12082. */
  12083. /**
  12084. * @hidden Internal use only.
  12085. */
  12086. /**
  12087. * @hidden Internal use only.
  12088. */
  12089. /**
  12090. * The current light unifom buffer.
  12091. * @hidden Internal use only.
  12092. */
  12093. /**
  12094. * Creates a Light object in the scene.
  12095. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12096. * @param name The firendly name of the light
  12097. * @param scene The scene the light belongs too
  12098. */
  12099. constructor(name: string, scene: Scene);
  12100. protected abstract _buildUniformLayout(): void;
  12101. /**
  12102. * Sets the passed Effect "effect" with the Light information.
  12103. * @param effect The effect to update
  12104. * @param lightIndex The index of the light in the effect to update
  12105. * @returns The light
  12106. */
  12107. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12108. /**
  12109. * @hidden internal use only.
  12110. */
  12111. getWorldMatrix(): Matrix;
  12112. /**
  12113. * Returns the string "Light".
  12114. * @returns the class name
  12115. */
  12116. getClassName(): string;
  12117. /**
  12118. * Converts the light information to a readable string for debug purpose.
  12119. * @param fullDetails Supports for multiple levels of logging within scene loading
  12120. * @returns the human readable light info
  12121. */
  12122. toString(fullDetails?: boolean): string;
  12123. /**
  12124. * Set the enabled state of this node.
  12125. * @param value - the new enabled state
  12126. */
  12127. setEnabled(value: boolean): void;
  12128. /**
  12129. * Returns the Light associated shadow generator if any.
  12130. * @return the associated shadow generator.
  12131. */
  12132. getShadowGenerator(): Nullable<IShadowGenerator>;
  12133. /**
  12134. * Returns a Vector3, the absolute light position in the World.
  12135. * @returns the world space position of the light
  12136. */
  12137. getAbsolutePosition(): Vector3;
  12138. /**
  12139. * Specifies if the light will affect the passed mesh.
  12140. * @param mesh The mesh to test against the light
  12141. * @return true the mesh is affected otherwise, false.
  12142. */
  12143. canAffectMesh(mesh: AbstractMesh): boolean;
  12144. /**
  12145. * Computes and Returns the light World matrix.
  12146. * @returns the world matrix
  12147. */
  12148. getWorldMatrix(): Matrix;
  12149. /**
  12150. * Sort function to order lights for rendering.
  12151. * @param a First Light object to compare to second.
  12152. * @param b Second Light object to compare first.
  12153. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12154. */
  12155. static CompareLightsPriority(a: Light, b: Light): number;
  12156. /**
  12157. * Releases resources associated with this node.
  12158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12160. */
  12161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12162. /**
  12163. * Returns the light type ID (integer).
  12164. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12165. */
  12166. getTypeID(): number;
  12167. /**
  12168. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12169. * @returns the scaled intensity in intensity mode unit
  12170. */
  12171. getScaledIntensity(): number;
  12172. /**
  12173. * Returns a new Light object, named "name", from the current one.
  12174. * @param name The name of the cloned light
  12175. * @returns the new created light
  12176. */
  12177. clone(name: string): Nullable<Light>;
  12178. /**
  12179. * Serializes the current light into a Serialization object.
  12180. * @returns the serialized object.
  12181. */
  12182. serialize(): any;
  12183. /**
  12184. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12185. * This new light is named "name" and added to the passed scene.
  12186. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12187. * @param name The friendly name of the light
  12188. * @param scene The scene the new light will belong to
  12189. * @returns the constructor function
  12190. */
  12191. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12192. /**
  12193. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12194. * @param parsedLight The JSON representation of the light
  12195. * @param scene The scene to create the parsed light in
  12196. * @returns the created light after parsing
  12197. */
  12198. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12199. private _hookArrayForExcluded;
  12200. private _hookArrayForIncludedOnly;
  12201. private _resyncMeshes;
  12202. /**
  12203. * Forces the meshes to update their light related information in their rendering used effects
  12204. * @hidden Internal Use Only
  12205. */
  12206. /**
  12207. * Recomputes the cached photometric scale if needed.
  12208. */
  12209. private _computePhotometricScale;
  12210. /**
  12211. * Returns the Photometric Scale according to the light type and intensity mode.
  12212. */
  12213. private _getPhotometricScale;
  12214. /**
  12215. * Reorder the light in the scene according to their defined priority.
  12216. * @hidden Internal Use Only
  12217. */
  12218. /**
  12219. * Prepares the list of defines specific to the light type.
  12220. * @param defines the list of defines
  12221. * @param lightIndex defines the index of the light for the effect
  12222. */
  12223. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12224. }
  12225. }
  12226. declare module BABYLON {
  12227. /**
  12228. * A point light is a light defined by an unique point in world space.
  12229. * The light is emitted in every direction from this point.
  12230. * A good example of a point light is a standard light bulb.
  12231. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12232. */
  12233. class PointLight extends ShadowLight {
  12234. private _shadowAngle;
  12235. /**
  12236. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12237. * This specifies what angle the shadow will use to be created.
  12238. *
  12239. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12240. */
  12241. /**
  12242. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12243. * This specifies what angle the shadow will use to be created.
  12244. *
  12245. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12246. */
  12247. shadowAngle: number;
  12248. /**
  12249. * Gets the direction if it has been set.
  12250. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12251. */
  12252. /**
  12253. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12254. */
  12255. direction: Vector3;
  12256. /**
  12257. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12258. * A PointLight emits the light in every direction.
  12259. * It can cast shadows.
  12260. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12261. * ```javascript
  12262. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12263. * ```
  12264. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12265. * @param name The light friendly name
  12266. * @param position The position of the point light in the scene
  12267. * @param scene The scene the lights belongs to
  12268. */
  12269. constructor(name: string, position: Vector3, scene: Scene);
  12270. /**
  12271. * Returns the string "PointLight"
  12272. * @returns the class name
  12273. */
  12274. getClassName(): string;
  12275. /**
  12276. * Returns the integer 0.
  12277. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12278. */
  12279. getTypeID(): number;
  12280. /**
  12281. * Specifies wether or not the shadowmap should be a cube texture.
  12282. * @returns true if the shadowmap needs to be a cube texture.
  12283. */
  12284. needCube(): boolean;
  12285. /**
  12286. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12287. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12288. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12289. */
  12290. getShadowDirection(faceIndex?: number): Vector3;
  12291. /**
  12292. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12293. * - fov = PI / 2
  12294. * - aspect ratio : 1.0
  12295. * - z-near and far equal to the active camera minZ and maxZ.
  12296. * Returns the PointLight.
  12297. */
  12298. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12299. protected _buildUniformLayout(): void;
  12300. /**
  12301. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12302. * @param effect The effect to update
  12303. * @param lightIndex The index of the light in the effect to update
  12304. * @returns The point light
  12305. */
  12306. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12307. /**
  12308. * Prepares the list of defines specific to the light type.
  12309. * @param defines the list of defines
  12310. * @param lightIndex defines the index of the light for the effect
  12311. */
  12312. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12313. }
  12314. }
  12315. declare module BABYLON {
  12316. /**
  12317. * Interface describing all the common properties and methods a shadow light needs to implement.
  12318. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12319. * as well as binding the different shadow properties to the effects.
  12320. */
  12321. interface IShadowLight extends Light {
  12322. /**
  12323. * The light id in the scene (used in scene.findLighById for instance)
  12324. */
  12325. id: string;
  12326. /**
  12327. * The position the shdow will be casted from.
  12328. */
  12329. position: Vector3;
  12330. /**
  12331. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12332. */
  12333. direction: Vector3;
  12334. /**
  12335. * The transformed position. Position of the light in world space taking parenting in account.
  12336. */
  12337. transformedPosition: Vector3;
  12338. /**
  12339. * The transformed direction. Direction of the light in world space taking parenting in account.
  12340. */
  12341. transformedDirection: Vector3;
  12342. /**
  12343. * The friendly name of the light in the scene.
  12344. */
  12345. name: string;
  12346. /**
  12347. * Defines the shadow projection clipping minimum z value.
  12348. */
  12349. shadowMinZ: number;
  12350. /**
  12351. * Defines the shadow projection clipping maximum z value.
  12352. */
  12353. shadowMaxZ: number;
  12354. /**
  12355. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12356. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12357. */
  12358. computeTransformedInformation(): boolean;
  12359. /**
  12360. * Gets the scene the light belongs to.
  12361. * @returns The scene
  12362. */
  12363. getScene(): Scene;
  12364. /**
  12365. * Callback defining a custom Projection Matrix Builder.
  12366. * This can be used to override the default projection matrix computation.
  12367. */
  12368. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12369. /**
  12370. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12371. * @param matrix The materix to updated with the projection information
  12372. * @param viewMatrix The transform matrix of the light
  12373. * @param renderList The list of mesh to render in the map
  12374. * @returns The current light
  12375. */
  12376. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12377. /**
  12378. * Gets the current depth scale used in ESM.
  12379. * @returns The scale
  12380. */
  12381. getDepthScale(): number;
  12382. /**
  12383. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12384. * @returns true if a cube texture needs to be use
  12385. */
  12386. needCube(): boolean;
  12387. /**
  12388. * Detects if the projection matrix requires to be recomputed this frame.
  12389. * @returns true if it requires to be recomputed otherwise, false.
  12390. */
  12391. needProjectionMatrixCompute(): boolean;
  12392. /**
  12393. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12394. */
  12395. forceProjectionMatrixCompute(): void;
  12396. /**
  12397. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12398. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12399. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12400. */
  12401. getShadowDirection(faceIndex?: number): Vector3;
  12402. /**
  12403. * Gets the minZ used for shadow according to both the scene and the light.
  12404. * @param activeCamera The camera we are returning the min for
  12405. * @returns the depth min z
  12406. */
  12407. getDepthMinZ(activeCamera: Camera): number;
  12408. /**
  12409. * Gets the maxZ used for shadow according to both the scene and the light.
  12410. * @param activeCamera The camera we are returning the max for
  12411. * @returns the depth max z
  12412. */
  12413. getDepthMaxZ(activeCamera: Camera): number;
  12414. }
  12415. /**
  12416. * Base implementation IShadowLight
  12417. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12418. */
  12419. abstract class ShadowLight extends Light implements IShadowLight {
  12420. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12421. protected _position: Vector3;
  12422. protected _setPosition(value: Vector3): void;
  12423. /**
  12424. * Sets the position the shadow will be casted from. Also use as the light position for both
  12425. * point and spot lights.
  12426. */
  12427. /**
  12428. * Sets the position the shadow will be casted from. Also use as the light position for both
  12429. * point and spot lights.
  12430. */
  12431. position: Vector3;
  12432. protected _direction: Vector3;
  12433. protected _setDirection(value: Vector3): void;
  12434. /**
  12435. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12436. * Also use as the light direction on spot and directional lights.
  12437. */
  12438. /**
  12439. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12440. * Also use as the light direction on spot and directional lights.
  12441. */
  12442. direction: Vector3;
  12443. private _shadowMinZ;
  12444. /**
  12445. * Gets the shadow projection clipping minimum z value.
  12446. */
  12447. /**
  12448. * Sets the shadow projection clipping minimum z value.
  12449. */
  12450. shadowMinZ: number;
  12451. private _shadowMaxZ;
  12452. /**
  12453. * Sets the shadow projection clipping maximum z value.
  12454. */
  12455. /**
  12456. * Gets the shadow projection clipping maximum z value.
  12457. */
  12458. shadowMaxZ: number;
  12459. /**
  12460. * Callback defining a custom Projection Matrix Builder.
  12461. * This can be used to override the default projection matrix computation.
  12462. */
  12463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12464. /**
  12465. * The transformed position. Position of the light in world space taking parenting in account.
  12466. */
  12467. transformedPosition: Vector3;
  12468. /**
  12469. * The transformed direction. Direction of the light in world space taking parenting in account.
  12470. */
  12471. transformedDirection: Vector3;
  12472. private _worldMatrix;
  12473. private _needProjectionMatrixCompute;
  12474. /**
  12475. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12476. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12477. */
  12478. computeTransformedInformation(): boolean;
  12479. /**
  12480. * Return the depth scale used for the shadow map.
  12481. * @returns the depth scale.
  12482. */
  12483. getDepthScale(): number;
  12484. /**
  12485. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12486. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12487. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12488. */
  12489. getShadowDirection(faceIndex?: number): Vector3;
  12490. /**
  12491. * Returns the ShadowLight absolute position in the World.
  12492. * @returns the position vector in world space
  12493. */
  12494. getAbsolutePosition(): Vector3;
  12495. /**
  12496. * Sets the ShadowLight direction toward the passed target.
  12497. * @param target The point tot target in local space
  12498. * @returns the updated ShadowLight direction
  12499. */
  12500. setDirectionToTarget(target: Vector3): Vector3;
  12501. /**
  12502. * Returns the light rotation in euler definition.
  12503. * @returns the x y z rotation in local space.
  12504. */
  12505. getRotation(): Vector3;
  12506. /**
  12507. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12508. * @returns true if a cube texture needs to be use
  12509. */
  12510. needCube(): boolean;
  12511. /**
  12512. * Detects if the projection matrix requires to be recomputed this frame.
  12513. * @returns true if it requires to be recomputed otherwise, false.
  12514. */
  12515. needProjectionMatrixCompute(): boolean;
  12516. /**
  12517. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12518. */
  12519. forceProjectionMatrixCompute(): void;
  12520. /**
  12521. * Get the world matrix of the sahdow lights.
  12522. * @hidden Internal Use Only
  12523. */
  12524. /**
  12525. * Gets the minZ used for shadow according to both the scene and the light.
  12526. * @param activeCamera The camera we are returning the min for
  12527. * @returns the depth min z
  12528. */
  12529. getDepthMinZ(activeCamera: Camera): number;
  12530. /**
  12531. * Gets the maxZ used for shadow according to both the scene and the light.
  12532. * @param activeCamera The camera we are returning the max for
  12533. * @returns the depth max z
  12534. */
  12535. getDepthMaxZ(activeCamera: Camera): number;
  12536. /**
  12537. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12538. * @param matrix The materix to updated with the projection information
  12539. * @param viewMatrix The transform matrix of the light
  12540. * @param renderList The list of mesh to render in the map
  12541. * @returns The current light
  12542. */
  12543. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12544. }
  12545. }
  12546. declare module BABYLON {
  12547. /**
  12548. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12549. * These values define a cone of light starting from the position, emitting toward the direction.
  12550. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12551. * and the exponent defines the speed of the decay of the light with distance (reach).
  12552. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12553. */
  12554. class SpotLight extends ShadowLight {
  12555. private _angle;
  12556. private _innerAngle;
  12557. private _cosHalfAngle;
  12558. private _lightAngleScale;
  12559. private _lightAngleOffset;
  12560. /**
  12561. * Gets the cone angle of the spot light in Radians.
  12562. */
  12563. /**
  12564. * Sets the cone angle of the spot light in Radians.
  12565. */
  12566. angle: number;
  12567. /**
  12568. * Only used in gltf falloff mode, this defines the angle where
  12569. * the directional falloff will start before cutting at angle which could be seen
  12570. * as outer angle.
  12571. */
  12572. /**
  12573. * Only used in gltf falloff mode, this defines the angle where
  12574. * the directional falloff will start before cutting at angle which could be seen
  12575. * as outer angle.
  12576. */
  12577. innerAngle: number;
  12578. private _shadowAngleScale;
  12579. /**
  12580. * Allows scaling the angle of the light for shadow generation only.
  12581. */
  12582. /**
  12583. * Allows scaling the angle of the light for shadow generation only.
  12584. */
  12585. shadowAngleScale: number;
  12586. /**
  12587. * The light decay speed with the distance from the emission spot.
  12588. */
  12589. exponent: number;
  12590. private _projectionTextureMatrix;
  12591. /**
  12592. * Allows reading the projecton texture
  12593. */
  12594. readonly projectionTextureMatrix: Matrix;
  12595. protected _projectionTextureLightNear: number;
  12596. /**
  12597. * Gets the near clip of the Spotlight for texture projection.
  12598. */
  12599. /**
  12600. * Sets the near clip of the Spotlight for texture projection.
  12601. */
  12602. projectionTextureLightNear: number;
  12603. protected _projectionTextureLightFar: number;
  12604. /**
  12605. * Gets the far clip of the Spotlight for texture projection.
  12606. */
  12607. /**
  12608. * Sets the far clip of the Spotlight for texture projection.
  12609. */
  12610. projectionTextureLightFar: number;
  12611. protected _projectionTextureUpDirection: Vector3;
  12612. /**
  12613. * Gets the Up vector of the Spotlight for texture projection.
  12614. */
  12615. /**
  12616. * Sets the Up vector of the Spotlight for texture projection.
  12617. */
  12618. projectionTextureUpDirection: Vector3;
  12619. private _projectionTexture;
  12620. /**
  12621. * Gets the projection texture of the light.
  12622. */
  12623. /**
  12624. * Sets the projection texture of the light.
  12625. */
  12626. projectionTexture: Nullable<BaseTexture>;
  12627. private _projectionTextureViewLightDirty;
  12628. private _projectionTextureProjectionLightDirty;
  12629. private _projectionTextureDirty;
  12630. private _projectionTextureViewTargetVector;
  12631. private _projectionTextureViewLightMatrix;
  12632. private _projectionTextureProjectionLightMatrix;
  12633. private _projectionTextureScalingMatrix;
  12634. /**
  12635. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12636. * It can cast shadows.
  12637. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12638. * @param name The light friendly name
  12639. * @param position The position of the spot light in the scene
  12640. * @param direction The direction of the light in the scene
  12641. * @param angle The cone angle of the light in Radians
  12642. * @param exponent The light decay speed with the distance from the emission spot
  12643. * @param scene The scene the lights belongs to
  12644. */
  12645. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12646. /**
  12647. * Returns the string "SpotLight".
  12648. * @returns the class name
  12649. */
  12650. getClassName(): string;
  12651. /**
  12652. * Returns the integer 2.
  12653. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12654. */
  12655. getTypeID(): number;
  12656. /**
  12657. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12658. */
  12659. protected _setDirection(value: Vector3): void;
  12660. /**
  12661. * Overrides the position setter to recompute the projection texture view light Matrix.
  12662. */
  12663. protected _setPosition(value: Vector3): void;
  12664. /**
  12665. * 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.
  12666. * Returns the SpotLight.
  12667. */
  12668. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12669. protected _computeProjectionTextureViewLightMatrix(): void;
  12670. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12671. /**
  12672. * Main function for light texture projection matrix computing.
  12673. */
  12674. protected _computeProjectionTextureMatrix(): void;
  12675. protected _buildUniformLayout(): void;
  12676. private _computeAngleValues;
  12677. /**
  12678. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12679. * @param effect The effect to update
  12680. * @param lightIndex The index of the light in the effect to update
  12681. * @returns The spot light
  12682. */
  12683. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12684. /**
  12685. * Disposes the light and the associated resources.
  12686. */
  12687. dispose(): void;
  12688. /**
  12689. * Prepares the list of defines specific to the light type.
  12690. * @param defines the list of defines
  12691. * @param lightIndex defines the index of the light for the effect
  12692. */
  12693. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12694. }
  12695. }
  12696. declare module BABYLON {
  12697. interface ILoadingScreen {
  12698. displayLoadingUI: () => void;
  12699. hideLoadingUI: () => void;
  12700. loadingUIBackgroundColor: string;
  12701. loadingUIText: string;
  12702. }
  12703. class DefaultLoadingScreen implements ILoadingScreen {
  12704. private _renderingCanvas;
  12705. private _loadingText;
  12706. private _loadingDivBackgroundColor;
  12707. private _loadingDiv;
  12708. private _loadingTextDiv;
  12709. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12710. displayLoadingUI(): void;
  12711. hideLoadingUI(): void;
  12712. loadingUIText: string;
  12713. loadingUIBackgroundColor: string;
  12714. private _resizeLoadingUI;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. class SceneLoaderProgressEvent {
  12719. readonly lengthComputable: boolean;
  12720. readonly loaded: number;
  12721. readonly total: number;
  12722. constructor(lengthComputable: boolean, loaded: number, total: number);
  12723. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12724. }
  12725. interface ISceneLoaderPluginExtensions {
  12726. [extension: string]: {
  12727. isBinary: boolean;
  12728. };
  12729. }
  12730. interface ISceneLoaderPluginFactory {
  12731. name: string;
  12732. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12733. canDirectLoad?: (data: string) => boolean;
  12734. }
  12735. interface ISceneLoaderPlugin {
  12736. /**
  12737. * The friendly name of this plugin.
  12738. */
  12739. name: string;
  12740. /**
  12741. * The file extensions supported by this plugin.
  12742. */
  12743. extensions: string | ISceneLoaderPluginExtensions;
  12744. /**
  12745. * Import meshes into a scene.
  12746. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12747. * @param scene The scene to import into
  12748. * @param data The data to import
  12749. * @param rootUrl The root url for scene and resources
  12750. * @param meshes The meshes array to import into
  12751. * @param particleSystems The particle systems array to import into
  12752. * @param skeletons The skeletons array to import into
  12753. * @param onError The callback when import fails
  12754. * @returns True if successful or false otherwise
  12755. */
  12756. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12757. /**
  12758. * Load into a scene.
  12759. * @param scene The scene to load into
  12760. * @param data The data to import
  12761. * @param rootUrl The root url for scene and resources
  12762. * @param onError The callback when import fails
  12763. * @returns true if successful or false otherwise
  12764. */
  12765. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12766. /**
  12767. * The callback that returns true if the data can be directly loaded.
  12768. */
  12769. canDirectLoad?: (data: string) => boolean;
  12770. /**
  12771. * The callback that allows custom handling of the root url based on the response url.
  12772. */
  12773. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12774. /**
  12775. * Load into an asset container.
  12776. * @param scene The scene to load into
  12777. * @param data The data to import
  12778. * @param rootUrl The root url for scene and resources
  12779. * @param onError The callback when import fails
  12780. * @returns The loaded asset container
  12781. */
  12782. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12783. }
  12784. interface ISceneLoaderPluginAsync {
  12785. /**
  12786. * The friendly name of this plugin.
  12787. */
  12788. name: string;
  12789. /**
  12790. * The file extensions supported by this plugin.
  12791. */
  12792. extensions: string | ISceneLoaderPluginExtensions;
  12793. /**
  12794. * Import meshes into a scene.
  12795. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12796. * @param scene The scene to import into
  12797. * @param data The data to import
  12798. * @param rootUrl The root url for scene and resources
  12799. * @param onProgress The callback when the load progresses
  12800. * @param fullName Defines the FQDN of the file to load
  12801. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12802. */
  12803. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  12804. meshes: AbstractMesh[];
  12805. particleSystems: IParticleSystem[];
  12806. skeletons: Skeleton[];
  12807. animationGroups: AnimationGroup[];
  12808. }>;
  12809. /**
  12810. * Load into a scene.
  12811. * @param scene The scene to load into
  12812. * @param data The data to import
  12813. * @param rootUrl The root url for scene and resources
  12814. * @param onProgress The callback when the load progresses
  12815. * @param fullName Defines the FQDN of the file to load
  12816. * @returns Nothing
  12817. */
  12818. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  12819. /**
  12820. * The callback that returns true if the data can be directly loaded.
  12821. */
  12822. canDirectLoad?: (data: string) => boolean;
  12823. /**
  12824. * The callback that allows custom handling of the root url based on the response url.
  12825. */
  12826. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12827. /**
  12828. * Load into an asset container.
  12829. * @param scene The scene to load into
  12830. * @param data The data to import
  12831. * @param rootUrl The root url for scene and resources
  12832. * @param onProgress The callback when the load progresses
  12833. * @param fullName Defines the FQDN of the file to load
  12834. * @returns The loaded asset container
  12835. */
  12836. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  12837. }
  12838. class SceneLoader {
  12839. private static _ForceFullSceneLoadingForIncremental;
  12840. private static _ShowLoadingScreen;
  12841. private static _CleanBoneMatrixWeights;
  12842. static readonly NO_LOGGING: number;
  12843. static readonly MINIMAL_LOGGING: number;
  12844. static readonly SUMMARY_LOGGING: number;
  12845. static readonly DETAILED_LOGGING: number;
  12846. private static _loggingLevel;
  12847. static ForceFullSceneLoadingForIncremental: boolean;
  12848. static ShowLoadingScreen: boolean;
  12849. static loggingLevel: number;
  12850. static CleanBoneMatrixWeights: boolean;
  12851. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12852. private static _registeredPlugins;
  12853. private static _getDefaultPlugin;
  12854. private static _getPluginForExtension;
  12855. private static _getPluginForDirectLoad;
  12856. private static _getPluginForFilename;
  12857. private static _getDirectLoad;
  12858. private static _loadData;
  12859. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12860. static IsPluginForExtensionAvailable(extension: string): boolean;
  12861. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12862. /**
  12863. * Import meshes into a scene
  12864. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12865. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12866. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12867. * @param scene the instance of BABYLON.Scene to append to
  12868. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12869. * @param onProgress a callback with a progress event for each file being loaded
  12870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12871. * @param pluginExtension the extension used to determine the plugin
  12872. * @returns The loaded plugin
  12873. */
  12874. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12875. /**
  12876. * Import meshes into a scene
  12877. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12878. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12879. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12880. * @param scene the instance of BABYLON.Scene to append to
  12881. * @param onProgress a callback with a progress event for each file being loaded
  12882. * @param pluginExtension the extension used to determine the plugin
  12883. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12884. */
  12885. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12886. meshes: AbstractMesh[];
  12887. particleSystems: IParticleSystem[];
  12888. skeletons: Skeleton[];
  12889. animationGroups: AnimationGroup[];
  12890. }>;
  12891. /**
  12892. * Load a scene
  12893. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12894. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12896. * @param onSuccess a callback with the scene when import succeeds
  12897. * @param onProgress a callback with a progress event for each file being loaded
  12898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12899. * @param pluginExtension the extension used to determine the plugin
  12900. * @returns The loaded plugin
  12901. */
  12902. 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>;
  12903. /**
  12904. * Load a scene
  12905. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12906. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12907. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12908. * @param onProgress a callback with a progress event for each file being loaded
  12909. * @param pluginExtension the extension used to determine the plugin
  12910. * @returns The loaded scene
  12911. */
  12912. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12913. /**
  12914. * Append a scene
  12915. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12916. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12917. * @param scene is the instance of BABYLON.Scene to append to
  12918. * @param onSuccess a callback with the scene when import succeeds
  12919. * @param onProgress a callback with a progress event for each file being loaded
  12920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12921. * @param pluginExtension the extension used to determine the plugin
  12922. * @returns The loaded plugin
  12923. */
  12924. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12925. /**
  12926. * Append a scene
  12927. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12928. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12929. * @param scene is the instance of BABYLON.Scene to append to
  12930. * @param onProgress a callback with a progress event for each file being loaded
  12931. * @param pluginExtension the extension used to determine the plugin
  12932. * @returns The given scene
  12933. */
  12934. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12935. /**
  12936. * Load a scene into an asset container
  12937. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12938. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12939. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12940. * @param onSuccess a callback with the scene when import succeeds
  12941. * @param onProgress a callback with a progress event for each file being loaded
  12942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12943. * @param pluginExtension the extension used to determine the plugin
  12944. * @returns The loaded plugin
  12945. */
  12946. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12947. /**
  12948. * Load a scene into an asset container
  12949. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12950. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12951. * @param scene is the instance of BABYLON.Scene to append to
  12952. * @param onProgress a callback with a progress event for each file being loaded
  12953. * @param pluginExtension the extension used to determine the plugin
  12954. * @returns The loaded asset container
  12955. */
  12956. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12957. }
  12958. }
  12959. declare module BABYLON {
  12960. /**
  12961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12963. * 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;
  12964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12965. */
  12966. class ColorCurves {
  12967. private _dirty;
  12968. private _tempColor;
  12969. private _globalCurve;
  12970. private _highlightsCurve;
  12971. private _midtonesCurve;
  12972. private _shadowsCurve;
  12973. private _positiveCurve;
  12974. private _negativeCurve;
  12975. private _globalHue;
  12976. private _globalDensity;
  12977. private _globalSaturation;
  12978. private _globalExposure;
  12979. /**
  12980. * Gets the global Hue value.
  12981. * 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).
  12982. */
  12983. /**
  12984. * Sets the global Hue value.
  12985. * 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).
  12986. */
  12987. globalHue: number;
  12988. /**
  12989. * Gets the global Density value.
  12990. * 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.
  12991. * Values less than zero provide a filter of opposite hue.
  12992. */
  12993. /**
  12994. * Sets the global Density value.
  12995. * 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.
  12996. * Values less than zero provide a filter of opposite hue.
  12997. */
  12998. globalDensity: number;
  12999. /**
  13000. * Gets the global Saturation value.
  13001. * 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.
  13002. */
  13003. /**
  13004. * Sets the global Saturation value.
  13005. * 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.
  13006. */
  13007. globalSaturation: number;
  13008. /**
  13009. * Gets the global Exposure value.
  13010. * 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.
  13011. */
  13012. /**
  13013. * Sets the global Exposure value.
  13014. * 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.
  13015. */
  13016. globalExposure: number;
  13017. private _highlightsHue;
  13018. private _highlightsDensity;
  13019. private _highlightsSaturation;
  13020. private _highlightsExposure;
  13021. /**
  13022. * Gets the highlights Hue value.
  13023. * 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).
  13024. */
  13025. /**
  13026. * Sets the highlights Hue value.
  13027. * 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).
  13028. */
  13029. highlightsHue: number;
  13030. /**
  13031. * Gets the highlights Density value.
  13032. * 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.
  13033. * Values less than zero provide a filter of opposite hue.
  13034. */
  13035. /**
  13036. * Sets the highlights Density value.
  13037. * 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.
  13038. * Values less than zero provide a filter of opposite hue.
  13039. */
  13040. highlightsDensity: number;
  13041. /**
  13042. * Gets the highlights Saturation value.
  13043. * 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.
  13044. */
  13045. /**
  13046. * Sets the highlights Saturation value.
  13047. * 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.
  13048. */
  13049. highlightsSaturation: number;
  13050. /**
  13051. * Gets the highlights Exposure value.
  13052. * 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.
  13053. */
  13054. /**
  13055. * Sets the highlights Exposure value.
  13056. * 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.
  13057. */
  13058. highlightsExposure: number;
  13059. private _midtonesHue;
  13060. private _midtonesDensity;
  13061. private _midtonesSaturation;
  13062. private _midtonesExposure;
  13063. /**
  13064. * Gets the midtones Hue value.
  13065. * 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).
  13066. */
  13067. /**
  13068. * Sets the midtones Hue value.
  13069. * 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).
  13070. */
  13071. midtonesHue: number;
  13072. /**
  13073. * Gets the midtones Density value.
  13074. * 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.
  13075. * Values less than zero provide a filter of opposite hue.
  13076. */
  13077. /**
  13078. * Sets the midtones Density value.
  13079. * 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.
  13080. * Values less than zero provide a filter of opposite hue.
  13081. */
  13082. midtonesDensity: number;
  13083. /**
  13084. * Gets the midtones Saturation value.
  13085. * 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.
  13086. */
  13087. /**
  13088. * Sets the midtones Saturation value.
  13089. * 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.
  13090. */
  13091. midtonesSaturation: number;
  13092. /**
  13093. * Gets the midtones Exposure value.
  13094. * 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.
  13095. */
  13096. /**
  13097. * Sets the midtones Exposure value.
  13098. * 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.
  13099. */
  13100. midtonesExposure: number;
  13101. private _shadowsHue;
  13102. private _shadowsDensity;
  13103. private _shadowsSaturation;
  13104. private _shadowsExposure;
  13105. /**
  13106. * Gets the shadows Hue value.
  13107. * 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).
  13108. */
  13109. /**
  13110. * Sets the shadows Hue value.
  13111. * 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).
  13112. */
  13113. shadowsHue: number;
  13114. /**
  13115. * Gets the shadows Density value.
  13116. * 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.
  13117. * Values less than zero provide a filter of opposite hue.
  13118. */
  13119. /**
  13120. * Sets the shadows Density value.
  13121. * 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.
  13122. * Values less than zero provide a filter of opposite hue.
  13123. */
  13124. shadowsDensity: number;
  13125. /**
  13126. * Gets the shadows Saturation value.
  13127. * 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.
  13128. */
  13129. /**
  13130. * Sets the shadows Saturation value.
  13131. * 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.
  13132. */
  13133. shadowsSaturation: number;
  13134. /**
  13135. * Gets the shadows Exposure value.
  13136. * 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.
  13137. */
  13138. /**
  13139. * Sets the shadows Exposure value.
  13140. * 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.
  13141. */
  13142. shadowsExposure: number;
  13143. getClassName(): string;
  13144. /**
  13145. * Binds the color curves to the shader.
  13146. * @param colorCurves The color curve to bind
  13147. * @param effect The effect to bind to
  13148. */
  13149. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13150. /**
  13151. * Prepare the list of uniforms associated with the ColorCurves effects.
  13152. * @param uniformsList The list of uniforms used in the effect
  13153. */
  13154. static PrepareUniforms(uniformsList: string[]): void;
  13155. /**
  13156. * Returns color grading data based on a hue, density, saturation and exposure value.
  13157. * @param filterHue The hue of the color filter.
  13158. * @param filterDensity The density of the color filter.
  13159. * @param saturation The saturation.
  13160. * @param exposure The exposure.
  13161. * @param result The result data container.
  13162. */
  13163. private getColorGradingDataToRef;
  13164. /**
  13165. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13166. * @param value The input slider value in range [-100,100].
  13167. * @returns Adjusted value.
  13168. */
  13169. private static applyColorGradingSliderNonlinear;
  13170. /**
  13171. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13172. * @param hue The hue (H) input.
  13173. * @param saturation The saturation (S) input.
  13174. * @param brightness The brightness (B) input.
  13175. * @result An RGBA color represented as Vector4.
  13176. */
  13177. private static fromHSBToRef;
  13178. /**
  13179. * Returns a value clamped between min and max
  13180. * @param value The value to clamp
  13181. * @param min The minimum of value
  13182. * @param max The maximum of value
  13183. * @returns The clamped value.
  13184. */
  13185. private static clamp;
  13186. /**
  13187. * Clones the current color curve instance.
  13188. * @return The cloned curves
  13189. */
  13190. clone(): ColorCurves;
  13191. /**
  13192. * Serializes the current color curve instance to a json representation.
  13193. * @return a JSON representation
  13194. */
  13195. serialize(): any;
  13196. /**
  13197. * Parses the color curve from a json representation.
  13198. * @param source the JSON source to parse
  13199. * @return The parsed curves
  13200. */
  13201. static Parse(source: any): ColorCurves;
  13202. }
  13203. }
  13204. declare module BABYLON {
  13205. /**
  13206. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13207. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13208. */
  13209. class EffectFallbacks {
  13210. private _defines;
  13211. private _currentRank;
  13212. private _maxRank;
  13213. private _mesh;
  13214. /**
  13215. * Removes the fallback from the bound mesh.
  13216. */
  13217. unBindMesh(): void;
  13218. /**
  13219. * Adds a fallback on the specified property.
  13220. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13221. * @param define The name of the define in the shader
  13222. */
  13223. addFallback(rank: number, define: string): void;
  13224. /**
  13225. * Sets the mesh to use CPU skinning when needing to fallback.
  13226. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13227. * @param mesh The mesh to use the fallbacks.
  13228. */
  13229. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13230. /**
  13231. * Checks to see if more fallbacks are still availible.
  13232. */
  13233. readonly isMoreFallbacks: boolean;
  13234. /**
  13235. * Removes the defines that shoould be removed when falling back.
  13236. * @param currentDefines defines the current define statements for the shader.
  13237. * @param effect defines the current effect we try to compile
  13238. * @returns The resulting defines with defines of the current rank removed.
  13239. */
  13240. reduce(currentDefines: string, effect: Effect): string;
  13241. }
  13242. /**
  13243. * Options to be used when creating an effect.
  13244. */
  13245. class EffectCreationOptions {
  13246. /**
  13247. * Atrributes that will be used in the shader.
  13248. */
  13249. attributes: string[];
  13250. /**
  13251. * Uniform varible names that will be set in the shader.
  13252. */
  13253. uniformsNames: string[];
  13254. /**
  13255. * Uniform buffer varible names that will be set in the shader.
  13256. */
  13257. uniformBuffersNames: string[];
  13258. /**
  13259. * Sampler texture variable names that will be set in the shader.
  13260. */
  13261. samplers: string[];
  13262. /**
  13263. * Define statements that will be set in the shader.
  13264. */
  13265. defines: any;
  13266. /**
  13267. * Possible fallbacks for this effect to improve performance when needed.
  13268. */
  13269. fallbacks: Nullable<EffectFallbacks>;
  13270. /**
  13271. * Callback that will be called when the shader is compiled.
  13272. */
  13273. onCompiled: Nullable<(effect: Effect) => void>;
  13274. /**
  13275. * Callback that will be called if an error occurs during shader compilation.
  13276. */
  13277. onError: Nullable<(effect: Effect, errors: string) => void>;
  13278. /**
  13279. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13280. */
  13281. indexParameters: any;
  13282. /**
  13283. * Max number of lights that can be used in the shader.
  13284. */
  13285. maxSimultaneousLights: number;
  13286. /**
  13287. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13288. */
  13289. transformFeedbackVaryings: Nullable<string[]>;
  13290. }
  13291. /**
  13292. * Effect containing vertex and fragment shader that can be executed on an object.
  13293. */
  13294. class Effect {
  13295. /**
  13296. * Name of the effect.
  13297. */
  13298. name: any;
  13299. /**
  13300. * String container all the define statements that should be set on the shader.
  13301. */
  13302. defines: string;
  13303. /**
  13304. * Callback that will be called when the shader is compiled.
  13305. */
  13306. onCompiled: Nullable<(effect: Effect) => void>;
  13307. /**
  13308. * Callback that will be called if an error occurs during shader compilation.
  13309. */
  13310. onError: Nullable<(effect: Effect, errors: string) => void>;
  13311. /**
  13312. * Callback that will be called when effect is bound.
  13313. */
  13314. onBind: Nullable<(effect: Effect) => void>;
  13315. /**
  13316. * Unique ID of the effect.
  13317. */
  13318. uniqueId: number;
  13319. /**
  13320. * Observable that will be called when the shader is compiled.
  13321. */
  13322. onCompileObservable: Observable<Effect>;
  13323. /**
  13324. * Observable that will be called if an error occurs during shader compilation.
  13325. */
  13326. onErrorObservable: Observable<Effect>;
  13327. /** @hidden */
  13328. /**
  13329. * Observable that will be called when effect is bound.
  13330. */
  13331. readonly onBindObservable: Observable<Effect>;
  13332. /** @hidden */
  13333. private static _uniqueIdSeed;
  13334. private _engine;
  13335. private _uniformBuffersNames;
  13336. private _uniformsNames;
  13337. private _samplers;
  13338. private _isReady;
  13339. private _compilationError;
  13340. private _attributesNames;
  13341. private _attributes;
  13342. private _uniforms;
  13343. /**
  13344. * Key for the effect.
  13345. * @hidden
  13346. */
  13347. private _indexParameters;
  13348. private _fallbacks;
  13349. private _vertexSourceCode;
  13350. private _fragmentSourceCode;
  13351. private _vertexSourceCodeOverride;
  13352. private _fragmentSourceCodeOverride;
  13353. private _transformFeedbackVaryings;
  13354. /**
  13355. * Compiled shader to webGL program.
  13356. * @hidden
  13357. */
  13358. private _valueCache;
  13359. private static _baseCache;
  13360. /**
  13361. * Instantiates an effect.
  13362. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13363. * @param baseName Name of the effect.
  13364. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13365. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13366. * @param samplers List of sampler variables that will be passed to the shader.
  13367. * @param engine Engine to be used to render the effect
  13368. * @param defines Define statements to be added to the shader.
  13369. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13370. * @param onCompiled Callback that will be called when the shader is compiled.
  13371. * @param onError Callback that will be called if an error occurs during shader compilation.
  13372. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13373. */
  13374. 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);
  13375. /**
  13376. * Unique key for this effect
  13377. */
  13378. readonly key: string;
  13379. /**
  13380. * If the effect has been compiled and prepared.
  13381. * @returns if the effect is compiled and prepared.
  13382. */
  13383. isReady(): boolean;
  13384. /**
  13385. * The engine the effect was initialized with.
  13386. * @returns the engine.
  13387. */
  13388. getEngine(): Engine;
  13389. /**
  13390. * The compiled webGL program for the effect
  13391. * @returns the webGL program.
  13392. */
  13393. getProgram(): WebGLProgram;
  13394. /**
  13395. * The set of names of attribute variables for the shader.
  13396. * @returns An array of attribute names.
  13397. */
  13398. getAttributesNames(): string[];
  13399. /**
  13400. * Returns the attribute at the given index.
  13401. * @param index The index of the attribute.
  13402. * @returns The location of the attribute.
  13403. */
  13404. getAttributeLocation(index: number): number;
  13405. /**
  13406. * Returns the attribute based on the name of the variable.
  13407. * @param name of the attribute to look up.
  13408. * @returns the attribute location.
  13409. */
  13410. getAttributeLocationByName(name: string): number;
  13411. /**
  13412. * The number of attributes.
  13413. * @returns the numnber of attributes.
  13414. */
  13415. getAttributesCount(): number;
  13416. /**
  13417. * Gets the index of a uniform variable.
  13418. * @param uniformName of the uniform to look up.
  13419. * @returns the index.
  13420. */
  13421. getUniformIndex(uniformName: string): number;
  13422. /**
  13423. * Returns the attribute based on the name of the variable.
  13424. * @param uniformName of the uniform to look up.
  13425. * @returns the location of the uniform.
  13426. */
  13427. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13428. /**
  13429. * Returns an array of sampler variable names
  13430. * @returns The array of sampler variable neames.
  13431. */
  13432. getSamplers(): string[];
  13433. /**
  13434. * The error from the last compilation.
  13435. * @returns the error string.
  13436. */
  13437. getCompilationError(): string;
  13438. /**
  13439. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13440. * @param func The callback to be used.
  13441. */
  13442. executeWhenCompiled(func: (effect: Effect) => void): void;
  13443. /** @hidden */
  13444. /** @hidden */
  13445. /** @hidden */
  13446. private _processShaderConversion;
  13447. private _processIncludes;
  13448. private _processPrecision;
  13449. /**
  13450. * Recompiles the webGL program
  13451. * @param vertexSourceCode The source code for the vertex shader.
  13452. * @param fragmentSourceCode The source code for the fragment shader.
  13453. * @param onCompiled Callback called when completed.
  13454. * @param onError Callback called on error.
  13455. * @hidden
  13456. */
  13457. /**
  13458. * Gets the uniform locations of the the specified variable names
  13459. * @param names THe names of the variables to lookup.
  13460. * @returns Array of locations in the same order as variable names.
  13461. */
  13462. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13463. /**
  13464. * Prepares the effect
  13465. * @hidden
  13466. */
  13467. /**
  13468. * Checks if the effect is supported. (Must be called after compilation)
  13469. */
  13470. readonly isSupported: boolean;
  13471. /**
  13472. * Binds a texture to the engine to be used as output of the shader.
  13473. * @param channel Name of the output variable.
  13474. * @param texture Texture to bind.
  13475. * @hidden
  13476. */
  13477. /**
  13478. * Sets a texture on the engine to be used in the shader.
  13479. * @param channel Name of the sampler variable.
  13480. * @param texture Texture to set.
  13481. */
  13482. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13483. /**
  13484. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13485. * @param channel Name of the sampler variable.
  13486. * @param texture Texture to set.
  13487. */
  13488. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13489. /**
  13490. * Sets an array of textures on the engine to be used in the shader.
  13491. * @param channel Name of the variable.
  13492. * @param textures Textures to set.
  13493. */
  13494. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13495. /**
  13496. * 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)
  13497. * @param channel Name of the sampler variable.
  13498. * @param postProcess Post process to get the input texture from.
  13499. */
  13500. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13501. /**
  13502. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13503. * 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)
  13504. * @param channel Name of the sampler variable.
  13505. * @param postProcess Post process to get the output texture from.
  13506. */
  13507. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13508. /** @hidden */
  13509. /** @hidden */
  13510. /** @hidden */
  13511. /** @hidden */
  13512. /**
  13513. * Binds a buffer to a uniform.
  13514. * @param buffer Buffer to bind.
  13515. * @param name Name of the uniform variable to bind to.
  13516. */
  13517. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13518. /**
  13519. * Binds block to a uniform.
  13520. * @param blockName Name of the block to bind.
  13521. * @param index Index to bind.
  13522. */
  13523. bindUniformBlock(blockName: string, index: number): void;
  13524. /**
  13525. * Sets an interger value on a uniform variable.
  13526. * @param uniformName Name of the variable.
  13527. * @param value Value to be set.
  13528. * @returns this effect.
  13529. */
  13530. setInt(uniformName: string, value: number): Effect;
  13531. /**
  13532. * Sets an int array on a uniform variable.
  13533. * @param uniformName Name of the variable.
  13534. * @param array array to be set.
  13535. * @returns this effect.
  13536. */
  13537. setIntArray(uniformName: string, array: Int32Array): Effect;
  13538. /**
  13539. * 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)
  13540. * @param uniformName Name of the variable.
  13541. * @param array array to be set.
  13542. * @returns this effect.
  13543. */
  13544. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13545. /**
  13546. * 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)
  13547. * @param uniformName Name of the variable.
  13548. * @param array array to be set.
  13549. * @returns this effect.
  13550. */
  13551. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13552. /**
  13553. * 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)
  13554. * @param uniformName Name of the variable.
  13555. * @param array array to be set.
  13556. * @returns this effect.
  13557. */
  13558. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13559. /**
  13560. * Sets an float array on a uniform variable.
  13561. * @param uniformName Name of the variable.
  13562. * @param array array to be set.
  13563. * @returns this effect.
  13564. */
  13565. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13566. /**
  13567. * 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)
  13568. * @param uniformName Name of the variable.
  13569. * @param array array to be set.
  13570. * @returns this effect.
  13571. */
  13572. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13573. /**
  13574. * 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)
  13575. * @param uniformName Name of the variable.
  13576. * @param array array to be set.
  13577. * @returns this effect.
  13578. */
  13579. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13580. /**
  13581. * 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)
  13582. * @param uniformName Name of the variable.
  13583. * @param array array to be set.
  13584. * @returns this effect.
  13585. */
  13586. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13587. /**
  13588. * Sets an array on a uniform variable.
  13589. * @param uniformName Name of the variable.
  13590. * @param array array to be set.
  13591. * @returns this effect.
  13592. */
  13593. setArray(uniformName: string, array: number[]): Effect;
  13594. /**
  13595. * 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)
  13596. * @param uniformName Name of the variable.
  13597. * @param array array to be set.
  13598. * @returns this effect.
  13599. */
  13600. setArray2(uniformName: string, array: number[]): Effect;
  13601. /**
  13602. * 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)
  13603. * @param uniformName Name of the variable.
  13604. * @param array array to be set.
  13605. * @returns this effect.
  13606. */
  13607. setArray3(uniformName: string, array: number[]): Effect;
  13608. /**
  13609. * 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)
  13610. * @param uniformName Name of the variable.
  13611. * @param array array to be set.
  13612. * @returns this effect.
  13613. */
  13614. setArray4(uniformName: string, array: number[]): Effect;
  13615. /**
  13616. * Sets matrices on a uniform variable.
  13617. * @param uniformName Name of the variable.
  13618. * @param matrices matrices to be set.
  13619. * @returns this effect.
  13620. */
  13621. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13622. /**
  13623. * Sets matrix on a uniform variable.
  13624. * @param uniformName Name of the variable.
  13625. * @param matrix matrix to be set.
  13626. * @returns this effect.
  13627. */
  13628. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13629. /**
  13630. * 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)
  13631. * @param uniformName Name of the variable.
  13632. * @param matrix matrix to be set.
  13633. * @returns this effect.
  13634. */
  13635. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13636. /**
  13637. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13638. * @param uniformName Name of the variable.
  13639. * @param matrix matrix to be set.
  13640. * @returns this effect.
  13641. */
  13642. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13643. /**
  13644. * Sets a float on a uniform variable.
  13645. * @param uniformName Name of the variable.
  13646. * @param value value to be set.
  13647. * @returns this effect.
  13648. */
  13649. setFloat(uniformName: string, value: number): Effect;
  13650. /**
  13651. * Sets a boolean on a uniform variable.
  13652. * @param uniformName Name of the variable.
  13653. * @param bool value to be set.
  13654. * @returns this effect.
  13655. */
  13656. setBool(uniformName: string, bool: boolean): Effect;
  13657. /**
  13658. * Sets a Vector2 on a uniform variable.
  13659. * @param uniformName Name of the variable.
  13660. * @param vector2 vector2 to be set.
  13661. * @returns this effect.
  13662. */
  13663. setVector2(uniformName: string, vector2: Vector2): Effect;
  13664. /**
  13665. * Sets a float2 on a uniform variable.
  13666. * @param uniformName Name of the variable.
  13667. * @param x First float in float2.
  13668. * @param y Second float in float2.
  13669. * @returns this effect.
  13670. */
  13671. setFloat2(uniformName: string, x: number, y: number): Effect;
  13672. /**
  13673. * Sets a Vector3 on a uniform variable.
  13674. * @param uniformName Name of the variable.
  13675. * @param vector3 Value to be set.
  13676. * @returns this effect.
  13677. */
  13678. setVector3(uniformName: string, vector3: Vector3): Effect;
  13679. /**
  13680. * Sets a float3 on a uniform variable.
  13681. * @param uniformName Name of the variable.
  13682. * @param x First float in float3.
  13683. * @param y Second float in float3.
  13684. * @param z Third float in float3.
  13685. * @returns this effect.
  13686. */
  13687. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13688. /**
  13689. * Sets a Vector4 on a uniform variable.
  13690. * @param uniformName Name of the variable.
  13691. * @param vector4 Value to be set.
  13692. * @returns this effect.
  13693. */
  13694. setVector4(uniformName: string, vector4: Vector4): Effect;
  13695. /**
  13696. * Sets a float4 on a uniform variable.
  13697. * @param uniformName Name of the variable.
  13698. * @param x First float in float4.
  13699. * @param y Second float in float4.
  13700. * @param z Third float in float4.
  13701. * @param w Fourth float in float4.
  13702. * @returns this effect.
  13703. */
  13704. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13705. /**
  13706. * Sets a Color3 on a uniform variable.
  13707. * @param uniformName Name of the variable.
  13708. * @param color3 Value to be set.
  13709. * @returns this effect.
  13710. */
  13711. setColor3(uniformName: string, color3: Color3): Effect;
  13712. /**
  13713. * Sets a Color4 on a uniform variable.
  13714. * @param uniformName Name of the variable.
  13715. * @param color3 Value to be set.
  13716. * @param alpha Alpha value to be set.
  13717. * @returns this effect.
  13718. */
  13719. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13720. /**
  13721. * Sets a Color4 on a uniform variable
  13722. * @param uniformName defines the name of the variable
  13723. * @param color4 defines the value to be set
  13724. * @returns this effect.
  13725. */
  13726. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13727. /**
  13728. * This function will add a new shader to the shader store
  13729. * @param name the name of the shader
  13730. * @param pixelShader optional pixel shader content
  13731. * @param vertexShader optional vertex shader content
  13732. */
  13733. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13734. /**
  13735. * Store of each shader (The can be looked up using effect.key)
  13736. */
  13737. static ShadersStore: {
  13738. [key: string]: string;
  13739. };
  13740. /**
  13741. * Store of each included file for a shader (The can be looked up using effect.key)
  13742. */
  13743. static IncludesShadersStore: {
  13744. [key: string]: string;
  13745. };
  13746. /**
  13747. * Resets the cache of effects.
  13748. */
  13749. static ResetCache(): void;
  13750. }
  13751. }
  13752. declare module BABYLON {
  13753. class FresnelParameters {
  13754. private _isEnabled;
  13755. isEnabled: boolean;
  13756. leftColor: Color3;
  13757. rightColor: Color3;
  13758. bias: number;
  13759. power: number;
  13760. clone(): FresnelParameters;
  13761. serialize(): any;
  13762. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13763. }
  13764. }
  13765. declare module BABYLON {
  13766. /**
  13767. * Interface to follow in your material defines to integrate easily the
  13768. * Image proccessing functions.
  13769. * @hidden
  13770. */
  13771. interface IImageProcessingConfigurationDefines {
  13772. IMAGEPROCESSING: boolean;
  13773. VIGNETTE: boolean;
  13774. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13775. VIGNETTEBLENDMODEOPAQUE: boolean;
  13776. TONEMAPPING: boolean;
  13777. TONEMAPPING_ACES: boolean;
  13778. CONTRAST: boolean;
  13779. EXPOSURE: boolean;
  13780. COLORCURVES: boolean;
  13781. COLORGRADING: boolean;
  13782. COLORGRADING3D: boolean;
  13783. SAMPLER3DGREENDEPTH: boolean;
  13784. SAMPLER3DBGRMAP: boolean;
  13785. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13786. }
  13787. /**
  13788. * @hidden
  13789. */
  13790. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13791. IMAGEPROCESSING: boolean;
  13792. VIGNETTE: boolean;
  13793. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13794. VIGNETTEBLENDMODEOPAQUE: boolean;
  13795. TONEMAPPING: boolean;
  13796. TONEMAPPING_ACES: boolean;
  13797. CONTRAST: boolean;
  13798. COLORCURVES: boolean;
  13799. COLORGRADING: boolean;
  13800. COLORGRADING3D: boolean;
  13801. SAMPLER3DGREENDEPTH: boolean;
  13802. SAMPLER3DBGRMAP: boolean;
  13803. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13804. EXPOSURE: boolean;
  13805. constructor();
  13806. }
  13807. /**
  13808. * This groups together the common properties used for image processing either in direct forward pass
  13809. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13810. * or not.
  13811. */
  13812. class ImageProcessingConfiguration {
  13813. /**
  13814. * Default tone mapping applied in BabylonJS.
  13815. */
  13816. static readonly TONEMAPPING_STANDARD: number;
  13817. /**
  13818. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  13819. * to other engines rendering to increase portability.
  13820. */
  13821. static readonly TONEMAPPING_ACES: number;
  13822. /**
  13823. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13824. */
  13825. colorCurves: Nullable<ColorCurves>;
  13826. private _colorCurvesEnabled;
  13827. /**
  13828. * Gets wether the color curves effect is enabled.
  13829. */
  13830. /**
  13831. * Sets wether the color curves effect is enabled.
  13832. */
  13833. colorCurvesEnabled: boolean;
  13834. /**
  13835. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13836. */
  13837. colorGradingTexture: Nullable<BaseTexture>;
  13838. private _colorGradingEnabled;
  13839. /**
  13840. * Gets wether the color grading effect is enabled.
  13841. */
  13842. /**
  13843. * Sets wether the color grading effect is enabled.
  13844. */
  13845. colorGradingEnabled: boolean;
  13846. private _colorGradingWithGreenDepth;
  13847. /**
  13848. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13849. */
  13850. /**
  13851. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13852. */
  13853. colorGradingWithGreenDepth: boolean;
  13854. private _colorGradingBGR;
  13855. /**
  13856. * Gets wether the color grading texture contains BGR values.
  13857. */
  13858. /**
  13859. * Sets wether the color grading texture contains BGR values.
  13860. */
  13861. colorGradingBGR: boolean;
  13862. /** @hidden */
  13863. /**
  13864. * Gets the Exposure used in the effect.
  13865. */
  13866. /**
  13867. * Sets the Exposure used in the effect.
  13868. */
  13869. exposure: number;
  13870. private _toneMappingEnabled;
  13871. /**
  13872. * Gets wether the tone mapping effect is enabled.
  13873. */
  13874. /**
  13875. * Sets wether the tone mapping effect is enabled.
  13876. */
  13877. toneMappingEnabled: boolean;
  13878. private _toneMappingType;
  13879. /**
  13880. * Gets the type of tone mapping effect.
  13881. */
  13882. /**
  13883. * Sets the type of tone mapping effect used in BabylonJS.
  13884. */
  13885. toneMappingType: number;
  13886. protected _contrast: number;
  13887. /**
  13888. * Gets the contrast used in the effect.
  13889. */
  13890. /**
  13891. * Sets the contrast used in the effect.
  13892. */
  13893. contrast: number;
  13894. /**
  13895. * Vignette stretch size.
  13896. */
  13897. vignetteStretch: number;
  13898. /**
  13899. * Vignette centre X Offset.
  13900. */
  13901. vignetteCentreX: number;
  13902. /**
  13903. * Vignette centre Y Offset.
  13904. */
  13905. vignetteCentreY: number;
  13906. /**
  13907. * Vignette weight or intensity of the vignette effect.
  13908. */
  13909. vignetteWeight: number;
  13910. /**
  13911. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13912. * if vignetteEnabled is set to true.
  13913. */
  13914. vignetteColor: Color4;
  13915. /**
  13916. * Camera field of view used by the Vignette effect.
  13917. */
  13918. vignetteCameraFov: number;
  13919. private _vignetteBlendMode;
  13920. /**
  13921. * Gets the vignette blend mode allowing different kind of effect.
  13922. */
  13923. /**
  13924. * Sets the vignette blend mode allowing different kind of effect.
  13925. */
  13926. vignetteBlendMode: number;
  13927. private _vignetteEnabled;
  13928. /**
  13929. * Gets wether the vignette effect is enabled.
  13930. */
  13931. /**
  13932. * Sets wether the vignette effect is enabled.
  13933. */
  13934. vignetteEnabled: boolean;
  13935. private _applyByPostProcess;
  13936. /**
  13937. * Gets wether the image processing is applied through a post process or not.
  13938. */
  13939. /**
  13940. * Sets wether the image processing is applied through a post process or not.
  13941. */
  13942. applyByPostProcess: boolean;
  13943. private _isEnabled;
  13944. /**
  13945. * Gets wether the image processing is enabled or not.
  13946. */
  13947. /**
  13948. * Sets wether the image processing is enabled or not.
  13949. */
  13950. isEnabled: boolean;
  13951. /**
  13952. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13953. */
  13954. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13955. /**
  13956. * Method called each time the image processing information changes requires to recompile the effect.
  13957. */
  13958. protected _updateParameters(): void;
  13959. getClassName(): string;
  13960. /**
  13961. * Prepare the list of uniforms associated with the Image Processing effects.
  13962. * @param uniformsList The list of uniforms used in the effect
  13963. * @param defines the list of defines currently in use
  13964. */
  13965. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13966. /**
  13967. * Prepare the list of samplers associated with the Image Processing effects.
  13968. * @param uniformsList The list of uniforms used in the effect
  13969. * @param defines the list of defines currently in use
  13970. */
  13971. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13972. /**
  13973. * Prepare the list of defines associated to the shader.
  13974. * @param defines the list of defines to complete
  13975. */
  13976. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13977. /**
  13978. * Returns true if all the image processing information are ready.
  13979. */
  13980. isReady(): boolean;
  13981. /**
  13982. * Binds the image processing to the shader.
  13983. * @param effect The effect to bind to
  13984. */
  13985. bind(effect: Effect, aspectRatio?: number): void;
  13986. /**
  13987. * Clones the current image processing instance.
  13988. * @return The cloned image processing
  13989. */
  13990. clone(): ImageProcessingConfiguration;
  13991. /**
  13992. * Serializes the current image processing instance to a json representation.
  13993. * @return a JSON representation
  13994. */
  13995. serialize(): any;
  13996. /**
  13997. * Parses the image processing from a json representation.
  13998. * @param source the JSON source to parse
  13999. * @return The parsed image processing
  14000. */
  14001. static Parse(source: any): ImageProcessingConfiguration;
  14002. private static _VIGNETTEMODE_MULTIPLY;
  14003. private static _VIGNETTEMODE_OPAQUE;
  14004. /**
  14005. * Used to apply the vignette as a mix with the pixel color.
  14006. */
  14007. static readonly VIGNETTEMODE_MULTIPLY: number;
  14008. /**
  14009. * Used to apply the vignette as a replacement of the pixel color.
  14010. */
  14011. static readonly VIGNETTEMODE_OPAQUE: number;
  14012. }
  14013. }
  14014. declare module BABYLON {
  14015. /**
  14016. * Manages the defines for the Material
  14017. */
  14018. class MaterialDefines {
  14019. private _keys;
  14020. private _isDirty;
  14021. /** @hidden */
  14022. /** @hidden */
  14023. /** @hidden */
  14024. /** @hidden */
  14025. /** @hidden */
  14026. /** @hidden */
  14027. /** @hidden */
  14028. /** @hidden */
  14029. /** @hidden */
  14030. /** @hidden */
  14031. /** @hidden */
  14032. /**
  14033. * Specifies if the material needs to be re-calculated
  14034. */
  14035. readonly isDirty: boolean;
  14036. /**
  14037. * Marks the material to indicate that it has been re-calculated
  14038. */
  14039. markAsProcessed(): void;
  14040. /**
  14041. * Marks the material to indicate that it needs to be re-calculated
  14042. */
  14043. markAsUnprocessed(): void;
  14044. /**
  14045. * Marks the material to indicate all of its defines need to be re-calculated
  14046. */
  14047. markAllAsDirty(): void;
  14048. /**
  14049. * Marks the material to indicate that image processing needs to be re-calculated
  14050. */
  14051. markAsImageProcessingDirty(): void;
  14052. /**
  14053. * Marks the material to indicate the lights need to be re-calculated
  14054. */
  14055. markAsLightDirty(): void;
  14056. /**
  14057. * Marks the attribute state as changed
  14058. */
  14059. markAsAttributesDirty(): void;
  14060. /**
  14061. * Marks the texture state as changed
  14062. */
  14063. markAsTexturesDirty(): void;
  14064. /**
  14065. * Marks the fresnel state as changed
  14066. */
  14067. markAsFresnelDirty(): void;
  14068. /**
  14069. * Marks the misc state as changed
  14070. */
  14071. markAsMiscDirty(): void;
  14072. /**
  14073. * Rebuilds the material defines
  14074. */
  14075. rebuild(): void;
  14076. /**
  14077. * Specifies if two material defines are equal
  14078. * @param other - A material define instance to compare to
  14079. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14080. */
  14081. isEqual(other: MaterialDefines): boolean;
  14082. /**
  14083. * Clones this instance's defines to another instance
  14084. * @param other - material defines to clone values to
  14085. */
  14086. cloneTo(other: MaterialDefines): void;
  14087. /**
  14088. * Resets the material define values
  14089. */
  14090. reset(): void;
  14091. /**
  14092. * Converts the material define values to a string
  14093. * @returns - String of material define information
  14094. */
  14095. toString(): string;
  14096. }
  14097. /**
  14098. * Base class for the main features of a material in Babylon.js
  14099. */
  14100. class Material implements IAnimatable {
  14101. private static _TriangleFillMode;
  14102. private static _WireFrameFillMode;
  14103. private static _PointFillMode;
  14104. private static _PointListDrawMode;
  14105. private static _LineListDrawMode;
  14106. private static _LineLoopDrawMode;
  14107. private static _LineStripDrawMode;
  14108. private static _TriangleStripDrawMode;
  14109. private static _TriangleFanDrawMode;
  14110. /**
  14111. * Returns the triangle fill mode
  14112. */
  14113. static readonly TriangleFillMode: number;
  14114. /**
  14115. * Returns the wireframe mode
  14116. */
  14117. static readonly WireFrameFillMode: number;
  14118. /**
  14119. * Returns the point fill mode
  14120. */
  14121. static readonly PointFillMode: number;
  14122. /**
  14123. * Returns the point list draw mode
  14124. */
  14125. static readonly PointListDrawMode: number;
  14126. /**
  14127. * Returns the line list draw mode
  14128. */
  14129. static readonly LineListDrawMode: number;
  14130. /**
  14131. * Returns the line loop draw mode
  14132. */
  14133. static readonly LineLoopDrawMode: number;
  14134. /**
  14135. * Returns the line strip draw mode
  14136. */
  14137. static readonly LineStripDrawMode: number;
  14138. /**
  14139. * Returns the triangle strip draw mode
  14140. */
  14141. static readonly TriangleStripDrawMode: number;
  14142. /**
  14143. * Returns the triangle fan draw mode
  14144. */
  14145. static readonly TriangleFanDrawMode: number;
  14146. /**
  14147. * Stores the clock-wise side orientation
  14148. */
  14149. private static _ClockWiseSideOrientation;
  14150. /**
  14151. * Stores the counter clock-wise side orientation
  14152. */
  14153. private static _CounterClockWiseSideOrientation;
  14154. /**
  14155. * Returns the clock-wise side orientation
  14156. */
  14157. static readonly ClockWiseSideOrientation: number;
  14158. /**
  14159. * Returns the counter clock-wise side orientation
  14160. */
  14161. static readonly CounterClockWiseSideOrientation: number;
  14162. /**
  14163. * The dirty texture flag value
  14164. */
  14165. private static _TextureDirtyFlag;
  14166. /**
  14167. * The dirty light flag value
  14168. */
  14169. private static _LightDirtyFlag;
  14170. /**
  14171. * The dirty fresnel flag value
  14172. */
  14173. private static _FresnelDirtyFlag;
  14174. /**
  14175. * The dirty attribute flag value
  14176. */
  14177. private static _AttributesDirtyFlag;
  14178. /**
  14179. * The dirty misc flag value
  14180. */
  14181. private static _MiscDirtyFlag;
  14182. /**
  14183. * Returns the dirty texture flag value
  14184. */
  14185. static readonly TextureDirtyFlag: number;
  14186. /**
  14187. * Returns the dirty light flag value
  14188. */
  14189. static readonly LightDirtyFlag: number;
  14190. /**
  14191. * Returns the dirty fresnel flag value
  14192. */
  14193. static readonly FresnelDirtyFlag: number;
  14194. /**
  14195. * Returns the dirty attributes flag value
  14196. */
  14197. static readonly AttributesDirtyFlag: number;
  14198. /**
  14199. * Returns the dirty misc flag value
  14200. */
  14201. static readonly MiscDirtyFlag: number;
  14202. /**
  14203. * The ID of the material
  14204. */
  14205. id: string;
  14206. /**
  14207. * Gets or sets the unique id of the material
  14208. */
  14209. uniqueId: number;
  14210. /**
  14211. * The name of the material
  14212. */
  14213. name: string;
  14214. /**
  14215. * Specifies if the ready state should be checked on each call
  14216. */
  14217. checkReadyOnEveryCall: boolean;
  14218. /**
  14219. * Specifies if the ready state should be checked once
  14220. */
  14221. checkReadyOnlyOnce: boolean;
  14222. /**
  14223. * The state of the material
  14224. */
  14225. state: string;
  14226. /**
  14227. * The alpha value of the material
  14228. */
  14229. protected _alpha: number;
  14230. /**
  14231. * Sets the alpha value of the material
  14232. */
  14233. /**
  14234. * Gets the alpha value of the material
  14235. */
  14236. alpha: number;
  14237. /**
  14238. * Specifies if back face culling is enabled
  14239. */
  14240. protected _backFaceCulling: boolean;
  14241. /**
  14242. * Sets the back-face culling state
  14243. */
  14244. /**
  14245. * Gets the back-face culling state
  14246. */
  14247. backFaceCulling: boolean;
  14248. /**
  14249. * Stores the value for side orientation
  14250. */
  14251. sideOrientation: number;
  14252. /**
  14253. * Callback triggered when the material is compiled
  14254. */
  14255. onCompiled: (effect: Effect) => void;
  14256. /**
  14257. * Callback triggered when an error occurs
  14258. */
  14259. onError: (effect: Effect, errors: string) => void;
  14260. /**
  14261. * Callback triggered to get the render target textures
  14262. */
  14263. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14264. /**
  14265. * Specifies if the material should be serialized
  14266. */
  14267. doNotSerialize: boolean;
  14268. /**
  14269. * Specifies if the effect should be stored on sub meshes
  14270. */
  14271. storeEffectOnSubMeshes: boolean;
  14272. /**
  14273. * Stores the animations for the material
  14274. */
  14275. animations: Array<Animation>;
  14276. /**
  14277. * An event triggered when the material is disposed
  14278. */
  14279. onDisposeObservable: Observable<Material>;
  14280. /**
  14281. * An observer which watches for dispose events
  14282. */
  14283. private _onDisposeObserver;
  14284. private _onUnBindObservable;
  14285. /**
  14286. * Called during a dispose event
  14287. */
  14288. onDispose: () => void;
  14289. private _onBindObservable;
  14290. /**
  14291. * An event triggered when the material is bound
  14292. */
  14293. readonly onBindObservable: Observable<AbstractMesh>;
  14294. /**
  14295. * An observer which watches for bind events
  14296. */
  14297. private _onBindObserver;
  14298. /**
  14299. * Called during a bind event
  14300. */
  14301. onBind: (Mesh: AbstractMesh) => void;
  14302. /**
  14303. * An event triggered when the material is unbound
  14304. */
  14305. readonly onUnBindObservable: Observable<Material>;
  14306. /**
  14307. * Stores the value of the alpha mode
  14308. */
  14309. private _alphaMode;
  14310. /**
  14311. * Sets the value of the alpha mode.
  14312. *
  14313. * | Value | Type | Description |
  14314. * | --- | --- | --- |
  14315. * | 0 | ALPHA_DISABLE | |
  14316. * | 1 | ALPHA_ADD | |
  14317. * | 2 | ALPHA_COMBINE | |
  14318. * | 3 | ALPHA_SUBTRACT | |
  14319. * | 4 | ALPHA_MULTIPLY | |
  14320. * | 5 | ALPHA_MAXIMIZED | |
  14321. * | 6 | ALPHA_ONEONE | |
  14322. * | 7 | ALPHA_PREMULTIPLIED | |
  14323. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14324. * | 9 | ALPHA_INTERPOLATE | |
  14325. * | 10 | ALPHA_SCREENMODE | |
  14326. *
  14327. */
  14328. /**
  14329. * Gets the value of the alpha mode
  14330. */
  14331. alphaMode: number;
  14332. /**
  14333. * Stores the state of the need depth pre-pass value
  14334. */
  14335. private _needDepthPrePass;
  14336. /**
  14337. * Sets the need depth pre-pass value
  14338. */
  14339. /**
  14340. * Gets the depth pre-pass value
  14341. */
  14342. needDepthPrePass: boolean;
  14343. /**
  14344. * Specifies if depth writing should be disabled
  14345. */
  14346. disableDepthWrite: boolean;
  14347. /**
  14348. * Specifies if depth writing should be forced
  14349. */
  14350. forceDepthWrite: boolean;
  14351. /**
  14352. * Specifies if there should be a separate pass for culling
  14353. */
  14354. separateCullingPass: boolean;
  14355. /**
  14356. * Stores the state specifing if fog should be enabled
  14357. */
  14358. private _fogEnabled;
  14359. /**
  14360. * Sets the state for enabling fog
  14361. */
  14362. /**
  14363. * Gets the value of the fog enabled state
  14364. */
  14365. fogEnabled: boolean;
  14366. /**
  14367. * Stores the size of points
  14368. */
  14369. pointSize: number;
  14370. /**
  14371. * Stores the z offset value
  14372. */
  14373. zOffset: number;
  14374. /**
  14375. * Gets a value specifying if wireframe mode is enabled
  14376. */
  14377. /**
  14378. * Sets the state of wireframe mode
  14379. */
  14380. wireframe: boolean;
  14381. /**
  14382. * Gets the value specifying if point clouds are enabled
  14383. */
  14384. /**
  14385. * Sets the state of point cloud mode
  14386. */
  14387. pointsCloud: boolean;
  14388. /**
  14389. * Gets the material fill mode
  14390. */
  14391. /**
  14392. * Sets the material fill mode
  14393. */
  14394. fillMode: number;
  14395. /**
  14396. * @hidden
  14397. * Stores the effects for the material
  14398. */
  14399. /**
  14400. * @hidden
  14401. * Specifies if the material was previously ready
  14402. */
  14403. /**
  14404. * Specifies if uniform buffers should be used
  14405. */
  14406. private _useUBO;
  14407. /**
  14408. * Stores a reference to the scene
  14409. */
  14410. private _scene;
  14411. /**
  14412. * Stores the fill mode state
  14413. */
  14414. private _fillMode;
  14415. /**
  14416. * Specifies if the depth write state should be cached
  14417. */
  14418. private _cachedDepthWriteState;
  14419. /**
  14420. * Stores the uniform buffer
  14421. */
  14422. protected _uniformBuffer: UniformBuffer;
  14423. /**
  14424. * Creates a material instance
  14425. * @param name defines the name of the material
  14426. * @param scene defines the scene to reference
  14427. * @param doNotAdd specifies if the material should be added to the scene
  14428. */
  14429. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14430. /**
  14431. * Returns a string representation of the current material
  14432. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14433. * @returns a string with material information
  14434. */
  14435. toString(fullDetails?: boolean): string;
  14436. /**
  14437. * Gets the class name of the material
  14438. * @returns a string with the class name of the material
  14439. */
  14440. getClassName(): string;
  14441. /**
  14442. * Specifies if updates for the material been locked
  14443. */
  14444. readonly isFrozen: boolean;
  14445. /**
  14446. * Locks updates for the material
  14447. */
  14448. freeze(): void;
  14449. /**
  14450. * Unlocks updates for the material
  14451. */
  14452. unfreeze(): void;
  14453. /**
  14454. * Specifies if the material is ready to be used
  14455. * @param mesh defines the mesh to check
  14456. * @param useInstances specifies if instances should be used
  14457. * @returns a boolean indicating if the material is ready to be used
  14458. */
  14459. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14460. /**
  14461. * Specifies that the submesh is ready to be used
  14462. * @param mesh defines the mesh to check
  14463. * @param subMesh defines which submesh to check
  14464. * @param useInstances specifies that instances should be used
  14465. * @returns a boolean indicating that the submesh is ready or not
  14466. */
  14467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14468. /**
  14469. * Returns the material effect
  14470. * @returns the effect associated with the material
  14471. */
  14472. getEffect(): Nullable<Effect>;
  14473. /**
  14474. * Returns the current scene
  14475. * @returns a Scene
  14476. */
  14477. getScene(): Scene;
  14478. /**
  14479. * Specifies if the material will require alpha blending
  14480. * @returns a boolean specifying if alpha blending is needed
  14481. */
  14482. needAlphaBlending(): boolean;
  14483. /**
  14484. * Specifies if the mesh will require alpha blending
  14485. * @param mesh defines the mesh to check
  14486. * @returns a boolean specifying if alpha blending is needed for the mesh
  14487. */
  14488. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14489. /**
  14490. * Specifies if this material should be rendered in alpha test mode
  14491. * @returns a boolean specifying if an alpha test is needed.
  14492. */
  14493. needAlphaTesting(): boolean;
  14494. /**
  14495. * Gets the texture used for the alpha test
  14496. * @returns the texture to use for alpha testing
  14497. */
  14498. getAlphaTestTexture(): Nullable<BaseTexture>;
  14499. /**
  14500. * Marks the material to indicate that it needs to be re-calculated
  14501. */
  14502. markDirty(): void;
  14503. /** @hidden */
  14504. /**
  14505. * Binds the material to the mesh
  14506. * @param world defines the world transformation matrix
  14507. * @param mesh defines the mesh to bind the material to
  14508. */
  14509. bind(world: Matrix, mesh?: Mesh): void;
  14510. /**
  14511. * Binds the submesh to the material
  14512. * @param world defines the world transformation matrix
  14513. * @param mesh defines the mesh containing the submesh
  14514. * @param subMesh defines the submesh to bind the material to
  14515. */
  14516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14517. /**
  14518. * Binds the world matrix to the material
  14519. * @param world defines the world transformation matrix
  14520. */
  14521. bindOnlyWorldMatrix(world: Matrix): void;
  14522. /**
  14523. * Binds the scene's uniform buffer to the effect.
  14524. * @param effect defines the effect to bind to the scene uniform buffer
  14525. * @param sceneUbo defines the uniform buffer storing scene data
  14526. */
  14527. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14528. /**
  14529. * Binds the view matrix to the effect
  14530. * @param effect defines the effect to bind the view matrix to
  14531. */
  14532. bindView(effect: Effect): void;
  14533. /**
  14534. * Binds the view projection matrix to the effect
  14535. * @param effect defines the effect to bind the view projection matrix to
  14536. */
  14537. bindViewProjection(effect: Effect): void;
  14538. /**
  14539. * Specifies if material alpha testing should be turned on for the mesh
  14540. * @param mesh defines the mesh to check
  14541. */
  14542. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14543. /**
  14544. * Processes to execute after binding the material to a mesh
  14545. * @param mesh defines the rendered mesh
  14546. */
  14547. protected _afterBind(mesh?: Mesh): void;
  14548. /**
  14549. * Unbinds the material from the mesh
  14550. */
  14551. unbind(): void;
  14552. /**
  14553. * Gets the active textures from the material
  14554. * @returns an array of textures
  14555. */
  14556. getActiveTextures(): BaseTexture[];
  14557. /**
  14558. * Specifies if the material uses a texture
  14559. * @param texture defines the texture to check against the material
  14560. * @returns a boolean specifying if the material uses the texture
  14561. */
  14562. hasTexture(texture: BaseTexture): boolean;
  14563. /**
  14564. * Makes a duplicate of the material, and gives it a new name
  14565. * @param name defines the new name for the duplicated material
  14566. * @returns the cloned material
  14567. */
  14568. clone(name: string): Nullable<Material>;
  14569. /**
  14570. * Gets the meshes bound to the material
  14571. * @returns an array of meshes bound to the material
  14572. */
  14573. getBindedMeshes(): AbstractMesh[];
  14574. /**
  14575. * Force shader compilation
  14576. * @param mesh defines the mesh associated with this material
  14577. * @param onCompiled defines a function to execute once the material is compiled
  14578. * @param options defines the options to configure the compilation
  14579. */
  14580. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14581. clipPlane: boolean;
  14582. }>): void;
  14583. /**
  14584. * Force shader compilation
  14585. * @param mesh defines the mesh that will use this material
  14586. * @param options defines additional options for compiling the shaders
  14587. * @returns a promise that resolves when the compilation completes
  14588. */
  14589. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14590. clipPlane: boolean;
  14591. }>): Promise<void>;
  14592. /**
  14593. * Marks a define in the material to indicate that it needs to be re-computed
  14594. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14595. */
  14596. markAsDirty(flag: number): void;
  14597. /**
  14598. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14599. * @param func defines a function which checks material defines against the submeshes
  14600. */
  14601. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14602. /**
  14603. * Indicates that image processing needs to be re-calculated for all submeshes
  14604. */
  14605. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14606. /**
  14607. * Indicates that textures need to be re-calculated for all submeshes
  14608. */
  14609. protected _markAllSubMeshesAsTexturesDirty(): void;
  14610. /**
  14611. * Indicates that fresnel needs to be re-calculated for all submeshes
  14612. */
  14613. protected _markAllSubMeshesAsFresnelDirty(): void;
  14614. /**
  14615. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14616. */
  14617. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14618. /**
  14619. * Indicates that lights need to be re-calculated for all submeshes
  14620. */
  14621. protected _markAllSubMeshesAsLightsDirty(): void;
  14622. /**
  14623. * Indicates that attributes need to be re-calculated for all submeshes
  14624. */
  14625. protected _markAllSubMeshesAsAttributesDirty(): void;
  14626. /**
  14627. * Indicates that misc needs to be re-calculated for all submeshes
  14628. */
  14629. protected _markAllSubMeshesAsMiscDirty(): void;
  14630. /**
  14631. * Indicates that textures and misc need to be re-calculated for all submeshes
  14632. */
  14633. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14634. /**
  14635. * Disposes the material
  14636. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14637. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14638. */
  14639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14640. /**
  14641. * Serializes this material
  14642. * @returns the serialized material object
  14643. */
  14644. serialize(): any;
  14645. /**
  14646. * Creates a MultiMaterial from parsed MultiMaterial data.
  14647. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14648. * @param scene defines the hosting scene
  14649. * @returns a new MultiMaterial
  14650. */
  14651. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14652. /**
  14653. * Creates a material from parsed material data
  14654. * @param parsedMaterial defines parsed material data
  14655. * @param scene defines the hosting scene
  14656. * @param rootUrl defines the root URL to use to load textures
  14657. * @returns a new material
  14658. */
  14659. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14660. }
  14661. }
  14662. declare module BABYLON {
  14663. /**
  14664. * "Static Class" containing the most commonly used helper while dealing with material for
  14665. * rendering purpose.
  14666. *
  14667. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14668. *
  14669. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14670. */
  14671. class MaterialHelper {
  14672. /**
  14673. * Bind the current view position to an effect.
  14674. * @param effect The effect to be bound
  14675. * @param scene The scene the eyes position is used from
  14676. */
  14677. static BindEyePosition(effect: Effect, scene: Scene): void;
  14678. /**
  14679. * Helps preparing the defines values about the UVs in used in the effect.
  14680. * UVs are shared as much as we can accross chanels in the shaders.
  14681. * @param texture The texture we are preparing the UVs for
  14682. * @param defines The defines to update
  14683. * @param key The chanel key "diffuse", "specular"... used in the shader
  14684. */
  14685. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14686. /**
  14687. * Binds a texture matrix value to its corrsponding uniform
  14688. * @param texture The texture to bind the matrix for
  14689. * @param uniformBuffer The uniform buffer receivin the data
  14690. * @param key The chanel key "diffuse", "specular"... used in the shader
  14691. */
  14692. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14693. /**
  14694. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14695. * @param mesh defines the current mesh
  14696. * @param scene defines the current scene
  14697. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14698. * @param pointsCloud defines if point cloud rendering has to be turned on
  14699. * @param fogEnabled defines if fog has to be turned on
  14700. * @param alphaTest defines if alpha testing has to be turned on
  14701. * @param defines defines the current list of defines
  14702. */
  14703. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14704. /**
  14705. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14706. * @param scene defines the current scene
  14707. * @param engine defines the current engine
  14708. * @param defines specifies the list of active defines
  14709. * @param useInstances defines if instances have to be turned on
  14710. * @param useClipPlane defines if clip plane have to be turned on
  14711. */
  14712. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14713. /**
  14714. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14715. * @param mesh The mesh containing the geometry data we will draw
  14716. * @param defines The defines to update
  14717. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14718. * @param useBones Precise whether bones should be used or not (override mesh info)
  14719. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14720. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14721. * @returns false if defines are considered not dirty and have not been checked
  14722. */
  14723. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14724. /**
  14725. * Prepares the defines related to the light information passed in parameter
  14726. * @param scene The scene we are intending to draw
  14727. * @param mesh The mesh the effect is compiling for
  14728. * @param defines The defines to update
  14729. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14730. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14731. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14732. * @returns true if normals will be required for the rest of the effect
  14733. */
  14734. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14735. /**
  14736. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14737. * that won t be acctive due to defines being turned off.
  14738. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14739. * @param samplersList The samplers list
  14740. * @param defines The defines helping in the list generation
  14741. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14742. */
  14743. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14744. /**
  14745. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14746. * @param defines The defines to update while falling back
  14747. * @param fallbacks The authorized effect fallbacks
  14748. * @param maxSimultaneousLights The maximum number of lights allowed
  14749. * @param rank the current rank of the Effect
  14750. * @returns The newly affected rank
  14751. */
  14752. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14753. /**
  14754. * Prepares the list of attributes required for morph targets according to the effect defines.
  14755. * @param attribs The current list of supported attribs
  14756. * @param mesh The mesh to prepare the morph targets attributes for
  14757. * @param defines The current Defines of the effect
  14758. */
  14759. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14760. /**
  14761. * Prepares the list of attributes required for bones according to the effect defines.
  14762. * @param attribs The current list of supported attribs
  14763. * @param mesh The mesh to prepare the bones attributes for
  14764. * @param defines The current Defines of the effect
  14765. * @param fallbacks The current efffect fallback strategy
  14766. */
  14767. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14768. /**
  14769. * Prepares the list of attributes required for instances according to the effect defines.
  14770. * @param attribs The current list of supported attribs
  14771. * @param defines The current Defines of the effect
  14772. */
  14773. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14774. /**
  14775. * Binds the light shadow information to the effect for the given mesh.
  14776. * @param light The light containing the generator
  14777. * @param scene The scene the lights belongs to
  14778. * @param mesh The mesh we are binding the information to render
  14779. * @param lightIndex The light index in the effect used to render the mesh
  14780. * @param effect The effect we are binding the data to
  14781. */
  14782. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14783. /**
  14784. * Binds the light information to the effect.
  14785. * @param light The light containing the generator
  14786. * @param effect The effect we are binding the data to
  14787. * @param lightIndex The light index in the effect used to render
  14788. */
  14789. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14790. /**
  14791. * Binds the lights information from the scene to the effect for the given mesh.
  14792. * @param scene The scene the lights belongs to
  14793. * @param mesh The mesh we are binding the information to render
  14794. * @param effect The effect we are binding the data to
  14795. * @param defines The generated defines for the effect
  14796. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14797. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14798. */
  14799. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14800. /**
  14801. * Binds the fog information from the scene to the effect for the given mesh.
  14802. * @param scene The scene the lights belongs to
  14803. * @param mesh The mesh we are binding the information to render
  14804. * @param effect The effect we are binding the data to
  14805. */
  14806. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14807. /**
  14808. * Binds the bones information from the mesh to the effect.
  14809. * @param mesh The mesh we are binding the information to render
  14810. * @param effect The effect we are binding the data to
  14811. */
  14812. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14813. /**
  14814. * Binds the morph targets information from the mesh to the effect.
  14815. * @param abstractMesh The mesh we are binding the information to render
  14816. * @param effect The effect we are binding the data to
  14817. */
  14818. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14819. /**
  14820. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14821. * @param defines The generated defines used in the effect
  14822. * @param effect The effect we are binding the data to
  14823. * @param scene The scene we are willing to render with logarithmic scale for
  14824. */
  14825. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14826. /**
  14827. * Binds the clip plane information from the scene to the effect.
  14828. * @param scene The scene the clip plane information are extracted from
  14829. * @param effect The effect we are binding the data to
  14830. */
  14831. static BindClipPlane(effect: Effect, scene: Scene): void;
  14832. }
  14833. }
  14834. declare module BABYLON {
  14835. class MultiMaterial extends Material {
  14836. private _subMaterials;
  14837. subMaterials: Nullable<Material>[];
  14838. constructor(name: string, scene: Scene);
  14839. private _hookArray;
  14840. getSubMaterial(index: number): Nullable<Material>;
  14841. getActiveTextures(): BaseTexture[];
  14842. getClassName(): string;
  14843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14844. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14845. serialize(): any;
  14846. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14847. }
  14848. }
  14849. declare module BABYLON {
  14850. class PushMaterial extends Material {
  14851. protected _activeEffect: Effect;
  14852. protected _normalMatrix: Matrix;
  14853. constructor(name: string, scene: Scene);
  14854. getEffect(): Effect;
  14855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14856. /**
  14857. * Binds the given world matrix to the active effect
  14858. *
  14859. * @param world the matrix to bind
  14860. */
  14861. bindOnlyWorldMatrix(world: Matrix): void;
  14862. /**
  14863. * Binds the given normal matrix to the active effect
  14864. *
  14865. * @param normalMatrix the matrix to bind
  14866. */
  14867. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14868. bind(world: Matrix, mesh?: Mesh): void;
  14869. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14870. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14871. }
  14872. }
  14873. declare module BABYLON {
  14874. class ShaderMaterial extends Material {
  14875. private _shaderPath;
  14876. private _options;
  14877. private _textures;
  14878. private _textureArrays;
  14879. private _floats;
  14880. private _ints;
  14881. private _floatsArrays;
  14882. private _colors3;
  14883. private _colors3Arrays;
  14884. private _colors4;
  14885. private _vectors2;
  14886. private _vectors3;
  14887. private _vectors4;
  14888. private _matrices;
  14889. private _matrices3x3;
  14890. private _matrices2x2;
  14891. private _vectors2Arrays;
  14892. private _vectors3Arrays;
  14893. private _cachedWorldViewMatrix;
  14894. private _renderId;
  14895. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14896. getClassName(): string;
  14897. needAlphaBlending(): boolean;
  14898. needAlphaTesting(): boolean;
  14899. private _checkUniform;
  14900. setTexture(name: string, texture: Texture): ShaderMaterial;
  14901. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14902. setFloat(name: string, value: number): ShaderMaterial;
  14903. setInt(name: string, value: number): ShaderMaterial;
  14904. setFloats(name: string, value: number[]): ShaderMaterial;
  14905. setColor3(name: string, value: Color3): ShaderMaterial;
  14906. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14907. setColor4(name: string, value: Color4): ShaderMaterial;
  14908. setVector2(name: string, value: Vector2): ShaderMaterial;
  14909. setVector3(name: string, value: Vector3): ShaderMaterial;
  14910. setVector4(name: string, value: Vector4): ShaderMaterial;
  14911. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14912. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14913. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14914. setArray2(name: string, value: number[]): ShaderMaterial;
  14915. setArray3(name: string, value: number[]): ShaderMaterial;
  14916. private _checkCache;
  14917. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14918. bindOnlyWorldMatrix(world: Matrix): void;
  14919. bind(world: Matrix, mesh?: Mesh): void;
  14920. getActiveTextures(): BaseTexture[];
  14921. hasTexture(texture: BaseTexture): boolean;
  14922. clone(name: string): ShaderMaterial;
  14923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14924. serialize(): any;
  14925. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14926. }
  14927. }
  14928. declare module BABYLON {
  14929. /** @hidden */
  14930. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14931. MAINUV1: boolean;
  14932. MAINUV2: boolean;
  14933. DIFFUSE: boolean;
  14934. DIFFUSEDIRECTUV: number;
  14935. AMBIENT: boolean;
  14936. AMBIENTDIRECTUV: number;
  14937. OPACITY: boolean;
  14938. OPACITYDIRECTUV: number;
  14939. OPACITYRGB: boolean;
  14940. REFLECTION: boolean;
  14941. EMISSIVE: boolean;
  14942. EMISSIVEDIRECTUV: number;
  14943. SPECULAR: boolean;
  14944. SPECULARDIRECTUV: number;
  14945. BUMP: boolean;
  14946. BUMPDIRECTUV: number;
  14947. PARALLAX: boolean;
  14948. PARALLAXOCCLUSION: boolean;
  14949. SPECULAROVERALPHA: boolean;
  14950. CLIPPLANE: boolean;
  14951. CLIPPLANE2: boolean;
  14952. CLIPPLANE3: boolean;
  14953. CLIPPLANE4: boolean;
  14954. ALPHATEST: boolean;
  14955. DEPTHPREPASS: boolean;
  14956. ALPHAFROMDIFFUSE: boolean;
  14957. POINTSIZE: boolean;
  14958. FOG: boolean;
  14959. SPECULARTERM: boolean;
  14960. DIFFUSEFRESNEL: boolean;
  14961. OPACITYFRESNEL: boolean;
  14962. REFLECTIONFRESNEL: boolean;
  14963. REFRACTIONFRESNEL: boolean;
  14964. EMISSIVEFRESNEL: boolean;
  14965. FRESNEL: boolean;
  14966. NORMAL: boolean;
  14967. UV1: boolean;
  14968. UV2: boolean;
  14969. VERTEXCOLOR: boolean;
  14970. VERTEXALPHA: boolean;
  14971. NUM_BONE_INFLUENCERS: number;
  14972. BonesPerMesh: number;
  14973. INSTANCES: boolean;
  14974. GLOSSINESS: boolean;
  14975. ROUGHNESS: boolean;
  14976. EMISSIVEASILLUMINATION: boolean;
  14977. LINKEMISSIVEWITHDIFFUSE: boolean;
  14978. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14979. LIGHTMAP: boolean;
  14980. LIGHTMAPDIRECTUV: number;
  14981. OBJECTSPACE_NORMALMAP: boolean;
  14982. USELIGHTMAPASSHADOWMAP: boolean;
  14983. REFLECTIONMAP_3D: boolean;
  14984. REFLECTIONMAP_SPHERICAL: boolean;
  14985. REFLECTIONMAP_PLANAR: boolean;
  14986. REFLECTIONMAP_CUBIC: boolean;
  14987. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14988. REFLECTIONMAP_PROJECTION: boolean;
  14989. REFLECTIONMAP_SKYBOX: boolean;
  14990. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  14991. REFLECTIONMAP_EXPLICIT: boolean;
  14992. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14993. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14994. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14995. INVERTCUBICMAP: boolean;
  14996. LOGARITHMICDEPTH: boolean;
  14997. REFRACTION: boolean;
  14998. REFRACTIONMAP_3D: boolean;
  14999. REFLECTIONOVERALPHA: boolean;
  15000. TWOSIDEDLIGHTING: boolean;
  15001. SHADOWFLOAT: boolean;
  15002. MORPHTARGETS: boolean;
  15003. MORPHTARGETS_NORMAL: boolean;
  15004. MORPHTARGETS_TANGENT: boolean;
  15005. NUM_MORPH_INFLUENCERS: number;
  15006. NONUNIFORMSCALING: boolean;
  15007. PREMULTIPLYALPHA: boolean;
  15008. IMAGEPROCESSING: boolean;
  15009. VIGNETTE: boolean;
  15010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15011. VIGNETTEBLENDMODEOPAQUE: boolean;
  15012. TONEMAPPING: boolean;
  15013. TONEMAPPING_ACES: boolean;
  15014. CONTRAST: boolean;
  15015. COLORCURVES: boolean;
  15016. COLORGRADING: boolean;
  15017. COLORGRADING3D: boolean;
  15018. SAMPLER3DGREENDEPTH: boolean;
  15019. SAMPLER3DBGRMAP: boolean;
  15020. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15021. /**
  15022. * If the reflection texture on this material is in linear color space
  15023. * @hidden
  15024. */
  15025. IS_REFLECTION_LINEAR: boolean;
  15026. /**
  15027. * If the refraction texture on this material is in linear color space
  15028. * @hidden
  15029. */
  15030. IS_REFRACTION_LINEAR: boolean;
  15031. EXPOSURE: boolean;
  15032. constructor();
  15033. setReflectionMode(modeToEnable: string): void;
  15034. }
  15035. class StandardMaterial extends PushMaterial {
  15036. private _diffuseTexture;
  15037. diffuseTexture: Nullable<BaseTexture>;
  15038. private _ambientTexture;
  15039. ambientTexture: Nullable<BaseTexture>;
  15040. private _opacityTexture;
  15041. opacityTexture: Nullable<BaseTexture>;
  15042. private _reflectionTexture;
  15043. reflectionTexture: Nullable<BaseTexture>;
  15044. private _emissiveTexture;
  15045. emissiveTexture: Nullable<BaseTexture>;
  15046. private _specularTexture;
  15047. specularTexture: Nullable<BaseTexture>;
  15048. private _bumpTexture;
  15049. bumpTexture: Nullable<BaseTexture>;
  15050. private _lightmapTexture;
  15051. lightmapTexture: Nullable<BaseTexture>;
  15052. private _refractionTexture;
  15053. refractionTexture: Nullable<BaseTexture>;
  15054. ambientColor: Color3;
  15055. diffuseColor: Color3;
  15056. specularColor: Color3;
  15057. emissiveColor: Color3;
  15058. specularPower: number;
  15059. private _useAlphaFromDiffuseTexture;
  15060. useAlphaFromDiffuseTexture: boolean;
  15061. private _useEmissiveAsIllumination;
  15062. useEmissiveAsIllumination: boolean;
  15063. private _linkEmissiveWithDiffuse;
  15064. linkEmissiveWithDiffuse: boolean;
  15065. private _useSpecularOverAlpha;
  15066. useSpecularOverAlpha: boolean;
  15067. private _useReflectionOverAlpha;
  15068. useReflectionOverAlpha: boolean;
  15069. private _disableLighting;
  15070. disableLighting: boolean;
  15071. private _useObjectSpaceNormalMap;
  15072. /**
  15073. * Allows using an object space normal map (instead of tangent space).
  15074. */
  15075. useObjectSpaceNormalMap: boolean;
  15076. private _useParallax;
  15077. useParallax: boolean;
  15078. private _useParallaxOcclusion;
  15079. useParallaxOcclusion: boolean;
  15080. parallaxScaleBias: number;
  15081. private _roughness;
  15082. roughness: number;
  15083. indexOfRefraction: number;
  15084. invertRefractionY: boolean;
  15085. /**
  15086. * Defines the alpha limits in alpha test mode
  15087. */
  15088. alphaCutOff: number;
  15089. private _useLightmapAsShadowmap;
  15090. useLightmapAsShadowmap: boolean;
  15091. private _diffuseFresnelParameters;
  15092. diffuseFresnelParameters: FresnelParameters;
  15093. private _opacityFresnelParameters;
  15094. opacityFresnelParameters: FresnelParameters;
  15095. private _reflectionFresnelParameters;
  15096. reflectionFresnelParameters: FresnelParameters;
  15097. private _refractionFresnelParameters;
  15098. refractionFresnelParameters: FresnelParameters;
  15099. private _emissiveFresnelParameters;
  15100. emissiveFresnelParameters: FresnelParameters;
  15101. private _useReflectionFresnelFromSpecular;
  15102. useReflectionFresnelFromSpecular: boolean;
  15103. private _useGlossinessFromSpecularMapAlpha;
  15104. useGlossinessFromSpecularMapAlpha: boolean;
  15105. private _maxSimultaneousLights;
  15106. maxSimultaneousLights: number;
  15107. /**
  15108. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15109. */
  15110. private _invertNormalMapX;
  15111. invertNormalMapX: boolean;
  15112. /**
  15113. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15114. */
  15115. private _invertNormalMapY;
  15116. invertNormalMapY: boolean;
  15117. /**
  15118. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15119. */
  15120. private _twoSidedLighting;
  15121. twoSidedLighting: boolean;
  15122. /**
  15123. * Default configuration related to image processing available in the standard Material.
  15124. */
  15125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15126. /**
  15127. * Gets the image processing configuration used either in this material.
  15128. */
  15129. /**
  15130. * Sets the Default image processing configuration used either in the this material.
  15131. *
  15132. * If sets to null, the scene one is in use.
  15133. */
  15134. imageProcessingConfiguration: ImageProcessingConfiguration;
  15135. /**
  15136. * Keep track of the image processing observer to allow dispose and replace.
  15137. */
  15138. private _imageProcessingObserver;
  15139. /**
  15140. * Attaches a new image processing configuration to the Standard Material.
  15141. * @param configuration
  15142. */
  15143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15144. /**
  15145. * Gets wether the color curves effect is enabled.
  15146. */
  15147. /**
  15148. * Sets wether the color curves effect is enabled.
  15149. */
  15150. cameraColorCurvesEnabled: boolean;
  15151. /**
  15152. * Gets wether the color grading effect is enabled.
  15153. */
  15154. /**
  15155. * Gets wether the color grading effect is enabled.
  15156. */
  15157. cameraColorGradingEnabled: boolean;
  15158. /**
  15159. * Gets wether tonemapping is enabled or not.
  15160. */
  15161. /**
  15162. * Sets wether tonemapping is enabled or not
  15163. */
  15164. cameraToneMappingEnabled: boolean;
  15165. /**
  15166. * The camera exposure used on this material.
  15167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15168. * This corresponds to a photographic exposure.
  15169. */
  15170. /**
  15171. * The camera exposure used on this material.
  15172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15173. * This corresponds to a photographic exposure.
  15174. */
  15175. cameraExposure: number;
  15176. /**
  15177. * Gets The camera contrast used on this material.
  15178. */
  15179. /**
  15180. * Sets The camera contrast used on this material.
  15181. */
  15182. cameraContrast: number;
  15183. /**
  15184. * Gets the Color Grading 2D Lookup Texture.
  15185. */
  15186. /**
  15187. * Sets the Color Grading 2D Lookup Texture.
  15188. */
  15189. cameraColorGradingTexture: Nullable<BaseTexture>;
  15190. /**
  15191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15193. * 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;
  15194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15195. */
  15196. /**
  15197. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15198. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15199. * 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;
  15200. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15201. */
  15202. cameraColorCurves: Nullable<ColorCurves>;
  15203. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15204. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15205. protected _worldViewProjectionMatrix: Matrix;
  15206. protected _globalAmbientColor: Color3;
  15207. protected _useLogarithmicDepth: boolean;
  15208. constructor(name: string, scene: Scene);
  15209. getClassName(): string;
  15210. useLogarithmicDepth: boolean;
  15211. needAlphaBlending(): boolean;
  15212. needAlphaTesting(): boolean;
  15213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15214. getAlphaTestTexture(): Nullable<BaseTexture>;
  15215. /**
  15216. * Child classes can use it to update shaders
  15217. */
  15218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15219. buildUniformLayout(): void;
  15220. unbind(): void;
  15221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15222. getAnimatables(): IAnimatable[];
  15223. getActiveTextures(): BaseTexture[];
  15224. hasTexture(texture: BaseTexture): boolean;
  15225. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15226. clone(name: string): StandardMaterial;
  15227. serialize(): any;
  15228. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15229. private static _DiffuseTextureEnabled: boolean;
  15230. static DiffuseTextureEnabled: boolean;
  15231. private static _AmbientTextureEnabled: boolean;
  15232. static AmbientTextureEnabled: boolean;
  15233. private static _OpacityTextureEnabled: boolean;
  15234. static OpacityTextureEnabled: boolean;
  15235. private static _ReflectionTextureEnabled: boolean;
  15236. static ReflectionTextureEnabled: boolean;
  15237. private static _EmissiveTextureEnabled: boolean;
  15238. static EmissiveTextureEnabled: boolean;
  15239. private static _SpecularTextureEnabled: boolean;
  15240. static SpecularTextureEnabled: boolean;
  15241. private static _BumpTextureEnabled: boolean;
  15242. static BumpTextureEnabled: boolean;
  15243. private static _LightmapTextureEnabled: boolean;
  15244. static LightmapTextureEnabled: boolean;
  15245. private static _RefractionTextureEnabled: boolean;
  15246. static RefractionTextureEnabled: boolean;
  15247. private static _ColorGradingTextureEnabled: boolean;
  15248. static ColorGradingTextureEnabled: boolean;
  15249. private static _FresnelEnabled: boolean;
  15250. static FresnelEnabled: boolean;
  15251. }
  15252. }
  15253. declare module BABYLON {
  15254. class UniformBuffer {
  15255. private _engine;
  15256. private _buffer;
  15257. private _data;
  15258. private _bufferData;
  15259. private _dynamic?;
  15260. private _uniformLocations;
  15261. private _uniformSizes;
  15262. private _uniformLocationPointer;
  15263. private _needSync;
  15264. private _noUBO;
  15265. private _currentEffect;
  15266. private static _MAX_UNIFORM_SIZE;
  15267. private static _tempBuffer;
  15268. /**
  15269. * Wrapper for updateUniform.
  15270. * @method updateMatrix3x3
  15271. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15272. * @param {Float32Array} matrix
  15273. */
  15274. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15275. /**
  15276. * Wrapper for updateUniform.
  15277. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15278. * @param {Float32Array} matrix
  15279. */
  15280. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15281. /**
  15282. * Wrapper for updateUniform.
  15283. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15284. * @param {number} x
  15285. */
  15286. updateFloat: (name: string, x: number) => void;
  15287. /**
  15288. * Wrapper for updateUniform.
  15289. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15290. * @param {number} x
  15291. * @param {number} y
  15292. * @param {string} [suffix] Suffix to add to the uniform name.
  15293. */
  15294. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15295. /**
  15296. * Wrapper for updateUniform.
  15297. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15298. * @param {number} x
  15299. * @param {number} y
  15300. * @param {number} z
  15301. * @param {string} [suffix] Suffix to add to the uniform name.
  15302. */
  15303. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15304. /**
  15305. * Wrapper for updateUniform.
  15306. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15307. * @param {number} x
  15308. * @param {number} y
  15309. * @param {number} z
  15310. * @param {number} w
  15311. * @param {string} [suffix] Suffix to add to the uniform name.
  15312. */
  15313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15314. /**
  15315. * Wrapper for updateUniform.
  15316. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15317. * @param {Matrix} A 4x4 matrix.
  15318. */
  15319. updateMatrix: (name: string, mat: Matrix) => void;
  15320. /**
  15321. * Wrapper for updateUniform.
  15322. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15323. * @param {Vector3} vector
  15324. */
  15325. updateVector3: (name: string, vector: Vector3) => void;
  15326. /**
  15327. * Wrapper for updateUniform.
  15328. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15329. * @param {Vector4} vector
  15330. */
  15331. updateVector4: (name: string, vector: Vector4) => void;
  15332. /**
  15333. * Wrapper for updateUniform.
  15334. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15335. * @param {Color3} color
  15336. * @param {string} [suffix] Suffix to add to the uniform name.
  15337. */
  15338. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15339. /**
  15340. * Wrapper for updateUniform.
  15341. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15342. * @param {Color3} color
  15343. * @param {number} alpha
  15344. * @param {string} [suffix] Suffix to add to the uniform name.
  15345. */
  15346. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15347. /**
  15348. * Uniform buffer objects.
  15349. *
  15350. * Handles blocks of uniform on the GPU.
  15351. *
  15352. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15353. *
  15354. * For more information, please refer to :
  15355. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15356. */
  15357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15358. /**
  15359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15360. * or just falling back on setUniformXXX calls.
  15361. */
  15362. readonly useUbo: boolean;
  15363. /**
  15364. * Indicates if the WebGL underlying uniform buffer is in sync
  15365. * with the javascript cache data.
  15366. */
  15367. readonly isSync: boolean;
  15368. /**
  15369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15370. * Also, a dynamic UniformBuffer will disable cache verification and always
  15371. * update the underlying WebGL uniform buffer to the GPU.
  15372. */
  15373. isDynamic(): boolean;
  15374. /**
  15375. * The data cache on JS side.
  15376. */
  15377. getData(): Float32Array;
  15378. /**
  15379. * The underlying WebGL Uniform buffer.
  15380. */
  15381. getBuffer(): Nullable<WebGLBuffer>;
  15382. /**
  15383. * std140 layout specifies how to align data within an UBO structure.
  15384. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15385. * for specs.
  15386. */
  15387. private _fillAlignment;
  15388. /**
  15389. * Adds an uniform in the buffer.
  15390. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15391. * for the layout to be correct !
  15392. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15393. * @param {number|number[]} size Data size, or data directly.
  15394. */
  15395. addUniform(name: string, size: number | number[]): void;
  15396. /**
  15397. * Wrapper for addUniform.
  15398. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15399. * @param {Matrix} mat A 4x4 matrix.
  15400. */
  15401. addMatrix(name: string, mat: Matrix): void;
  15402. /**
  15403. * Wrapper for addUniform.
  15404. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15405. * @param {number} x
  15406. * @param {number} y
  15407. */
  15408. addFloat2(name: string, x: number, y: number): void;
  15409. /**
  15410. * Wrapper for addUniform.
  15411. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15412. * @param {number} x
  15413. * @param {number} y
  15414. * @param {number} z
  15415. */
  15416. addFloat3(name: string, x: number, y: number, z: number): void;
  15417. /**
  15418. * Wrapper for addUniform.
  15419. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15420. * @param {Color3} color
  15421. */
  15422. addColor3(name: string, color: Color3): void;
  15423. /**
  15424. * Wrapper for addUniform.
  15425. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15426. * @param {Color3} color
  15427. * @param {number} alpha
  15428. */
  15429. addColor4(name: string, color: Color3, alpha: number): void;
  15430. /**
  15431. * Wrapper for addUniform.
  15432. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15433. * @param {Vector3} vector
  15434. */
  15435. addVector3(name: string, vector: Vector3): void;
  15436. /**
  15437. * Wrapper for addUniform.
  15438. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15439. */
  15440. addMatrix3x3(name: string): void;
  15441. /**
  15442. * Wrapper for addUniform.
  15443. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15444. */
  15445. addMatrix2x2(name: string): void;
  15446. /**
  15447. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15448. */
  15449. create(): void;
  15450. /** @hidden */
  15451. /**
  15452. * Updates the WebGL Uniform Buffer on the GPU.
  15453. * If the `dynamic` flag is set to true, no cache comparison is done.
  15454. * Otherwise, the buffer will be updated only if the cache differs.
  15455. */
  15456. update(): void;
  15457. /**
  15458. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15459. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15460. * @param {number[]|Float32Array} data Flattened data
  15461. * @param {number} size Size of the data.
  15462. */
  15463. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15464. private _updateMatrix3x3ForUniform;
  15465. private _updateMatrix3x3ForEffect;
  15466. private _updateMatrix2x2ForEffect;
  15467. private _updateMatrix2x2ForUniform;
  15468. private _updateFloatForEffect;
  15469. private _updateFloatForUniform;
  15470. private _updateFloat2ForEffect;
  15471. private _updateFloat2ForUniform;
  15472. private _updateFloat3ForEffect;
  15473. private _updateFloat3ForUniform;
  15474. private _updateFloat4ForEffect;
  15475. private _updateFloat4ForUniform;
  15476. private _updateMatrixForEffect;
  15477. private _updateMatrixForUniform;
  15478. private _updateVector3ForEffect;
  15479. private _updateVector3ForUniform;
  15480. private _updateVector4ForEffect;
  15481. private _updateVector4ForUniform;
  15482. private _updateColor3ForEffect;
  15483. private _updateColor3ForUniform;
  15484. private _updateColor4ForEffect;
  15485. private _updateColor4ForUniform;
  15486. /**
  15487. * Sets a sampler uniform on the effect.
  15488. * @param {string} name Name of the sampler.
  15489. * @param {Texture} texture
  15490. */
  15491. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15492. /**
  15493. * Directly updates the value of the uniform in the cache AND on the GPU.
  15494. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15495. * @param {number[]|Float32Array} data Flattened data
  15496. */
  15497. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15498. /**
  15499. * Binds this uniform buffer to an effect.
  15500. * @param {Effect} effect
  15501. * @param {string} name Name of the uniform block in the shader.
  15502. */
  15503. bindToEffect(effect: Effect, name: string): void;
  15504. /**
  15505. * Disposes the uniform buffer.
  15506. */
  15507. dispose(): void;
  15508. }
  15509. }
  15510. declare module BABYLON {
  15511. class Scalar {
  15512. /**
  15513. * Two pi constants convenient for computation.
  15514. */
  15515. static TwoPi: number;
  15516. /**
  15517. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15518. */
  15519. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15520. /**
  15521. * Returns a string : the upper case translation of the number i to hexadecimal.
  15522. */
  15523. static ToHex(i: number): string;
  15524. /**
  15525. * Returns -1 if value is negative and +1 is value is positive.
  15526. * Returns the value itself if it's equal to zero.
  15527. */
  15528. static Sign(value: number): number;
  15529. /**
  15530. * Returns the value itself if it's between min and max.
  15531. * Returns min if the value is lower than min.
  15532. * Returns max if the value is greater than max.
  15533. */
  15534. static Clamp(value: number, min?: number, max?: number): number;
  15535. /**
  15536. * Returns the log2 of value.
  15537. */
  15538. static Log2(value: number): number;
  15539. /**
  15540. * Loops the value, so that it is never larger than length and never smaller than 0.
  15541. *
  15542. * This is similar to the modulo operator but it works with floating point numbers.
  15543. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15544. * With t = 5 and length = 2.5, the result would be 0.0.
  15545. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15546. */
  15547. static Repeat(value: number, length: number): number;
  15548. /**
  15549. * Normalize the value between 0.0 and 1.0 using min and max values
  15550. */
  15551. static Normalize(value: number, min: number, max: number): number;
  15552. /**
  15553. * Denormalize the value from 0.0 and 1.0 using min and max values
  15554. */
  15555. static Denormalize(normalized: number, min: number, max: number): number;
  15556. /**
  15557. * Calculates the shortest difference between two given angles given in degrees.
  15558. */
  15559. static DeltaAngle(current: number, target: number): number;
  15560. /**
  15561. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15562. *
  15563. * The returned value will move back and forth between 0 and length
  15564. */
  15565. static PingPong(tx: number, length: number): number;
  15566. /**
  15567. * Interpolates between min and max with smoothing at the limits.
  15568. *
  15569. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15570. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15571. */
  15572. static SmoothStep(from: number, to: number, tx: number): number;
  15573. /**
  15574. * Moves a value current towards target.
  15575. *
  15576. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15577. * Negative values of maxDelta pushes the value away from target.
  15578. */
  15579. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15580. /**
  15581. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15582. *
  15583. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15584. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15585. */
  15586. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15587. /**
  15588. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15589. */
  15590. static Lerp(start: number, end: number, amount: number): number;
  15591. /**
  15592. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15593. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15594. */
  15595. static LerpAngle(start: number, end: number, amount: number): number;
  15596. /**
  15597. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15598. */
  15599. static InverseLerp(a: number, b: number, value: number): number;
  15600. /**
  15601. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15602. */
  15603. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15604. /**
  15605. * Returns a random float number between and min and max values
  15606. */
  15607. static RandomRange(min: number, max: number): number;
  15608. /**
  15609. * This function returns percentage of a number in a given range.
  15610. *
  15611. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15612. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15613. */
  15614. static RangeToPercent(number: number, min: number, max: number): number;
  15615. /**
  15616. * This function returns number that corresponds to the percentage in a given range.
  15617. *
  15618. * PercentToRange(0.34,0,100) will return 34.
  15619. */
  15620. static PercentToRange(percent: number, min: number, max: number): number;
  15621. /**
  15622. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15623. * @param angle The angle to normalize in radian.
  15624. * @return The converted angle.
  15625. */
  15626. static NormalizeRadians(angle: number): number;
  15627. }
  15628. }
  15629. declare module BABYLON {
  15630. const ToGammaSpace: number;
  15631. const ToLinearSpace = 2.2;
  15632. const Epsilon = 0.001;
  15633. /**
  15634. * Class used to hold a RBG color
  15635. */
  15636. class Color3 {
  15637. /**
  15638. * Defines the red component (between 0 and 1, default is 0)
  15639. */
  15640. r: number;
  15641. /**
  15642. * Defines the green component (between 0 and 1, default is 0)
  15643. */
  15644. g: number;
  15645. /**
  15646. * Defines the blue component (between 0 and 1, default is 0)
  15647. */
  15648. b: number;
  15649. /**
  15650. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15651. * @param r defines the red component (between 0 and 1, default is 0)
  15652. * @param g defines the green component (between 0 and 1, default is 0)
  15653. * @param b defines the blue component (between 0 and 1, default is 0)
  15654. */
  15655. constructor(
  15656. /**
  15657. * Defines the red component (between 0 and 1, default is 0)
  15658. */
  15659. r?: number,
  15660. /**
  15661. * Defines the green component (between 0 and 1, default is 0)
  15662. */
  15663. g?: number,
  15664. /**
  15665. * Defines the blue component (between 0 and 1, default is 0)
  15666. */
  15667. b?: number);
  15668. /**
  15669. * Creates a string with the Color3 current values
  15670. * @returns the string representation of the Color3 object
  15671. */
  15672. toString(): string;
  15673. /**
  15674. * Returns the string "Color3"
  15675. * @returns "Color3"
  15676. */
  15677. getClassName(): string;
  15678. /**
  15679. * Compute the Color3 hash code
  15680. * @returns an unique number that can be used to hash Color3 objects
  15681. */
  15682. getHashCode(): number;
  15683. /**
  15684. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15685. * @param array defines the array where to store the r,g,b components
  15686. * @param index defines an optional index in the target array to define where to start storing values
  15687. * @returns the current Color3 object
  15688. */
  15689. toArray(array: FloatArray, index?: number): Color3;
  15690. /**
  15691. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15692. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15693. * @returns a new {BABYLON.Color4} object
  15694. */
  15695. toColor4(alpha?: number): Color4;
  15696. /**
  15697. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15698. * @returns the new array
  15699. */
  15700. asArray(): number[];
  15701. /**
  15702. * Returns the luminance value
  15703. * @returns a float value
  15704. */
  15705. toLuminance(): number;
  15706. /**
  15707. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15708. * @param otherColor defines the second operand
  15709. * @returns the new Color3 object
  15710. */
  15711. multiply(otherColor: Color3): Color3;
  15712. /**
  15713. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15714. * @param otherColor defines the second operand
  15715. * @param result defines the Color3 object where to store the result
  15716. * @returns the current Color3
  15717. */
  15718. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15719. /**
  15720. * Determines equality between Color3 objects
  15721. * @param otherColor defines the second operand
  15722. * @returns true if the rgb values are equal to the given ones
  15723. */
  15724. equals(otherColor: Color3): boolean;
  15725. /**
  15726. * Determines equality between the current Color3 object and a set of r,b,g values
  15727. * @param r defines the red component to check
  15728. * @param g defines the green component to check
  15729. * @param b defines the blue component to check
  15730. * @returns true if the rgb values are equal to the given ones
  15731. */
  15732. equalsFloats(r: number, g: number, b: number): boolean;
  15733. /**
  15734. * Multiplies in place each rgb value by scale
  15735. * @param scale defines the scaling factor
  15736. * @returns the updated Color3
  15737. */
  15738. scale(scale: number): Color3;
  15739. /**
  15740. * Multiplies the rgb values by scale and stores the result into "result"
  15741. * @param scale defines the scaling factor
  15742. * @param result defines the Color3 object where to store the result
  15743. * @returns the unmodified current Color3
  15744. */
  15745. scaleToRef(scale: number, result: Color3): Color3;
  15746. /**
  15747. * Scale the current Color3 values by a factor and add the result to a given Color3
  15748. * @param scale defines the scale factor
  15749. * @param result defines color to store the result into
  15750. * @returns the unmodified current Color3
  15751. */
  15752. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15753. /**
  15754. * Clamps the rgb values by the min and max values and stores the result into "result"
  15755. * @param min defines minimum clamping value (default is 0)
  15756. * @param max defines maximum clamping value (default is 1)
  15757. * @param result defines color to store the result into
  15758. * @returns the original Color3
  15759. */
  15760. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15761. /**
  15762. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15763. * @param otherColor defines the second operand
  15764. * @returns the new Color3
  15765. */
  15766. add(otherColor: Color3): Color3;
  15767. /**
  15768. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15769. * @param otherColor defines the second operand
  15770. * @param result defines Color3 object to store the result into
  15771. * @returns the unmodified current Color3
  15772. */
  15773. addToRef(otherColor: Color3, result: Color3): Color3;
  15774. /**
  15775. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15776. * @param otherColor defines the second operand
  15777. * @returns the new Color3
  15778. */
  15779. subtract(otherColor: Color3): Color3;
  15780. /**
  15781. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15782. * @param otherColor defines the second operand
  15783. * @param result defines Color3 object to store the result into
  15784. * @returns the unmodified current Color3
  15785. */
  15786. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15787. /**
  15788. * Copy the current object
  15789. * @returns a new Color3 copied the current one
  15790. */
  15791. clone(): Color3;
  15792. /**
  15793. * Copies the rgb values from the source in the current Color3
  15794. * @param source defines the source Color3 object
  15795. * @returns the updated Color3 object
  15796. */
  15797. copyFrom(source: Color3): Color3;
  15798. /**
  15799. * Updates the Color3 rgb values from the given floats
  15800. * @param r defines the red component to read from
  15801. * @param g defines the green component to read from
  15802. * @param b defines the blue component to read from
  15803. * @returns the current Color3 object
  15804. */
  15805. copyFromFloats(r: number, g: number, b: number): Color3;
  15806. /**
  15807. * Updates the Color3 rgb values from the given floats
  15808. * @param r defines the red component to read from
  15809. * @param g defines the green component to read from
  15810. * @param b defines the blue component to read from
  15811. * @returns the current Color3 object
  15812. */
  15813. set(r: number, g: number, b: number): Color3;
  15814. /**
  15815. * Compute the Color3 hexadecimal code as a string
  15816. * @returns a string containing the hexadecimal representation of the Color3 object
  15817. */
  15818. toHexString(): string;
  15819. /**
  15820. * Computes a new Color3 converted from the current one to linear space
  15821. * @returns a new Color3 object
  15822. */
  15823. toLinearSpace(): Color3;
  15824. /**
  15825. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15826. * @param convertedColor defines the Color3 object where to store the linear space version
  15827. * @returns the unmodified Color3
  15828. */
  15829. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15830. /**
  15831. * Computes a new Color3 converted from the current one to gamma space
  15832. * @returns a new Color3 object
  15833. */
  15834. toGammaSpace(): Color3;
  15835. /**
  15836. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15837. * @param convertedColor defines the Color3 object where to store the gamma space version
  15838. * @returns the unmodified Color3
  15839. */
  15840. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15841. /**
  15842. * Creates a new Color3 from the string containing valid hexadecimal values
  15843. * @param hex defines a string containing valid hexadecimal values
  15844. * @returns a new Color3 object
  15845. */
  15846. static FromHexString(hex: string): Color3;
  15847. /**
  15848. * Creates a new Vector3 from the starting index of the given array
  15849. * @param array defines the source array
  15850. * @param offset defines an offset in the source array
  15851. * @returns a new Color3 object
  15852. */
  15853. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15854. /**
  15855. * Creates a new Color3 from integer values (< 256)
  15856. * @param r defines the red component to read from (value between 0 and 255)
  15857. * @param g defines the green component to read from (value between 0 and 255)
  15858. * @param b defines the blue component to read from (value between 0 and 255)
  15859. * @returns a new Color3 object
  15860. */
  15861. static FromInts(r: number, g: number, b: number): Color3;
  15862. /**
  15863. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15864. * @param start defines the start Color3 value
  15865. * @param end defines the end Color3 value
  15866. * @param amount defines the gradient value between start and end
  15867. * @returns a new Color3 object
  15868. */
  15869. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15870. /**
  15871. * Returns a Color3 value containing a red color
  15872. * @returns a new Color3 object
  15873. */
  15874. static Red(): Color3;
  15875. /**
  15876. * Returns a Color3 value containing a green color
  15877. * @returns a new Color3 object
  15878. */
  15879. static Green(): Color3;
  15880. /**
  15881. * Returns a Color3 value containing a blue color
  15882. * @returns a new Color3 object
  15883. */
  15884. static Blue(): Color3;
  15885. /**
  15886. * Returns a Color3 value containing a black color
  15887. * @returns a new Color3 object
  15888. */
  15889. static Black(): Color3;
  15890. /**
  15891. * Returns a Color3 value containing a white color
  15892. * @returns a new Color3 object
  15893. */
  15894. static White(): Color3;
  15895. /**
  15896. * Returns a Color3 value containing a purple color
  15897. * @returns a new Color3 object
  15898. */
  15899. static Purple(): Color3;
  15900. /**
  15901. * Returns a Color3 value containing a magenta color
  15902. * @returns a new Color3 object
  15903. */
  15904. static Magenta(): Color3;
  15905. /**
  15906. * Returns a Color3 value containing a yellow color
  15907. * @returns a new Color3 object
  15908. */
  15909. static Yellow(): Color3;
  15910. /**
  15911. * Returns a Color3 value containing a gray color
  15912. * @returns a new Color3 object
  15913. */
  15914. static Gray(): Color3;
  15915. /**
  15916. * Returns a Color3 value containing a teal color
  15917. * @returns a new Color3 object
  15918. */
  15919. static Teal(): Color3;
  15920. /**
  15921. * Returns a Color3 value containing a random color
  15922. * @returns a new Color3 object
  15923. */
  15924. static Random(): Color3;
  15925. }
  15926. /**
  15927. * Class used to hold a RBGA color
  15928. */
  15929. class Color4 {
  15930. /**
  15931. * Defines the red component (between 0 and 1, default is 0)
  15932. */
  15933. r: number;
  15934. /**
  15935. * Defines the green component (between 0 and 1, default is 0)
  15936. */
  15937. g: number;
  15938. /**
  15939. * Defines the blue component (between 0 and 1, default is 0)
  15940. */
  15941. b: number;
  15942. /**
  15943. * Defines the alpha component (between 0 and 1, default is 1)
  15944. */
  15945. a: number;
  15946. /**
  15947. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15948. * @param r defines the red component (between 0 and 1, default is 0)
  15949. * @param g defines the green component (between 0 and 1, default is 0)
  15950. * @param b defines the blue component (between 0 and 1, default is 0)
  15951. * @param a defines the alpha component (between 0 and 1, default is 1)
  15952. */
  15953. constructor(
  15954. /**
  15955. * Defines the red component (between 0 and 1, default is 0)
  15956. */
  15957. r?: number,
  15958. /**
  15959. * Defines the green component (between 0 and 1, default is 0)
  15960. */
  15961. g?: number,
  15962. /**
  15963. * Defines the blue component (between 0 and 1, default is 0)
  15964. */
  15965. b?: number,
  15966. /**
  15967. * Defines the alpha component (between 0 and 1, default is 1)
  15968. */
  15969. a?: number);
  15970. /**
  15971. * Adds in place the given Color4 values to the current Color4 object
  15972. * @param right defines the second operand
  15973. * @returns the current updated Color4 object
  15974. */
  15975. addInPlace(right: Color4): Color4;
  15976. /**
  15977. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15978. * @returns the new array
  15979. */
  15980. asArray(): number[];
  15981. /**
  15982. * Stores from the starting index in the given array the Color4 successive values
  15983. * @param array defines the array where to store the r,g,b components
  15984. * @param index defines an optional index in the target array to define where to start storing values
  15985. * @returns the current Color4 object
  15986. */
  15987. toArray(array: number[], index?: number): Color4;
  15988. /**
  15989. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15990. * @param right defines the second operand
  15991. * @returns a new Color4 object
  15992. */
  15993. add(right: Color4): Color4;
  15994. /**
  15995. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15996. * @param right defines the second operand
  15997. * @returns a new Color4 object
  15998. */
  15999. subtract(right: Color4): Color4;
  16000. /**
  16001. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16002. * @param right defines the second operand
  16003. * @param result defines the Color4 object where to store the result
  16004. * @returns the current Color4 object
  16005. */
  16006. subtractToRef(right: Color4, result: Color4): Color4;
  16007. /**
  16008. * Creates a new Color4 with the current Color4 values multiplied by scale
  16009. * @param scale defines the scaling factor to apply
  16010. * @returns a new Color4 object
  16011. */
  16012. scale(scale: number): Color4;
  16013. /**
  16014. * Multiplies the current Color4 values by scale and stores the result in "result"
  16015. * @param scale defines the scaling factor to apply
  16016. * @param result defines the Color4 object where to store the result
  16017. * @returns the current unmodified Color4
  16018. */
  16019. scaleToRef(scale: number, result: Color4): Color4;
  16020. /**
  16021. * Scale the current Color4 values by a factor and add the result to a given Color4
  16022. * @param scale defines the scale factor
  16023. * @param result defines the Color4 object where to store the result
  16024. * @returns the unmodified current Color4
  16025. */
  16026. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16027. /**
  16028. * Clamps the rgb values by the min and max values and stores the result into "result"
  16029. * @param min defines minimum clamping value (default is 0)
  16030. * @param max defines maximum clamping value (default is 1)
  16031. * @param result defines color to store the result into.
  16032. * @returns the cuurent Color4
  16033. */
  16034. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16035. /**
  16036. * Multipy an Color4 value by another and return a new Color4 object
  16037. * @param color defines the Color4 value to multiply by
  16038. * @returns a new Color4 object
  16039. */
  16040. multiply(color: Color4): Color4;
  16041. /**
  16042. * Multipy a Color4 value by another and push the result in a reference value
  16043. * @param color defines the Color4 value to multiply by
  16044. * @param result defines the Color4 to fill the result in
  16045. * @returns the result Color4
  16046. */
  16047. multiplyToRef(color: Color4, result: Color4): Color4;
  16048. /**
  16049. * Creates a string with the Color4 current values
  16050. * @returns the string representation of the Color4 object
  16051. */
  16052. toString(): string;
  16053. /**
  16054. * Returns the string "Color4"
  16055. * @returns "Color4"
  16056. */
  16057. getClassName(): string;
  16058. /**
  16059. * Compute the Color4 hash code
  16060. * @returns an unique number that can be used to hash Color4 objects
  16061. */
  16062. getHashCode(): number;
  16063. /**
  16064. * Creates a new Color4 copied from the current one
  16065. * @returns a new Color4 object
  16066. */
  16067. clone(): Color4;
  16068. /**
  16069. * Copies the given Color4 values into the current one
  16070. * @param source defines the source Color4 object
  16071. * @returns the current updated Color4 object
  16072. */
  16073. copyFrom(source: Color4): Color4;
  16074. /**
  16075. * Copies the given float values into the current one
  16076. * @param r defines the red component to read from
  16077. * @param g defines the green component to read from
  16078. * @param b defines the blue component to read from
  16079. * @param a defines the alpha component to read from
  16080. * @returns the current updated Color4 object
  16081. */
  16082. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16083. /**
  16084. * Copies the given float values into the current one
  16085. * @param r defines the red component to read from
  16086. * @param g defines the green component to read from
  16087. * @param b defines the blue component to read from
  16088. * @param a defines the alpha component to read from
  16089. * @returns the current updated Color4 object
  16090. */
  16091. set(r: number, g: number, b: number, a: number): Color4;
  16092. /**
  16093. * Compute the Color4 hexadecimal code as a string
  16094. * @returns a string containing the hexadecimal representation of the Color4 object
  16095. */
  16096. toHexString(): string;
  16097. /**
  16098. * Computes a new Color4 converted from the current one to linear space
  16099. * @returns a new Color4 object
  16100. */
  16101. toLinearSpace(): Color4;
  16102. /**
  16103. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16104. * @param convertedColor defines the Color4 object where to store the linear space version
  16105. * @returns the unmodified Color4
  16106. */
  16107. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16108. /**
  16109. * Computes a new Color4 converted from the current one to gamma space
  16110. * @returns a new Color4 object
  16111. */
  16112. toGammaSpace(): Color4;
  16113. /**
  16114. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16115. * @param convertedColor defines the Color4 object where to store the gamma space version
  16116. * @returns the unmodified Color4
  16117. */
  16118. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16119. /**
  16120. * Creates a new Color4 from the string containing valid hexadecimal values
  16121. * @param hex defines a string containing valid hexadecimal values
  16122. * @returns a new Color4 object
  16123. */
  16124. static FromHexString(hex: string): Color4;
  16125. /**
  16126. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16127. * @param left defines the start value
  16128. * @param right defines the end value
  16129. * @param amount defines the gradient factor
  16130. * @returns a new Color4 object
  16131. */
  16132. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16133. /**
  16134. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16135. * @param left defines the start value
  16136. * @param right defines the end value
  16137. * @param amount defines the gradient factor
  16138. * @param result defines the Color4 object where to store data
  16139. */
  16140. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16141. /**
  16142. * Creates a new Color4 from the starting index element of the given array
  16143. * @param array defines the source array to read from
  16144. * @param offset defines the offset in the source array
  16145. * @returns a new Color4 object
  16146. */
  16147. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16148. /**
  16149. * Creates a new Color3 from integer values (< 256)
  16150. * @param r defines the red component to read from (value between 0 and 255)
  16151. * @param g defines the green component to read from (value between 0 and 255)
  16152. * @param b defines the blue component to read from (value between 0 and 255)
  16153. * @param a defines the alpha component to read from (value between 0 and 255)
  16154. * @returns a new Color3 object
  16155. */
  16156. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16157. /**
  16158. * Check the content of a given array and convert it to an array containing RGBA data
  16159. * If the original array was already containing count * 4 values then it is returned directly
  16160. * @param colors defines the array to check
  16161. * @param count defines the number of RGBA data to expect
  16162. * @returns an array containing count * 4 values (RGBA)
  16163. */
  16164. static CheckColors4(colors: number[], count: number): number[];
  16165. }
  16166. /**
  16167. * Class representing a vector containing 2 coordinates
  16168. */
  16169. class Vector2 {
  16170. /** defines the first coordinate */
  16171. x: number;
  16172. /** defines the second coordinate */
  16173. y: number;
  16174. /**
  16175. * Creates a new Vector2 from the given x and y coordinates
  16176. * @param x defines the first coordinate
  16177. * @param y defines the second coordinate
  16178. */
  16179. constructor(
  16180. /** defines the first coordinate */
  16181. x?: number,
  16182. /** defines the second coordinate */
  16183. y?: number);
  16184. /**
  16185. * Gets a string with the Vector2 coordinates
  16186. * @returns a string with the Vector2 coordinates
  16187. */
  16188. toString(): string;
  16189. /**
  16190. * Gets class name
  16191. * @returns the string "Vector2"
  16192. */
  16193. getClassName(): string;
  16194. /**
  16195. * Gets current vector hash code
  16196. * @returns the Vector2 hash code as a number
  16197. */
  16198. getHashCode(): number;
  16199. /**
  16200. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16201. * @param array defines the source array
  16202. * @param index defines the offset in source array
  16203. * @returns the current Vector2
  16204. */
  16205. toArray(array: FloatArray, index?: number): Vector2;
  16206. /**
  16207. * Copy the current vector to an array
  16208. * @returns a new array with 2 elements: the Vector2 coordinates.
  16209. */
  16210. asArray(): number[];
  16211. /**
  16212. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16213. * @param source defines the source Vector2
  16214. * @returns the current updated Vector2
  16215. */
  16216. copyFrom(source: Vector2): Vector2;
  16217. /**
  16218. * Sets the Vector2 coordinates with the given floats
  16219. * @param x defines the first coordinate
  16220. * @param y defines the second coordinate
  16221. * @returns the current updated Vector2
  16222. */
  16223. copyFromFloats(x: number, y: number): Vector2;
  16224. /**
  16225. * Sets the Vector2 coordinates with the given floats
  16226. * @param x defines the first coordinate
  16227. * @param y defines the second coordinate
  16228. * @returns the current updated Vector2
  16229. */
  16230. set(x: number, y: number): Vector2;
  16231. /**
  16232. * Add another vector with the current one
  16233. * @param otherVector defines the other vector
  16234. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16235. */
  16236. add(otherVector: Vector2): Vector2;
  16237. /**
  16238. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16239. * @param otherVector defines the other vector
  16240. * @param result defines the target vector
  16241. * @returns the unmodified current Vector2
  16242. */
  16243. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16244. /**
  16245. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16246. * @param otherVector defines the other vector
  16247. * @returns the current updated Vector2
  16248. */
  16249. addInPlace(otherVector: Vector2): Vector2;
  16250. /**
  16251. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16252. * @param otherVector defines the other vector
  16253. * @returns a new Vector2
  16254. */
  16255. addVector3(otherVector: Vector3): Vector2;
  16256. /**
  16257. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16258. * @param otherVector defines the other vector
  16259. * @returns a new Vector2
  16260. */
  16261. subtract(otherVector: Vector2): Vector2;
  16262. /**
  16263. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16264. * @param otherVector defines the other vector
  16265. * @param result defines the target vector
  16266. * @returns the unmodified current Vector2
  16267. */
  16268. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16269. /**
  16270. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16271. * @param otherVector defines the other vector
  16272. * @returns the current updated Vector2
  16273. */
  16274. subtractInPlace(otherVector: Vector2): Vector2;
  16275. /**
  16276. * Multiplies in place the current Vector2 coordinates by the given ones
  16277. * @param otherVector defines the other vector
  16278. * @returns the current updated Vector2
  16279. */
  16280. multiplyInPlace(otherVector: Vector2): Vector2;
  16281. /**
  16282. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16283. * @param otherVector defines the other vector
  16284. * @returns a new Vector2
  16285. */
  16286. multiply(otherVector: Vector2): Vector2;
  16287. /**
  16288. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16289. * @param otherVector defines the other vector
  16290. * @param result defines the target vector
  16291. * @returns the unmodified current Vector2
  16292. */
  16293. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16294. /**
  16295. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16296. * @param x defines the first coordinate
  16297. * @param y defines the second coordinate
  16298. * @returns a new Vector2
  16299. */
  16300. multiplyByFloats(x: number, y: number): Vector2;
  16301. /**
  16302. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16303. * @param otherVector defines the other vector
  16304. * @returns a new Vector2
  16305. */
  16306. divide(otherVector: Vector2): Vector2;
  16307. /**
  16308. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16309. * @param otherVector defines the other vector
  16310. * @param result defines the target vector
  16311. * @returns the unmodified current Vector2
  16312. */
  16313. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16314. /**
  16315. * Divides the current Vector2 coordinates by the given ones
  16316. * @param otherVector defines the other vector
  16317. * @returns the current updated Vector2
  16318. */
  16319. divideInPlace(otherVector: Vector2): Vector2;
  16320. /**
  16321. * Gets a new Vector2 with current Vector2 negated coordinates
  16322. * @returns a new Vector2
  16323. */
  16324. negate(): Vector2;
  16325. /**
  16326. * Multiply the Vector2 coordinates by scale
  16327. * @param scale defines the scaling factor
  16328. * @returns the current updated Vector2
  16329. */
  16330. scaleInPlace(scale: number): Vector2;
  16331. /**
  16332. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16333. * @param scale defines the scaling factor
  16334. * @returns a new Vector2
  16335. */
  16336. scale(scale: number): Vector2;
  16337. /**
  16338. * Scale the current Vector2 values by a factor to a given Vector2
  16339. * @param scale defines the scale factor
  16340. * @param result defines the Vector2 object where to store the result
  16341. * @returns the unmodified current Vector2
  16342. */
  16343. scaleToRef(scale: number, result: Vector2): Vector2;
  16344. /**
  16345. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16346. * @param scale defines the scale factor
  16347. * @param result defines the Vector2 object where to store the result
  16348. * @returns the unmodified current Vector2
  16349. */
  16350. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16351. /**
  16352. * Gets a boolean if two vectors are equals
  16353. * @param otherVector defines the other vector
  16354. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16355. */
  16356. equals(otherVector: Vector2): boolean;
  16357. /**
  16358. * Gets a boolean if two vectors are equals (using an epsilon value)
  16359. * @param otherVector defines the other vector
  16360. * @param epsilon defines the minimal distance to consider equality
  16361. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16362. */
  16363. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16364. /**
  16365. * Gets a new Vector2 from current Vector2 floored values
  16366. * @returns a new Vector2
  16367. */
  16368. floor(): Vector2;
  16369. /**
  16370. * Gets a new Vector2 from current Vector2 floored values
  16371. * @returns a new Vector2
  16372. */
  16373. fract(): Vector2;
  16374. /**
  16375. * Gets the length of the vector
  16376. * @returns the vector length (float)
  16377. */
  16378. length(): number;
  16379. /**
  16380. * Gets the vector squared length
  16381. * @returns the vector squared length (float)
  16382. */
  16383. lengthSquared(): number;
  16384. /**
  16385. * Normalize the vector
  16386. * @returns the current updated Vector2
  16387. */
  16388. normalize(): Vector2;
  16389. /**
  16390. * Gets a new Vector2 copied from the Vector2
  16391. * @returns a new Vector2
  16392. */
  16393. clone(): Vector2;
  16394. /**
  16395. * Gets a new Vector2(0, 0)
  16396. * @returns a new Vector2
  16397. */
  16398. static Zero(): Vector2;
  16399. /**
  16400. * Gets a new Vector2(1, 1)
  16401. * @returns a new Vector2
  16402. */
  16403. static One(): Vector2;
  16404. /**
  16405. * Gets a new Vector2 set from the given index element of the given array
  16406. * @param array defines the data source
  16407. * @param offset defines the offset in the data source
  16408. * @returns a new Vector2
  16409. */
  16410. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16411. /**
  16412. * Sets "result" from the given index element of the given array
  16413. * @param array defines the data source
  16414. * @param offset defines the offset in the data source
  16415. * @param result defines the target vector
  16416. */
  16417. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16418. /**
  16419. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16420. * @param value1 defines 1st point of control
  16421. * @param value2 defines 2nd point of control
  16422. * @param value3 defines 3rd point of control
  16423. * @param value4 defines 4th point of control
  16424. * @param amount defines the interpolation factor
  16425. * @returns a new Vector2
  16426. */
  16427. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16428. /**
  16429. * 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".
  16430. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16431. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16432. * @param value defines the value to clamp
  16433. * @param min defines the lower limit
  16434. * @param max defines the upper limit
  16435. * @returns a new Vector2
  16436. */
  16437. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16438. /**
  16439. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16440. * @param value1 defines the 1st control point
  16441. * @param tangent1 defines the outgoing tangent
  16442. * @param value2 defines the 2nd control point
  16443. * @param tangent2 defines the incoming tangent
  16444. * @param amount defines the interpolation factor
  16445. * @returns a new Vector2
  16446. */
  16447. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16448. /**
  16449. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16450. * @param start defines the start vector
  16451. * @param end defines the end vector
  16452. * @param amount defines the interpolation factor
  16453. * @returns a new Vector2
  16454. */
  16455. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16456. /**
  16457. * Gets the dot product of the vector "left" and the vector "right"
  16458. * @param left defines first vector
  16459. * @param right defines second vector
  16460. * @returns the dot product (float)
  16461. */
  16462. static Dot(left: Vector2, right: Vector2): number;
  16463. /**
  16464. * Returns a new Vector2 equal to the normalized given vector
  16465. * @param vector defines the vector to normalize
  16466. * @returns a new Vector2
  16467. */
  16468. static Normalize(vector: Vector2): Vector2;
  16469. /**
  16470. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16471. * @param left defines 1st vector
  16472. * @param right defines 2nd vector
  16473. * @returns a new Vector2
  16474. */
  16475. static Minimize(left: Vector2, right: Vector2): Vector2;
  16476. /**
  16477. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16478. * @param left defines 1st vector
  16479. * @param right defines 2nd vector
  16480. * @returns a new Vector2
  16481. */
  16482. static Maximize(left: Vector2, right: Vector2): Vector2;
  16483. /**
  16484. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16485. * @param vector defines the vector to transform
  16486. * @param transformation defines the matrix to apply
  16487. * @returns a new Vector2
  16488. */
  16489. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16490. /**
  16491. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16492. * @param vector defines the vector to transform
  16493. * @param transformation defines the matrix to apply
  16494. * @param result defines the target vector
  16495. */
  16496. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16497. /**
  16498. * Determines if a given vector is included in a triangle
  16499. * @param p defines the vector to test
  16500. * @param p0 defines 1st triangle point
  16501. * @param p1 defines 2nd triangle point
  16502. * @param p2 defines 3rd triangle point
  16503. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16504. */
  16505. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16506. /**
  16507. * Gets the distance between the vectors "value1" and "value2"
  16508. * @param value1 defines first vector
  16509. * @param value2 defines second vector
  16510. * @returns the distance between vectors
  16511. */
  16512. static Distance(value1: Vector2, value2: Vector2): number;
  16513. /**
  16514. * Returns the squared distance between the vectors "value1" and "value2"
  16515. * @param value1 defines first vector
  16516. * @param value2 defines second vector
  16517. * @returns the squared distance between vectors
  16518. */
  16519. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16520. /**
  16521. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16522. * @param value1 defines first vector
  16523. * @param value2 defines second vector
  16524. * @returns a new Vector2
  16525. */
  16526. static Center(value1: Vector2, value2: Vector2): Vector2;
  16527. /**
  16528. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16529. * @param p defines the middle point
  16530. * @param segA defines one point of the segment
  16531. * @param segB defines the other point of the segment
  16532. * @returns the shortest distance
  16533. */
  16534. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16535. }
  16536. /**
  16537. * Classed used to store (x,y,z) vector representation
  16538. * A Vector3 is the main object used in 3D geometry
  16539. * It can represent etiher the coordinates of a point the space, either a direction
  16540. * Reminder: Babylon.js uses a left handed forward facing system
  16541. */
  16542. class Vector3 {
  16543. /**
  16544. * Defines the first coordinates (on X axis)
  16545. */
  16546. x: number;
  16547. /**
  16548. * Defines the second coordinates (on Y axis)
  16549. */
  16550. y: number;
  16551. /**
  16552. * Defines the third coordinates (on Z axis)
  16553. */
  16554. z: number;
  16555. /**
  16556. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16557. * @param x defines the first coordinates (on X axis)
  16558. * @param y defines the second coordinates (on Y axis)
  16559. * @param z defines the third coordinates (on Z axis)
  16560. */
  16561. constructor(
  16562. /**
  16563. * Defines the first coordinates (on X axis)
  16564. */
  16565. x?: number,
  16566. /**
  16567. * Defines the second coordinates (on Y axis)
  16568. */
  16569. y?: number,
  16570. /**
  16571. * Defines the third coordinates (on Z axis)
  16572. */
  16573. z?: number);
  16574. /**
  16575. * Creates a string representation of the Vector3
  16576. * @returns a string with the Vector3 coordinates.
  16577. */
  16578. toString(): string;
  16579. /**
  16580. * Gets the class name
  16581. * @returns the string "Vector3"
  16582. */
  16583. getClassName(): string;
  16584. /**
  16585. * Creates the Vector3 hash code
  16586. * @returns a number which tends to be unique between Vector3 instances
  16587. */
  16588. getHashCode(): number;
  16589. /**
  16590. * Creates an array containing three elements : the coordinates of the Vector3
  16591. * @returns a new array of numbers
  16592. */
  16593. asArray(): number[];
  16594. /**
  16595. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16596. * @param array defines the destination array
  16597. * @param index defines the offset in the destination array
  16598. * @returns the current Vector3
  16599. */
  16600. toArray(array: FloatArray, index?: number): Vector3;
  16601. /**
  16602. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16603. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16604. */
  16605. toQuaternion(): Quaternion;
  16606. /**
  16607. * Adds the given vector to the current Vector3
  16608. * @param otherVector defines the second operand
  16609. * @returns the current updated Vector3
  16610. */
  16611. addInPlace(otherVector: Vector3): Vector3;
  16612. /**
  16613. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16614. * @param otherVector defines the second operand
  16615. * @returns the resulting Vector3
  16616. */
  16617. add(otherVector: Vector3): Vector3;
  16618. /**
  16619. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16620. * @param otherVector defines the second operand
  16621. * @param result defines the Vector3 object where to store the result
  16622. * @returns the current Vector3
  16623. */
  16624. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16625. /**
  16626. * Subtract the given vector from the current Vector3
  16627. * @param otherVector defines the second operand
  16628. * @returns the current updated Vector3
  16629. */
  16630. subtractInPlace(otherVector: Vector3): Vector3;
  16631. /**
  16632. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16633. * @param otherVector defines the second operand
  16634. * @returns the resulting Vector3
  16635. */
  16636. subtract(otherVector: Vector3): Vector3;
  16637. /**
  16638. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16639. * @param otherVector defines the second operand
  16640. * @param result defines the Vector3 object where to store the result
  16641. * @returns the current Vector3
  16642. */
  16643. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16644. /**
  16645. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16646. * @param x defines the x coordinate of the operand
  16647. * @param y defines the y coordinate of the operand
  16648. * @param z defines the z coordinate of the operand
  16649. * @returns the resulting Vector3
  16650. */
  16651. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16652. /**
  16653. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16654. * @param x defines the x coordinate of the operand
  16655. * @param y defines the y coordinate of the operand
  16656. * @param z defines the z coordinate of the operand
  16657. * @param result defines the Vector3 object where to store the result
  16658. * @returns the current Vector3
  16659. */
  16660. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16661. /**
  16662. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16663. * @returns a new Vector3
  16664. */
  16665. negate(): Vector3;
  16666. /**
  16667. * Multiplies the Vector3 coordinates by the float "scale"
  16668. * @param scale defines the multiplier factor
  16669. * @returns the current updated Vector3
  16670. */
  16671. scaleInPlace(scale: number): Vector3;
  16672. /**
  16673. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16674. * @param scale defines the multiplier factor
  16675. * @returns a new Vector3
  16676. */
  16677. scale(scale: number): Vector3;
  16678. /**
  16679. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16680. * @param scale defines the multiplier factor
  16681. * @param result defines the Vector3 object where to store the result
  16682. * @returns the current Vector3
  16683. */
  16684. scaleToRef(scale: number, result: Vector3): Vector3;
  16685. /**
  16686. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16687. * @param scale defines the scale factor
  16688. * @param result defines the Vector3 object where to store the result
  16689. * @returns the unmodified current Vector3
  16690. */
  16691. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16692. /**
  16693. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16694. * @param otherVector defines the second operand
  16695. * @returns true if both vectors are equals
  16696. */
  16697. equals(otherVector: Vector3): boolean;
  16698. /**
  16699. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16700. * @param otherVector defines the second operand
  16701. * @param epsilon defines the minimal distance to define values as equals
  16702. * @returns true if both vectors are distant less than epsilon
  16703. */
  16704. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16705. /**
  16706. * Returns true if the current Vector3 coordinates equals the given floats
  16707. * @param x defines the x coordinate of the operand
  16708. * @param y defines the y coordinate of the operand
  16709. * @param z defines the z coordinate of the operand
  16710. * @returns true if both vectors are equals
  16711. */
  16712. equalsToFloats(x: number, y: number, z: number): boolean;
  16713. /**
  16714. * Multiplies the current Vector3 coordinates by the given ones
  16715. * @param otherVector defines the second operand
  16716. * @returns the current updated Vector3
  16717. */
  16718. multiplyInPlace(otherVector: Vector3): Vector3;
  16719. /**
  16720. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16721. * @param otherVector defines the second operand
  16722. * @returns the new Vector3
  16723. */
  16724. multiply(otherVector: Vector3): Vector3;
  16725. /**
  16726. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16727. * @param otherVector defines the second operand
  16728. * @param result defines the Vector3 object where to store the result
  16729. * @returns the current Vector3
  16730. */
  16731. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16732. /**
  16733. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16734. * @param x defines the x coordinate of the operand
  16735. * @param y defines the y coordinate of the operand
  16736. * @param z defines the z coordinate of the operand
  16737. * @returns the new Vector3
  16738. */
  16739. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16740. /**
  16741. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16742. * @param otherVector defines the second operand
  16743. * @returns the new Vector3
  16744. */
  16745. divide(otherVector: Vector3): Vector3;
  16746. /**
  16747. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16748. * @param otherVector defines the second operand
  16749. * @param result defines the Vector3 object where to store the result
  16750. * @returns the current Vector3
  16751. */
  16752. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16753. /**
  16754. * Divides the current Vector3 coordinates by the given ones.
  16755. * @param otherVector defines the second operand
  16756. * @returns the current updated Vector3
  16757. */
  16758. divideInPlace(otherVector: Vector3): Vector3;
  16759. /**
  16760. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16761. * @param other defines the second operand
  16762. * @returns the current updated Vector3
  16763. */
  16764. minimizeInPlace(other: Vector3): Vector3;
  16765. /**
  16766. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16767. * @param other defines the second operand
  16768. * @returns the current updated Vector3
  16769. */
  16770. maximizeInPlace(other: Vector3): Vector3;
  16771. /**
  16772. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16773. */
  16774. readonly isNonUniform: boolean;
  16775. /**
  16776. * Gets a new Vector3 from current Vector3 floored values
  16777. * @returns a new Vector3
  16778. */
  16779. floor(): Vector3;
  16780. /**
  16781. * Gets a new Vector3 from current Vector3 floored values
  16782. * @returns a new Vector3
  16783. */
  16784. fract(): Vector3;
  16785. /**
  16786. * Gets the length of the Vector3
  16787. * @returns the length of the Vecto3
  16788. */
  16789. length(): number;
  16790. /**
  16791. * Gets the squared length of the Vector3
  16792. * @returns squared length of the Vector3
  16793. */
  16794. lengthSquared(): number;
  16795. /**
  16796. * Normalize the current Vector3.
  16797. * Please note that this is an in place operation.
  16798. * @returns the current updated Vector3
  16799. */
  16800. normalize(): Vector3;
  16801. /**
  16802. * Normalize the current Vector3 to a new vector
  16803. * @returns the new Vector3
  16804. */
  16805. normalizeToNew(): Vector3;
  16806. /**
  16807. * Normalize the current Vector3 to the reference
  16808. * @param reference define the Vector3 to update
  16809. * @returns the updated Vector3
  16810. */
  16811. normalizeToRef(reference: Vector3): Vector3;
  16812. /**
  16813. * Creates a new Vector3 copied from the current Vector3
  16814. * @returns the new Vector3
  16815. */
  16816. clone(): Vector3;
  16817. /**
  16818. * Copies the given vector coordinates to the current Vector3 ones
  16819. * @param source defines the source Vector3
  16820. * @returns the current updated Vector3
  16821. */
  16822. copyFrom(source: Vector3): Vector3;
  16823. /**
  16824. * Copies the given floats to the current Vector3 coordinates
  16825. * @param x defines the x coordinate of the operand
  16826. * @param y defines the y coordinate of the operand
  16827. * @param z defines the z coordinate of the operand
  16828. * @returns the current updated Vector3
  16829. */
  16830. copyFromFloats(x: number, y: number, z: number): Vector3;
  16831. /**
  16832. * Copies the given floats to the current Vector3 coordinates
  16833. * @param x defines the x coordinate of the operand
  16834. * @param y defines the y coordinate of the operand
  16835. * @param z defines the z coordinate of the operand
  16836. * @returns the current updated Vector3
  16837. */
  16838. set(x: number, y: number, z: number): Vector3;
  16839. /**
  16840. * Get the clip factor between two vectors
  16841. * @param vector0 defines the first operand
  16842. * @param vector1 defines the second operand
  16843. * @param axis defines the axis to use
  16844. * @param size defines the size along the axis
  16845. * @returns the clip factor
  16846. */
  16847. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16848. /**
  16849. * Get angle between two vectors
  16850. * @param vector0 angle between vector0 and vector1
  16851. * @param vector1 angle between vector0 and vector1
  16852. * @param normal direction of the normal
  16853. * @return the angle between vector0 and vector1
  16854. */
  16855. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16856. /**
  16857. * Returns a new Vector3 set from the index "offset" of the given array
  16858. * @param array defines the source array
  16859. * @param offset defines the offset in the source array
  16860. * @returns the new Vector3
  16861. */
  16862. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16863. /**
  16864. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16865. * This function is deprecated. Use FromArray instead
  16866. * @param array defines the source array
  16867. * @param offset defines the offset in the source array
  16868. * @returns the new Vector3
  16869. */
  16870. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16871. /**
  16872. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16873. * @param array defines the source array
  16874. * @param offset defines the offset in the source array
  16875. * @param result defines the Vector3 where to store the result
  16876. */
  16877. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16878. /**
  16879. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16880. * This function is deprecated. Use FromArrayToRef instead.
  16881. * @param array defines the source array
  16882. * @param offset defines the offset in the source array
  16883. * @param result defines the Vector3 where to store the result
  16884. */
  16885. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16886. /**
  16887. * Sets the given vector "result" with the given floats.
  16888. * @param x defines the x coordinate of the source
  16889. * @param y defines the y coordinate of the source
  16890. * @param z defines the z coordinate of the source
  16891. * @param result defines the Vector3 where to store the result
  16892. */
  16893. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16894. /**
  16895. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16896. * @returns a new empty Vector3
  16897. */
  16898. static Zero(): Vector3;
  16899. /**
  16900. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16901. * @returns a new unit Vector3
  16902. */
  16903. static One(): Vector3;
  16904. /**
  16905. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16906. * @returns a new up Vector3
  16907. */
  16908. static Up(): Vector3;
  16909. /**
  16910. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16911. * @returns a new down Vector3
  16912. */
  16913. static Down(): Vector3;
  16914. /**
  16915. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16916. * @returns a new forward Vector3
  16917. */
  16918. static Forward(): Vector3;
  16919. /**
  16920. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16921. * @returns a new right Vector3
  16922. */
  16923. static Right(): Vector3;
  16924. /**
  16925. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16926. * @returns a new left Vector3
  16927. */
  16928. static Left(): Vector3;
  16929. /**
  16930. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16931. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16932. * @param vector defines the Vector3 to transform
  16933. * @param transformation defines the transformation matrix
  16934. * @returns the transformed Vector3
  16935. */
  16936. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16937. /**
  16938. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16939. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16940. * @param vector defines the Vector3 to transform
  16941. * @param transformation defines the transformation matrix
  16942. * @param result defines the Vector3 where to store the result
  16943. */
  16944. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16945. /**
  16946. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16947. * This method computes tranformed coordinates only, not transformed direction vectors
  16948. * @param x define the x coordinate of the source vector
  16949. * @param y define the y coordinate of the source vector
  16950. * @param z define the z coordinate of the source vector
  16951. * @param transformation defines the transformation matrix
  16952. * @param result defines the Vector3 where to store the result
  16953. */
  16954. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16955. /**
  16956. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16957. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16958. * @param vector defines the Vector3 to transform
  16959. * @param transformation defines the transformation matrix
  16960. * @returns the new Vector3
  16961. */
  16962. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16963. /**
  16964. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16965. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16966. * @param vector defines the Vector3 to transform
  16967. * @param transformation defines the transformation matrix
  16968. * @param result defines the Vector3 where to store the result
  16969. */
  16970. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16971. /**
  16972. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16973. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16974. * @param x define the x coordinate of the source vector
  16975. * @param y define the y coordinate of the source vector
  16976. * @param z define the z coordinate of the source vector
  16977. * @param transformation defines the transformation matrix
  16978. * @param result defines the Vector3 where to store the result
  16979. */
  16980. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16981. /**
  16982. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16983. * @param value1 defines the first control point
  16984. * @param value2 defines the second control point
  16985. * @param value3 defines the third control point
  16986. * @param value4 defines the fourth control point
  16987. * @param amount defines the amount on the spline to use
  16988. * @returns the new Vector3
  16989. */
  16990. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16991. /**
  16992. * 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"
  16993. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16994. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16995. * @param value defines the current value
  16996. * @param min defines the lower range value
  16997. * @param max defines the upper range value
  16998. * @returns the new Vector3
  16999. */
  17000. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17001. /**
  17002. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17003. * @param value1 defines the first control point
  17004. * @param tangent1 defines the first tangent vector
  17005. * @param value2 defines the second control point
  17006. * @param tangent2 defines the second tangent vector
  17007. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17008. * @returns the new Vector3
  17009. */
  17010. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17011. /**
  17012. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17013. * @param start defines the start value
  17014. * @param end defines the end value
  17015. * @param amount max defines amount between both (between 0 and 1)
  17016. * @returns the new Vector3
  17017. */
  17018. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17019. /**
  17020. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17021. * @param start defines the start value
  17022. * @param end defines the end value
  17023. * @param amount max defines amount between both (between 0 and 1)
  17024. * @param result defines the Vector3 where to store the result
  17025. */
  17026. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17027. /**
  17028. * Returns the dot product (float) between the vectors "left" and "right"
  17029. * @param left defines the left operand
  17030. * @param right defines the right operand
  17031. * @returns the dot product
  17032. */
  17033. static Dot(left: Vector3, right: Vector3): number;
  17034. /**
  17035. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17036. * The cross product is then orthogonal to both "left" and "right"
  17037. * @param left defines the left operand
  17038. * @param right defines the right operand
  17039. * @returns the cross product
  17040. */
  17041. static Cross(left: Vector3, right: Vector3): Vector3;
  17042. /**
  17043. * Sets the given vector "result" with the cross product of "left" and "right"
  17044. * The cross product is then orthogonal to both "left" and "right"
  17045. * @param left defines the left operand
  17046. * @param right defines the right operand
  17047. * @param result defines the Vector3 where to store the result
  17048. */
  17049. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17050. /**
  17051. * Returns a new Vector3 as the normalization of the given vector
  17052. * @param vector defines the Vector3 to normalize
  17053. * @returns the new Vector3
  17054. */
  17055. static Normalize(vector: Vector3): Vector3;
  17056. /**
  17057. * Sets the given vector "result" with the normalization of the given first vector
  17058. * @param vector defines the Vector3 to normalize
  17059. * @param result defines the Vector3 where to store the result
  17060. */
  17061. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17062. private static _viewportMatrixCache;
  17063. /**
  17064. * Project a Vector3 onto screen space
  17065. * @param vector defines the Vector3 to project
  17066. * @param world defines the world matrix to use
  17067. * @param transform defines the transform (view x projection) matrix to use
  17068. * @param viewport defines the screen viewport to use
  17069. * @returns the new Vector3
  17070. */
  17071. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17072. /**
  17073. * Unproject from screen space to object space
  17074. * @param source defines the screen space Vector3 to use
  17075. * @param viewportWidth defines the current width of the viewport
  17076. * @param viewportHeight defines the current height of the viewport
  17077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17078. * @param transform defines the transform (view x projection) matrix to use
  17079. * @returns the new Vector3
  17080. */
  17081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17082. /**
  17083. * Unproject from screen space to object space
  17084. * @param source defines the screen space Vector3 to use
  17085. * @param viewportWidth defines the current width of the viewport
  17086. * @param viewportHeight defines the current height of the viewport
  17087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17088. * @param view defines the view matrix to use
  17089. * @param projection defines the projection matrix to use
  17090. * @returns the new Vector3
  17091. */
  17092. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17093. /**
  17094. * Unproject from screen space to object space
  17095. * @param source defines the screen space Vector3 to use
  17096. * @param viewportWidth defines the current width of the viewport
  17097. * @param viewportHeight defines the current height of the viewport
  17098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17099. * @param view defines the view matrix to use
  17100. * @param projection defines the projection matrix to use
  17101. * @param result defines the Vector3 where to store the result
  17102. */
  17103. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17104. /**
  17105. * Unproject from screen space to object space
  17106. * @param sourceX defines the screen space x coordinate to use
  17107. * @param sourceY defines the screen space y coordinate to use
  17108. * @param sourceZ defines the screen space z coordinate to use
  17109. * @param viewportWidth defines the current width of the viewport
  17110. * @param viewportHeight defines the current height of the viewport
  17111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17112. * @param view defines the view matrix to use
  17113. * @param projection defines the projection matrix to use
  17114. * @param result defines the Vector3 where to store the result
  17115. */
  17116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17117. /**
  17118. * Gets the minimal coordinate values between two Vector3
  17119. * @param left defines the first operand
  17120. * @param right defines the second operand
  17121. * @returns the new Vector3
  17122. */
  17123. static Minimize(left: Vector3, right: Vector3): Vector3;
  17124. /**
  17125. * Gets the maximal coordinate values between two Vector3
  17126. * @param left defines the first operand
  17127. * @param right defines the second operand
  17128. * @returns the new Vector3
  17129. */
  17130. static Maximize(left: Vector3, right: Vector3): Vector3;
  17131. /**
  17132. * Returns the distance between the vectors "value1" and "value2"
  17133. * @param value1 defines the first operand
  17134. * @param value2 defines the second operand
  17135. * @returns the distance
  17136. */
  17137. static Distance(value1: Vector3, value2: Vector3): number;
  17138. /**
  17139. * Returns the squared distance between the vectors "value1" and "value2"
  17140. * @param value1 defines the first operand
  17141. * @param value2 defines the second operand
  17142. * @returns the squared distance
  17143. */
  17144. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17145. /**
  17146. * Returns a new Vector3 located at the center between "value1" and "value2"
  17147. * @param value1 defines the first operand
  17148. * @param value2 defines the second operand
  17149. * @returns the new Vector3
  17150. */
  17151. static Center(value1: Vector3, value2: Vector3): Vector3;
  17152. /**
  17153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17155. * to something in order to rotate it from its local system to the given target system
  17156. * Note: axis1, axis2 and axis3 are normalized during this operation
  17157. * @param axis1 defines the first axis
  17158. * @param axis2 defines the second axis
  17159. * @param axis3 defines the third axis
  17160. * @returns a new Vector3
  17161. */
  17162. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17163. /**
  17164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17165. * @param axis1 defines the first axis
  17166. * @param axis2 defines the second axis
  17167. * @param axis3 defines the third axis
  17168. * @param ref defines the Vector3 where to store the result
  17169. */
  17170. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17171. }
  17172. class Vector4 {
  17173. x: number;
  17174. y: number;
  17175. z: number;
  17176. w: number;
  17177. /**
  17178. * Creates a Vector4 object from the given floats.
  17179. */
  17180. constructor(x: number, y: number, z: number, w: number);
  17181. /**
  17182. * Returns the string with the Vector4 coordinates.
  17183. */
  17184. toString(): string;
  17185. /**
  17186. * Returns the string "Vector4".
  17187. */
  17188. getClassName(): string;
  17189. /**
  17190. * Returns the Vector4 hash code.
  17191. */
  17192. getHashCode(): number;
  17193. /**
  17194. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17195. */
  17196. asArray(): number[];
  17197. /**
  17198. * Populates the given array from the given index with the Vector4 coordinates.
  17199. * Returns the Vector4.
  17200. */
  17201. toArray(array: FloatArray, index?: number): Vector4;
  17202. /**
  17203. * Adds the given vector to the current Vector4.
  17204. * Returns the updated Vector4.
  17205. */
  17206. addInPlace(otherVector: Vector4): Vector4;
  17207. /**
  17208. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17209. */
  17210. add(otherVector: Vector4): Vector4;
  17211. /**
  17212. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17213. * Returns the current Vector4.
  17214. */
  17215. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17216. /**
  17217. * Subtract in place the given vector from the current Vector4.
  17218. * Returns the updated Vector4.
  17219. */
  17220. subtractInPlace(otherVector: Vector4): Vector4;
  17221. /**
  17222. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17223. */
  17224. subtract(otherVector: Vector4): Vector4;
  17225. /**
  17226. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17227. * Returns the current Vector4.
  17228. */
  17229. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17230. /**
  17231. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17232. */
  17233. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17234. /**
  17235. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17236. * Returns the current Vector4.
  17237. */
  17238. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17239. /**
  17240. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17241. */
  17242. negate(): Vector4;
  17243. /**
  17244. * Multiplies the current Vector4 coordinates by scale (float).
  17245. * Returns the updated Vector4.
  17246. */
  17247. scaleInPlace(scale: number): Vector4;
  17248. /**
  17249. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17250. */
  17251. scale(scale: number): Vector4;
  17252. /**
  17253. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17254. * Returns the current Vector4.
  17255. */
  17256. scaleToRef(scale: number, result: Vector4): Vector4;
  17257. /**
  17258. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17259. * @param scale defines the scale factor
  17260. * @param result defines the Vector4 object where to store the result
  17261. * @returns the unmodified current Vector4
  17262. */
  17263. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17264. /**
  17265. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17266. */
  17267. equals(otherVector: Vector4): boolean;
  17268. /**
  17269. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17270. */
  17271. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17272. /**
  17273. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17274. */
  17275. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17276. /**
  17277. * Multiplies in place the current Vector4 by the given one.
  17278. * Returns the updated Vector4.
  17279. */
  17280. multiplyInPlace(otherVector: Vector4): Vector4;
  17281. /**
  17282. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17283. */
  17284. multiply(otherVector: Vector4): Vector4;
  17285. /**
  17286. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17287. * Returns the current Vector4.
  17288. */
  17289. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17290. /**
  17291. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17292. */
  17293. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17294. /**
  17295. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17296. */
  17297. divide(otherVector: Vector4): Vector4;
  17298. /**
  17299. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17300. * Returns the current Vector4.
  17301. */
  17302. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17303. /**
  17304. * Divides the current Vector3 coordinates by the given ones.
  17305. * @returns the updated Vector3.
  17306. */
  17307. divideInPlace(otherVector: Vector4): Vector4;
  17308. /**
  17309. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17310. * @param other defines the second operand
  17311. * @returns the current updated Vector4
  17312. */
  17313. minimizeInPlace(other: Vector4): Vector4;
  17314. /**
  17315. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17316. * @param other defines the second operand
  17317. * @returns the current updated Vector4
  17318. */
  17319. maximizeInPlace(other: Vector4): Vector4;
  17320. /**
  17321. * Gets a new Vector4 from current Vector4 floored values
  17322. * @returns a new Vector4
  17323. */
  17324. floor(): Vector4;
  17325. /**
  17326. * Gets a new Vector4 from current Vector3 floored values
  17327. * @returns a new Vector4
  17328. */
  17329. fract(): Vector4;
  17330. /**
  17331. * Returns the Vector4 length (float).
  17332. */
  17333. length(): number;
  17334. /**
  17335. * Returns the Vector4 squared length (float).
  17336. */
  17337. lengthSquared(): number;
  17338. /**
  17339. * Normalizes in place the Vector4.
  17340. * Returns the updated Vector4.
  17341. */
  17342. normalize(): Vector4;
  17343. /**
  17344. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17345. */
  17346. toVector3(): Vector3;
  17347. /**
  17348. * Returns a new Vector4 copied from the current one.
  17349. */
  17350. clone(): Vector4;
  17351. /**
  17352. * Updates the current Vector4 with the given one coordinates.
  17353. * Returns the updated Vector4.
  17354. */
  17355. copyFrom(source: Vector4): Vector4;
  17356. /**
  17357. * Updates the current Vector4 coordinates with the given floats.
  17358. * Returns the updated Vector4.
  17359. */
  17360. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17361. /**
  17362. * Updates the current Vector4 coordinates with the given floats.
  17363. * Returns the updated Vector4.
  17364. */
  17365. set(x: number, y: number, z: number, w: number): Vector4;
  17366. /**
  17367. * Returns a new Vector4 set from the starting index of the given array.
  17368. */
  17369. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17370. /**
  17371. * Updates the given vector "result" from the starting index of the given array.
  17372. */
  17373. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17374. /**
  17375. * Updates the given vector "result" from the starting index of the given Float32Array.
  17376. */
  17377. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17378. /**
  17379. * Updates the given vector "result" coordinates from the given floats.
  17380. */
  17381. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17382. /**
  17383. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17384. */
  17385. static Zero(): Vector4;
  17386. /**
  17387. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17388. */
  17389. static One(): Vector4;
  17390. /**
  17391. * Returns a new normalized Vector4 from the given one.
  17392. */
  17393. static Normalize(vector: Vector4): Vector4;
  17394. /**
  17395. * Updates the given vector "result" from the normalization of the given one.
  17396. */
  17397. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17398. static Minimize(left: Vector4, right: Vector4): Vector4;
  17399. static Maximize(left: Vector4, right: Vector4): Vector4;
  17400. /**
  17401. * Returns the distance (float) between the vectors "value1" and "value2".
  17402. */
  17403. static Distance(value1: Vector4, value2: Vector4): number;
  17404. /**
  17405. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17406. */
  17407. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17408. /**
  17409. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17410. */
  17411. static Center(value1: Vector4, value2: Vector4): Vector4;
  17412. /**
  17413. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17414. * This methods computes transformed normalized direction vectors only.
  17415. */
  17416. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17417. /**
  17418. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17419. * This methods computes transformed normalized direction vectors only.
  17420. */
  17421. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17422. /**
  17423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17424. * This methods computes transformed normalized direction vectors only.
  17425. */
  17426. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17427. }
  17428. interface ISize {
  17429. width: number;
  17430. height: number;
  17431. }
  17432. class Size implements ISize {
  17433. width: number;
  17434. height: number;
  17435. /**
  17436. * Creates a Size object from the given width and height (floats).
  17437. */
  17438. constructor(width: number, height: number);
  17439. toString(): string;
  17440. /**
  17441. * Returns the string "Size"
  17442. */
  17443. getClassName(): string;
  17444. /**
  17445. * Returns the Size hash code.
  17446. */
  17447. getHashCode(): number;
  17448. /**
  17449. * Updates the current size from the given one.
  17450. * Returns the updated Size.
  17451. */
  17452. copyFrom(src: Size): void;
  17453. /**
  17454. * Updates in place the current Size from the given floats.
  17455. * Returns the updated Size.
  17456. */
  17457. copyFromFloats(width: number, height: number): Size;
  17458. /**
  17459. * Updates in place the current Size from the given floats.
  17460. * Returns the updated Size.
  17461. */
  17462. set(width: number, height: number): Size;
  17463. /**
  17464. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17465. */
  17466. multiplyByFloats(w: number, h: number): Size;
  17467. /**
  17468. * Returns a new Size copied from the given one.
  17469. */
  17470. clone(): Size;
  17471. /**
  17472. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17473. */
  17474. equals(other: Size): boolean;
  17475. /**
  17476. * Returns the surface of the Size : width * height (float).
  17477. */
  17478. readonly surface: number;
  17479. /**
  17480. * Returns a new Size set to (0.0, 0.0)
  17481. */
  17482. static Zero(): Size;
  17483. /**
  17484. * Returns a new Size set as the addition result of the current Size and the given one.
  17485. */
  17486. add(otherSize: Size): Size;
  17487. /**
  17488. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17489. */
  17490. subtract(otherSize: Size): Size;
  17491. /**
  17492. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17493. */
  17494. static Lerp(start: Size, end: Size, amount: number): Size;
  17495. }
  17496. /**
  17497. * Class used to store quaternion data
  17498. * @see https://en.wikipedia.org/wiki/Quaternion
  17499. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17500. */
  17501. class Quaternion {
  17502. /** defines the first component (0 by default) */
  17503. x: number;
  17504. /** defines the second component (0 by default) */
  17505. y: number;
  17506. /** defines the third component (0 by default) */
  17507. z: number;
  17508. /** defines the fourth component (1.0 by default) */
  17509. w: number;
  17510. /**
  17511. * Creates a new Quaternion from the given floats
  17512. * @param x defines the first component (0 by default)
  17513. * @param y defines the second component (0 by default)
  17514. * @param z defines the third component (0 by default)
  17515. * @param w defines the fourth component (1.0 by default)
  17516. */
  17517. constructor(
  17518. /** defines the first component (0 by default) */
  17519. x?: number,
  17520. /** defines the second component (0 by default) */
  17521. y?: number,
  17522. /** defines the third component (0 by default) */
  17523. z?: number,
  17524. /** defines the fourth component (1.0 by default) */
  17525. w?: number);
  17526. /**
  17527. * Gets a string representation for the current quaternion
  17528. * @returns a string with the Quaternion coordinates
  17529. */
  17530. toString(): string;
  17531. /**
  17532. * Gets the class name of the quaternion
  17533. * @returns the string "Quaternion"
  17534. */
  17535. getClassName(): string;
  17536. /**
  17537. * Gets a hash code for this quaternion
  17538. * @returns the quaternion hash code
  17539. */
  17540. getHashCode(): number;
  17541. /**
  17542. * Copy the quaternion to an array
  17543. * @returns a new array populated with 4 elements from the quaternion coordinates
  17544. */
  17545. asArray(): number[];
  17546. /**
  17547. * Check if two quaternions are equals
  17548. * @param otherQuaternion defines the second operand
  17549. * @return true if the current quaternion and the given one coordinates are strictly equals
  17550. */
  17551. equals(otherQuaternion: Quaternion): boolean;
  17552. /**
  17553. * Clone the current quaternion
  17554. * @returns a new quaternion copied from the current one
  17555. */
  17556. clone(): Quaternion;
  17557. /**
  17558. * Copy a quaternion to the current one
  17559. * @param other defines the other quaternion
  17560. * @returns the updated current quaternion
  17561. */
  17562. copyFrom(other: Quaternion): Quaternion;
  17563. /**
  17564. * Updates the current quaternion with the given float coordinates
  17565. * @param x defines the x coordinate
  17566. * @param y defines the y coordinate
  17567. * @param z defines the z coordinate
  17568. * @param w defines the w coordinate
  17569. * @returns the updated current quaternion
  17570. */
  17571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17572. /**
  17573. * Updates the current quaternion from the given float coordinates
  17574. * @param x defines the x coordinate
  17575. * @param y defines the y coordinate
  17576. * @param z defines the z coordinate
  17577. * @param w defines the w coordinate
  17578. * @returns the updated current quaternion
  17579. */
  17580. set(x: number, y: number, z: number, w: number): Quaternion;
  17581. /**
  17582. * Adds two quaternions
  17583. * @param other defines the second operand
  17584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17585. */
  17586. add(other: Quaternion): Quaternion;
  17587. /**
  17588. * Add a quaternion to the current one
  17589. * @param other defines the quaternion to add
  17590. * @returns the current quaternion
  17591. */
  17592. addInPlace(other: Quaternion): Quaternion;
  17593. /**
  17594. * Subtract two quaternions
  17595. * @param other defines the second operand
  17596. * @returns a new quaternion as the subtraction result of the given one from the current one
  17597. */
  17598. subtract(other: Quaternion): Quaternion;
  17599. /**
  17600. * Multiplies the current quaternion by a scale factor
  17601. * @param value defines the scale factor
  17602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17603. */
  17604. scale(value: number): Quaternion;
  17605. /**
  17606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17607. * @param scale defines the scale factor
  17608. * @param result defines the Quaternion object where to store the result
  17609. * @returns the unmodified current quaternion
  17610. */
  17611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17612. /**
  17613. * Multiplies in place the current quaternion by a scale factor
  17614. * @param value defines the scale factor
  17615. * @returns the current modified quaternion
  17616. */
  17617. scaleInPlace(value: number): Quaternion;
  17618. /**
  17619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17620. * @param scale defines the scale factor
  17621. * @param result defines the Quaternion object where to store the result
  17622. * @returns the unmodified current quaternion
  17623. */
  17624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17625. /**
  17626. * Multiplies two quaternions
  17627. * @param q1 defines the second operand
  17628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17629. */
  17630. multiply(q1: Quaternion): Quaternion;
  17631. /**
  17632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17633. * @param q1 defines the second operand
  17634. * @param result defines the target quaternion
  17635. * @returns the current quaternion
  17636. */
  17637. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17638. /**
  17639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17640. * @param q1 defines the second operand
  17641. * @returns the currentupdated quaternion
  17642. */
  17643. multiplyInPlace(q1: Quaternion): Quaternion;
  17644. /**
  17645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17646. * @param ref defines the target quaternion
  17647. * @returns the current quaternion
  17648. */
  17649. conjugateToRef(ref: Quaternion): Quaternion;
  17650. /**
  17651. * Conjugates in place (1-q) the current quaternion
  17652. * @returns the current updated quaternion
  17653. */
  17654. conjugateInPlace(): Quaternion;
  17655. /**
  17656. * Conjugates in place (1-q) the current quaternion
  17657. * @returns a new quaternion
  17658. */
  17659. conjugate(): Quaternion;
  17660. /**
  17661. * Gets length of current quaternion
  17662. * @returns the quaternion length (float)
  17663. */
  17664. length(): number;
  17665. /**
  17666. * Normalize in place the current quaternion
  17667. * @returns the current updated quaternion
  17668. */
  17669. normalize(): Quaternion;
  17670. /**
  17671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17672. * @param order is a reserved parameter and is ignore for now
  17673. * @returns a new Vector3 containing the Euler angles
  17674. */
  17675. toEulerAngles(order?: string): Vector3;
  17676. /**
  17677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17678. * @param result defines the vector which will be filled with the Euler angles
  17679. * @param order is a reserved parameter and is ignore for now
  17680. * @returns the current unchanged quaternion
  17681. */
  17682. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17683. /**
  17684. * Updates the given rotation matrix with the current quaternion values
  17685. * @param result defines the target matrix
  17686. * @returns the current unchanged quaternion
  17687. */
  17688. toRotationMatrix(result: Matrix): Quaternion;
  17689. /**
  17690. * Updates the current quaternion from the given rotation matrix values
  17691. * @param matrix defines the source matrix
  17692. * @returns the current updated quaternion
  17693. */
  17694. fromRotationMatrix(matrix: Matrix): Quaternion;
  17695. /**
  17696. * Creates a new quaternion from a rotation matrix
  17697. * @param matrix defines the source matrix
  17698. * @returns a new quaternion created from the given rotation matrix values
  17699. */
  17700. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17701. /**
  17702. * Updates the given quaternion with the given rotation matrix values
  17703. * @param matrix defines the source matrix
  17704. * @param result defines the target quaternion
  17705. */
  17706. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17707. /**
  17708. * Returns the dot product (float) between the quaternions "left" and "right"
  17709. * @param left defines the left operand
  17710. * @param right defines the right operand
  17711. * @returns the dot product
  17712. */
  17713. static Dot(left: Quaternion, right: Quaternion): number;
  17714. /**
  17715. * Checks if the two quaternions are close to each other
  17716. * @param quat0 defines the first quaternion to check
  17717. * @param quat1 defines the second quaternion to check
  17718. * @returns true if the two quaternions are close to each other
  17719. */
  17720. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17721. /**
  17722. * Creates an empty quaternion
  17723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17724. */
  17725. static Zero(): Quaternion;
  17726. /**
  17727. * Inverse a given quaternion
  17728. * @param q defines the source quaternion
  17729. * @returns a new quaternion as the inverted current quaternion
  17730. */
  17731. static Inverse(q: Quaternion): Quaternion;
  17732. /**
  17733. * Creates an identity quaternion
  17734. * @returns the identity quaternion
  17735. */
  17736. static Identity(): Quaternion;
  17737. /**
  17738. * Gets a boolean indicating if the given quaternion is identity
  17739. * @param quaternion defines the quaternion to check
  17740. * @returns true if the quaternion is identity
  17741. */
  17742. static IsIdentity(quaternion: Quaternion): boolean;
  17743. /**
  17744. * Creates a quaternion from a rotation around an axis
  17745. * @param axis defines the axis to use
  17746. * @param angle defines the angle to use
  17747. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17748. */
  17749. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17750. /**
  17751. * Creates a rotation around an axis and stores it into the given quaternion
  17752. * @param axis defines the axis to use
  17753. * @param angle defines the angle to use
  17754. * @param result defines the target quaternion
  17755. * @returns the target quaternion
  17756. */
  17757. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17758. /**
  17759. * Creates a new quaternion from data stored into an array
  17760. * @param array defines the data source
  17761. * @param offset defines the offset in the source array where the data starts
  17762. * @returns a new quaternion
  17763. */
  17764. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17765. /**
  17766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17767. * @param yaw defines the rotation around Y axis
  17768. * @param pitch defines the rotation around X axis
  17769. * @param roll defines the rotation around Z axis
  17770. * @returns the new quaternion
  17771. */
  17772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17773. /**
  17774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17775. * @param yaw defines the rotation around Y axis
  17776. * @param pitch defines the rotation around X axis
  17777. * @param roll defines the rotation around Z axis
  17778. * @param result defines the target quaternion
  17779. */
  17780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17781. /**
  17782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17783. * @param alpha defines the rotation around first axis
  17784. * @param beta defines the rotation around second axis
  17785. * @param gamma defines the rotation around third axis
  17786. * @returns the new quaternion
  17787. */
  17788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17789. /**
  17790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17791. * @param alpha defines the rotation around first axis
  17792. * @param beta defines the rotation around second axis
  17793. * @param gamma defines the rotation around third axis
  17794. * @param result defines the target quaternion
  17795. */
  17796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17797. /**
  17798. * 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)
  17799. * @param axis1 defines the first axis
  17800. * @param axis2 defines the second axis
  17801. * @param axis3 defines the third axis
  17802. * @returns the new quaternion
  17803. */
  17804. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17805. /**
  17806. * 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
  17807. * @param axis1 defines the first axis
  17808. * @param axis2 defines the second axis
  17809. * @param axis3 defines the third axis
  17810. * @param ref defines the target quaternion
  17811. */
  17812. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17813. /**
  17814. * Interpolates between two quaternions
  17815. * @param left defines first quaternion
  17816. * @param right defines second quaternion
  17817. * @param amount defines the gradient to use
  17818. * @returns the new interpolated quaternion
  17819. */
  17820. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17821. /**
  17822. * Interpolates between two quaternions and stores it into a target quaternion
  17823. * @param left defines first quaternion
  17824. * @param right defines second quaternion
  17825. * @param amount defines the gradient to use
  17826. * @param result defines the target quaternion
  17827. */
  17828. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17829. /**
  17830. * Interpolate between two quaternions using Hermite interpolation
  17831. * @param value1 defines first quaternion
  17832. * @param tangent1 defines the incoming tangent
  17833. * @param value2 defines second quaternion
  17834. * @param tangent2 defines the outgoing tangent
  17835. * @param amount defines the target quaternion
  17836. * @returns the new interpolated quaternion
  17837. */
  17838. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17839. }
  17840. /**
  17841. * Class used to store matrix data (4x4)
  17842. */
  17843. class Matrix {
  17844. private static _tempQuaternion;
  17845. private static _xAxis;
  17846. private static _yAxis;
  17847. private static _zAxis;
  17848. private static _updateFlagSeed;
  17849. private static _identityReadOnly;
  17850. private _isIdentity;
  17851. private _isIdentityDirty;
  17852. /**
  17853. * Gets the update flag of the matrix which is an unique number for the matrix.
  17854. * It will be incremented every time the matrix data change.
  17855. * You can use it to speed the comparison between two versions of the same matrix.
  17856. */
  17857. updateFlag: number;
  17858. /**
  17859. * Gets or sets the internal data of the matrix
  17860. */
  17861. m: Float32Array;
  17862. /** @hidden */
  17863. /**
  17864. * Creates an empty matrix (filled with zeros)
  17865. */
  17866. constructor();
  17867. /**
  17868. * Check if the current matrix is indentity
  17869. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17870. * @returns true is the matrix is the identity matrix
  17871. */
  17872. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17873. /**
  17874. * Gets the determinant of the matrix
  17875. * @returns the matrix determinant
  17876. */
  17877. determinant(): number;
  17878. /**
  17879. * Returns the matrix as a Float32Array
  17880. * @returns the matrix underlying array
  17881. */
  17882. toArray(): Float32Array;
  17883. /**
  17884. * Returns the matrix as a Float32Array
  17885. * @returns the matrix underlying array.
  17886. */
  17887. asArray(): Float32Array;
  17888. /**
  17889. * Inverts the current matrix in place
  17890. * @returns the current inverted matrix
  17891. */
  17892. invert(): Matrix;
  17893. /**
  17894. * Sets all the matrix elements to zero
  17895. * @returns the current matrix
  17896. */
  17897. reset(): Matrix;
  17898. /**
  17899. * Adds the current matrix with a second one
  17900. * @param other defines the matrix to add
  17901. * @returns a new matrix as the addition of the current matrix and the given one
  17902. */
  17903. add(other: Matrix): Matrix;
  17904. /**
  17905. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17906. * @param other defines the matrix to add
  17907. * @param result defines the target matrix
  17908. * @returns the current matrix
  17909. */
  17910. addToRef(other: Matrix, result: Matrix): Matrix;
  17911. /**
  17912. * Adds in place the given matrix to the current matrix
  17913. * @param other defines the second operand
  17914. * @returns the current updated matrix
  17915. */
  17916. addToSelf(other: Matrix): Matrix;
  17917. /**
  17918. * Sets the given matrix to the current inverted Matrix
  17919. * @param other defines the target matrix
  17920. * @returns the unmodified current matrix
  17921. */
  17922. invertToRef(other: Matrix): Matrix;
  17923. /**
  17924. * Inserts the translation vector (using 3 floats) in the current matrix
  17925. * @param x defines the 1st component of the translation
  17926. * @param y defines the 2nd component of the translation
  17927. * @param z defines the 3rd component of the translation
  17928. * @returns the current updated matrix
  17929. */
  17930. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17931. /**
  17932. * Inserts the translation vector in the current matrix
  17933. * @param vector3 defines the translation to insert
  17934. * @returns the current updated matrix
  17935. */
  17936. setTranslation(vector3: Vector3): Matrix;
  17937. /**
  17938. * Gets the translation value of the current matrix
  17939. * @returns a new Vector3 as the extracted translation from the matrix
  17940. */
  17941. getTranslation(): Vector3;
  17942. /**
  17943. * Fill a Vector3 with the extracted translation from the matrix
  17944. * @param result defines the Vector3 where to store the translation
  17945. * @returns the current matrix
  17946. */
  17947. getTranslationToRef(result: Vector3): Matrix;
  17948. /**
  17949. * Remove rotation and scaling part from the matrix
  17950. * @returns the updated matrix
  17951. */
  17952. removeRotationAndScaling(): Matrix;
  17953. /**
  17954. * Multiply two matrices
  17955. * @param other defines the second operand
  17956. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17957. */
  17958. multiply(other: Matrix): Matrix;
  17959. /**
  17960. * Copy the current matrix from the given one
  17961. * @param other defines the source matrix
  17962. * @returns the current updated matrix
  17963. */
  17964. copyFrom(other: Matrix): Matrix;
  17965. /**
  17966. * Populates the given array from the starting index with the current matrix values
  17967. * @param array defines the target array
  17968. * @param offset defines the offset in the target array where to start storing values
  17969. * @returns the current matrix
  17970. */
  17971. copyToArray(array: Float32Array, offset?: number): Matrix;
  17972. /**
  17973. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17974. * @param other defines the second operand
  17975. * @param result defines the matrix where to store the multiplication
  17976. * @returns the current matrix
  17977. */
  17978. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17979. /**
  17980. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17981. * @param other defines the second operand
  17982. * @param result defines the array where to store the multiplication
  17983. * @param offset defines the offset in the target array where to start storing values
  17984. * @returns the current matrix
  17985. */
  17986. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17987. /**
  17988. * Check equality between this matrix and a second one
  17989. * @param value defines the second matrix to compare
  17990. * @returns true is the current matrix and the given one values are strictly equal
  17991. */
  17992. equals(value: Matrix): boolean;
  17993. /**
  17994. * Clone the current matrix
  17995. * @returns a new matrix from the current matrix
  17996. */
  17997. clone(): Matrix;
  17998. /**
  17999. * Returns the name of the current matrix class
  18000. * @returns the string "Matrix"
  18001. */
  18002. getClassName(): string;
  18003. /**
  18004. * Gets the hash code of the current matrix
  18005. * @returns the hash code
  18006. */
  18007. getHashCode(): number;
  18008. /**
  18009. * Decomposes the current Matrix into a translation, rotation and scaling components
  18010. * @param scale defines the scale vector3 given as a reference to update
  18011. * @param rotation defines the rotation quaternion given as a reference to update
  18012. * @param translation defines the translation vector3 given as a reference to update
  18013. * @returns true if operation was successful
  18014. */
  18015. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18016. /**
  18017. * Gets specific row of the matrix
  18018. * @param index defines the number of the row to get
  18019. * @returns the index-th row of the current matrix as a new Vector4
  18020. */
  18021. getRow(index: number): Nullable<Vector4>;
  18022. /**
  18023. * Sets the index-th row of the current matrix to the vector4 values
  18024. * @param index defines the number of the row to set
  18025. * @param row defines the target vector4
  18026. * @returns the updated current matrix
  18027. */
  18028. setRow(index: number, row: Vector4): Matrix;
  18029. /**
  18030. * Compute the transpose of the matrix
  18031. * @returns the new transposed matrix
  18032. */
  18033. transpose(): Matrix;
  18034. /**
  18035. * Compute the transpose of the matrix and store it in a given matrix
  18036. * @param result defines the target matrix
  18037. * @returns the current matrix
  18038. */
  18039. transposeToRef(result: Matrix): Matrix;
  18040. /**
  18041. * Sets the index-th row of the current matrix with the given 4 x float values
  18042. * @param index defines the row index
  18043. * @param x defines the x component to set
  18044. * @param y defines the y component to set
  18045. * @param z defines the z component to set
  18046. * @param w defines the w component to set
  18047. * @returns the updated current matrix
  18048. */
  18049. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18050. /**
  18051. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18052. * @param scale defines the scale factor
  18053. * @returns a new matrix
  18054. */
  18055. scale(scale: number): Matrix;
  18056. /**
  18057. * Scale the current matrix values by a factor to a given result matrix
  18058. * @param scale defines the scale factor
  18059. * @param result defines the matrix to store the result
  18060. * @returns the current matrix
  18061. */
  18062. scaleToRef(scale: number, result: Matrix): Matrix;
  18063. /**
  18064. * Scale the current matrix values by a factor and add the result to a given matrix
  18065. * @param scale defines the scale factor
  18066. * @param result defines the Matrix to store the result
  18067. * @returns the current matrix
  18068. */
  18069. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18070. /**
  18071. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18072. * @param ref matrix to store the result
  18073. */
  18074. toNormalMatrix(ref: Matrix): void;
  18075. /**
  18076. * Gets only rotation part of the current matrix
  18077. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18078. */
  18079. getRotationMatrix(): Matrix;
  18080. /**
  18081. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18082. * @param result defines the target matrix to store data to
  18083. * @returns the current matrix
  18084. */
  18085. getRotationMatrixToRef(result: Matrix): Matrix;
  18086. /**
  18087. * Creates a matrix from an array
  18088. * @param array defines the source array
  18089. * @param offset defines an offset in the source array
  18090. * @returns a new Matrix set from the starting index of the given array
  18091. */
  18092. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18093. /**
  18094. * Copy the content of an array into a given matrix
  18095. * @param array defines the source array
  18096. * @param offset defines an offset in the source array
  18097. * @param result defines the target matrix
  18098. */
  18099. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18100. /**
  18101. * Stores an array into a matrix after having multiplied each component by a given factor
  18102. * @param array defines the source array
  18103. * @param offset defines the offset in the source array
  18104. * @param scale defines the scaling factor
  18105. * @param result defines the target matrix
  18106. */
  18107. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18108. /**
  18109. * Stores a list of values (16) inside a given matrix
  18110. * @param initialM11 defines 1st value of 1st row
  18111. * @param initialM12 defines 2nd value of 1st row
  18112. * @param initialM13 defines 3rd value of 1st row
  18113. * @param initialM14 defines 4th value of 1st row
  18114. * @param initialM21 defines 1st value of 2nd row
  18115. * @param initialM22 defines 2nd value of 2nd row
  18116. * @param initialM23 defines 3rd value of 2nd row
  18117. * @param initialM24 defines 4th value of 2nd row
  18118. * @param initialM31 defines 1st value of 3rd row
  18119. * @param initialM32 defines 2nd value of 3rd row
  18120. * @param initialM33 defines 3rd value of 3rd row
  18121. * @param initialM34 defines 4th value of 3rd row
  18122. * @param initialM41 defines 1st value of 4th row
  18123. * @param initialM42 defines 2nd value of 4th row
  18124. * @param initialM43 defines 3rd value of 4th row
  18125. * @param initialM44 defines 4th value of 4th row
  18126. * @param result defines the target matrix
  18127. */
  18128. 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;
  18129. /**
  18130. * Gets an identity matrix that must not be updated
  18131. */
  18132. static readonly IdentityReadOnly: Matrix;
  18133. /**
  18134. * Creates new matrix from a list of values (16)
  18135. * @param initialM11 defines 1st value of 1st row
  18136. * @param initialM12 defines 2nd value of 1st row
  18137. * @param initialM13 defines 3rd value of 1st row
  18138. * @param initialM14 defines 4th value of 1st row
  18139. * @param initialM21 defines 1st value of 2nd row
  18140. * @param initialM22 defines 2nd value of 2nd row
  18141. * @param initialM23 defines 3rd value of 2nd row
  18142. * @param initialM24 defines 4th value of 2nd row
  18143. * @param initialM31 defines 1st value of 3rd row
  18144. * @param initialM32 defines 2nd value of 3rd row
  18145. * @param initialM33 defines 3rd value of 3rd row
  18146. * @param initialM34 defines 4th value of 3rd row
  18147. * @param initialM41 defines 1st value of 4th row
  18148. * @param initialM42 defines 2nd value of 4th row
  18149. * @param initialM43 defines 3rd value of 4th row
  18150. * @param initialM44 defines 4th value of 4th row
  18151. * @returns the new matrix
  18152. */
  18153. 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;
  18154. /**
  18155. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18156. * @param scale defines the scale vector3
  18157. * @param rotation defines the rotation quaternion
  18158. * @param translation defines the translation vector3
  18159. * @returns a new matrix
  18160. */
  18161. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18162. /**
  18163. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18164. * @param scale defines the scale vector3
  18165. * @param rotation defines the rotation quaternion
  18166. * @param translation defines the translation vector3
  18167. * @param result defines the target matrix
  18168. */
  18169. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18170. /**
  18171. * Creates a new identity matrix
  18172. * @returns a new identity matrix
  18173. */
  18174. static Identity(): Matrix;
  18175. /**
  18176. * Creates a new identity matrix and stores the result in a given matrix
  18177. * @param result defines the target matrix
  18178. */
  18179. static IdentityToRef(result: Matrix): void;
  18180. /**
  18181. * Creates a new zero matrix
  18182. * @returns a new zero matrix
  18183. */
  18184. static Zero(): Matrix;
  18185. /**
  18186. * Creates a new rotation matrix for "angle" radians around the X axis
  18187. * @param angle defines the angle (in radians) to use
  18188. * @return the new matrix
  18189. */
  18190. static RotationX(angle: number): Matrix;
  18191. /**
  18192. * Creates a new matrix as the invert of a given matrix
  18193. * @param source defines the source matrix
  18194. * @returns the new matrix
  18195. */
  18196. static Invert(source: Matrix): Matrix;
  18197. /**
  18198. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18199. * @param angle defines the angle (in radians) to use
  18200. * @param result defines the target matrix
  18201. */
  18202. static RotationXToRef(angle: number, result: Matrix): void;
  18203. /**
  18204. * Creates a new rotation matrix for "angle" radians around the Y axis
  18205. * @param angle defines the angle (in radians) to use
  18206. * @return the new matrix
  18207. */
  18208. static RotationY(angle: number): Matrix;
  18209. /**
  18210. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18211. * @param angle defines the angle (in radians) to use
  18212. * @param result defines the target matrix
  18213. */
  18214. static RotationYToRef(angle: number, result: Matrix): void;
  18215. /**
  18216. * Creates a new rotation matrix for "angle" radians around the Z axis
  18217. * @param angle defines the angle (in radians) to use
  18218. * @return the new matrix
  18219. */
  18220. static RotationZ(angle: number): Matrix;
  18221. /**
  18222. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18223. * @param angle defines the angle (in radians) to use
  18224. * @param result defines the target matrix
  18225. */
  18226. static RotationZToRef(angle: number, result: Matrix): void;
  18227. /**
  18228. * Creates a new rotation matrix for "angle" radians around the given axis
  18229. * @param axis defines the axis to use
  18230. * @param angle defines the angle (in radians) to use
  18231. * @return the new matrix
  18232. */
  18233. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18234. /**
  18235. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18236. * @param axis defines the axis to use
  18237. * @param angle defines the angle (in radians) to use
  18238. * @param result defines the target matrix
  18239. */
  18240. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18241. /**
  18242. * Creates a rotation matrix
  18243. * @param yaw defines the yaw angle in radians (Y axis)
  18244. * @param pitch defines the pitch angle in radians (X axis)
  18245. * @param roll defines the roll angle in radians (X axis)
  18246. * @returns the new rotation matrix
  18247. */
  18248. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18249. /**
  18250. * Creates a rotation matrix and stores it in a given matrix
  18251. * @param yaw defines the yaw angle in radians (Y axis)
  18252. * @param pitch defines the pitch angle in radians (X axis)
  18253. * @param roll defines the roll angle in radians (X axis)
  18254. * @param result defines the target matrix
  18255. */
  18256. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18257. /**
  18258. * Creates a scaling matrix
  18259. * @param x defines the scale factor on X axis
  18260. * @param y defines the scale factor on Y axis
  18261. * @param z defines the scale factor on Z axis
  18262. * @returns the new matrix
  18263. */
  18264. static Scaling(x: number, y: number, z: number): Matrix;
  18265. /**
  18266. * Creates a scaling matrix and stores it in a given matrix
  18267. * @param x defines the scale factor on X axis
  18268. * @param y defines the scale factor on Y axis
  18269. * @param z defines the scale factor on Z axis
  18270. * @param result defines the target matrix
  18271. */
  18272. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18273. /**
  18274. * Creates a translation matrix
  18275. * @param x defines the translation on X axis
  18276. * @param y defines the translation on Y axis
  18277. * @param z defines the translationon Z axis
  18278. * @returns the new matrix
  18279. */
  18280. static Translation(x: number, y: number, z: number): Matrix;
  18281. /**
  18282. * Creates a translation matrix and stores it in a given matrix
  18283. * @param x defines the translation on X axis
  18284. * @param y defines the translation on Y axis
  18285. * @param z defines the translationon Z axis
  18286. * @param result defines the target matrix
  18287. */
  18288. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18289. /**
  18290. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18291. * @param startValue defines the start value
  18292. * @param endValue defines the end value
  18293. * @param gradient defines the gradient factor
  18294. * @returns the new matrix
  18295. */
  18296. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18297. /**
  18298. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18299. * @param startValue defines the start value
  18300. * @param endValue defines the end value
  18301. * @param gradient defines the gradient factor
  18302. * @param result defines the Matrix object where to store data
  18303. */
  18304. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18305. /**
  18306. * Builds a new matrix whose values are computed by:
  18307. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18308. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18309. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18310. * @param startValue defines the first matrix
  18311. * @param endValue defines the second matrix
  18312. * @param gradient defines the gradient between the two matrices
  18313. * @returns the new matrix
  18314. */
  18315. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18316. /**
  18317. * Update a matrix to values which are computed by:
  18318. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18319. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18320. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18321. * @param startValue defines the first matrix
  18322. * @param endValue defines the second matrix
  18323. * @param gradient defines the gradient between the two matrices
  18324. * @param result defines the target matrix
  18325. */
  18326. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18327. /**
  18328. * 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"
  18329. * This function works in left handed mode
  18330. * @param eye defines the final position of the entity
  18331. * @param target defines where the entity should look at
  18332. * @param up defines the up vector for the entity
  18333. * @returns the new matrix
  18334. */
  18335. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18336. /**
  18337. * 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".
  18338. * This function works in left handed mode
  18339. * @param eye defines the final position of the entity
  18340. * @param target defines where the entity should look at
  18341. * @param up defines the up vector for the entity
  18342. * @param result defines the target matrix
  18343. */
  18344. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18345. /**
  18346. * 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"
  18347. * This function works in right handed mode
  18348. * @param eye defines the final position of the entity
  18349. * @param target defines where the entity should look at
  18350. * @param up defines the up vector for the entity
  18351. * @returns the new matrix
  18352. */
  18353. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18354. /**
  18355. * 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".
  18356. * This function works in right handed mode
  18357. * @param eye defines the final position of the entity
  18358. * @param target defines where the entity should look at
  18359. * @param up defines the up vector for the entity
  18360. * @param result defines the target matrix
  18361. */
  18362. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18363. /**
  18364. * Create a left-handed orthographic projection matrix
  18365. * @param width defines the viewport width
  18366. * @param height defines the viewport height
  18367. * @param znear defines the near clip plane
  18368. * @param zfar defines the far clip plane
  18369. * @returns a new matrix as a left-handed orthographic projection matrix
  18370. */
  18371. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18372. /**
  18373. * Store a left-handed orthographic projection to a given matrix
  18374. * @param width defines the viewport width
  18375. * @param height defines the viewport height
  18376. * @param znear defines the near clip plane
  18377. * @param zfar defines the far clip plane
  18378. * @param result defines the target matrix
  18379. */
  18380. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18381. /**
  18382. * Create a left-handed orthographic projection matrix
  18383. * @param left defines the viewport left coordinate
  18384. * @param right defines the viewport right coordinate
  18385. * @param bottom defines the viewport bottom coordinate
  18386. * @param top defines the viewport top coordinate
  18387. * @param znear defines the near clip plane
  18388. * @param zfar defines the far clip plane
  18389. * @returns a new matrix as a left-handed orthographic projection matrix
  18390. */
  18391. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18392. /**
  18393. * Stores a left-handed orthographic projection into a given matrix
  18394. * @param left defines the viewport left coordinate
  18395. * @param right defines the viewport right coordinate
  18396. * @param bottom defines the viewport bottom coordinate
  18397. * @param top defines the viewport top coordinate
  18398. * @param znear defines the near clip plane
  18399. * @param zfar defines the far clip plane
  18400. * @param result defines the target matrix
  18401. */
  18402. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18403. /**
  18404. * Creates a right-handed orthographic projection matrix
  18405. * @param left defines the viewport left coordinate
  18406. * @param right defines the viewport right coordinate
  18407. * @param bottom defines the viewport bottom coordinate
  18408. * @param top defines the viewport top coordinate
  18409. * @param znear defines the near clip plane
  18410. * @param zfar defines the far clip plane
  18411. * @returns a new matrix as a right-handed orthographic projection matrix
  18412. */
  18413. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18414. /**
  18415. * Stores a right-handed orthographic projection into a given matrix
  18416. * @param left defines the viewport left coordinate
  18417. * @param right defines the viewport right coordinate
  18418. * @param bottom defines the viewport bottom coordinate
  18419. * @param top defines the viewport top coordinate
  18420. * @param znear defines the near clip plane
  18421. * @param zfar defines the far clip plane
  18422. * @param result defines the target matrix
  18423. */
  18424. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18425. /**
  18426. * Creates a left-handed perspective projection matrix
  18427. * @param width defines the viewport width
  18428. * @param height defines the viewport height
  18429. * @param znear defines the near clip plane
  18430. * @param zfar defines the far clip plane
  18431. * @returns a new matrix as a left-handed perspective projection matrix
  18432. */
  18433. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18434. /**
  18435. * Creates a left-handed perspective projection matrix
  18436. * @param fov defines the horizontal field of view
  18437. * @param aspect defines the aspect ratio
  18438. * @param znear defines the near clip plane
  18439. * @param zfar defines the far clip plane
  18440. * @returns a new matrix as a left-handed perspective projection matrix
  18441. */
  18442. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18443. /**
  18444. * Stores a left-handed perspective projection into a given matrix
  18445. * @param fov defines the horizontal field of view
  18446. * @param aspect defines the aspect ratio
  18447. * @param znear defines the near clip plane
  18448. * @param zfar defines the far clip plane
  18449. * @param result defines the target matrix
  18450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18451. */
  18452. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18453. /**
  18454. * Creates a right-handed perspective projection matrix
  18455. * @param fov defines the horizontal field of view
  18456. * @param aspect defines the aspect ratio
  18457. * @param znear defines the near clip plane
  18458. * @param zfar defines the far clip plane
  18459. * @returns a new matrix as a right-handed perspective projection matrix
  18460. */
  18461. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18462. /**
  18463. * Stores a right-handed perspective projection into a given matrix
  18464. * @param fov defines the horizontal field of view
  18465. * @param aspect defines the aspect ratio
  18466. * @param znear defines the near clip plane
  18467. * @param zfar defines the far clip plane
  18468. * @param result defines the target matrix
  18469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18470. */
  18471. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18472. /**
  18473. * Stores a perspective projection for WebVR info a given matrix
  18474. * @param fov defines the field of view
  18475. * @param znear defines the near clip plane
  18476. * @param zfar defines the far clip plane
  18477. * @param result defines the target matrix
  18478. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18479. */
  18480. static PerspectiveFovWebVRToRef(fov: {
  18481. upDegrees: number;
  18482. downDegrees: number;
  18483. leftDegrees: number;
  18484. rightDegrees: number;
  18485. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18486. /**
  18487. * Computes a complete transformation matrix
  18488. * @param viewport defines the viewport to use
  18489. * @param world defines the world matrix
  18490. * @param view defines the view matrix
  18491. * @param projection defines the projection matrix
  18492. * @param zmin defines the near clip plane
  18493. * @param zmax defines the far clip plane
  18494. * @returns the transformation matrix
  18495. */
  18496. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18497. /**
  18498. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18499. * @param matrix defines the matrix to use
  18500. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18501. */
  18502. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18503. /**
  18504. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18505. * @param matrix defines the matrix to use
  18506. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18507. */
  18508. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18509. /**
  18510. * Compute the transpose of a given matrix
  18511. * @param matrix defines the matrix to transpose
  18512. * @returns the new matrix
  18513. */
  18514. static Transpose(matrix: Matrix): Matrix;
  18515. /**
  18516. * Compute the transpose of a matrix and store it in a target matrix
  18517. * @param matrix defines the matrix to transpose
  18518. * @param result defines the target matrix
  18519. */
  18520. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18521. /**
  18522. * Computes a reflection matrix from a plane
  18523. * @param plane defines the reflection plane
  18524. * @returns a new matrix
  18525. */
  18526. static Reflection(plane: Plane): Matrix;
  18527. /**
  18528. * Computes a reflection matrix from a plane
  18529. * @param plane defines the reflection plane
  18530. * @param result defines the target matrix
  18531. */
  18532. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18533. /**
  18534. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18535. * @param xaxis defines the value of the 1st axis
  18536. * @param yaxis defines the value of the 2nd axis
  18537. * @param zaxis defines the value of the 3rd axis
  18538. * @param result defines the target matrix
  18539. */
  18540. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18541. /**
  18542. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18543. * @param quat defines the quaternion to use
  18544. * @param result defines the target matrix
  18545. */
  18546. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18547. }
  18548. class Plane {
  18549. normal: Vector3;
  18550. d: number;
  18551. /**
  18552. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18553. */
  18554. constructor(a: number, b: number, c: number, d: number);
  18555. /**
  18556. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18557. */
  18558. asArray(): number[];
  18559. /**
  18560. * Returns a new plane copied from the current Plane.
  18561. */
  18562. clone(): Plane;
  18563. /**
  18564. * Returns the string "Plane".
  18565. */
  18566. getClassName(): string;
  18567. /**
  18568. * Returns the Plane hash code.
  18569. */
  18570. getHashCode(): number;
  18571. /**
  18572. * Normalize the current Plane in place.
  18573. * Returns the updated Plane.
  18574. */
  18575. normalize(): Plane;
  18576. /**
  18577. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18578. */
  18579. transform(transformation: Matrix): Plane;
  18580. /**
  18581. * Returns the dot product (float) of the point coordinates and the plane normal.
  18582. */
  18583. dotCoordinate(point: Vector3): number;
  18584. /**
  18585. * Updates the current Plane from the plane defined by the three given points.
  18586. * Returns the updated Plane.
  18587. */
  18588. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18589. /**
  18590. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18591. */
  18592. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18593. /**
  18594. * Returns the signed distance (float) from the given point to the Plane.
  18595. */
  18596. signedDistanceTo(point: Vector3): number;
  18597. /**
  18598. * Returns a new Plane from the given array.
  18599. */
  18600. static FromArray(array: ArrayLike<number>): Plane;
  18601. /**
  18602. * Returns a new Plane defined by the three given points.
  18603. */
  18604. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18605. /**
  18606. * Returns a new Plane the normal vector to this plane at the given origin point.
  18607. * Note : the vector "normal" is updated because normalized.
  18608. */
  18609. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18610. /**
  18611. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18612. */
  18613. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18614. }
  18615. class Viewport {
  18616. x: number;
  18617. y: number;
  18618. width: number;
  18619. height: number;
  18620. /**
  18621. * Creates a Viewport object located at (x, y) and sized (width, height).
  18622. */
  18623. constructor(x: number, y: number, width: number, height: number);
  18624. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18625. /**
  18626. * Returns a new Viewport copied from the current one.
  18627. */
  18628. clone(): Viewport;
  18629. }
  18630. class Frustum {
  18631. /**
  18632. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18633. */
  18634. static GetPlanes(transform: Matrix): Plane[];
  18635. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18636. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18637. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18638. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18639. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18640. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18641. /**
  18642. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18643. */
  18644. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18645. }
  18646. /** Defines supported spaces */
  18647. enum Space {
  18648. /** Local (object) space */
  18649. LOCAL = 0,
  18650. /** World space */
  18651. WORLD = 1,
  18652. /** Bone space */
  18653. BONE = 2
  18654. }
  18655. /** Defines the 3 main axes */
  18656. class Axis {
  18657. /** X axis */
  18658. static X: Vector3;
  18659. /** Y axis */
  18660. static Y: Vector3;
  18661. /** Z axis */
  18662. static Z: Vector3;
  18663. }
  18664. class BezierCurve {
  18665. /**
  18666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18667. */
  18668. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18669. }
  18670. /**
  18671. * Defines potential orientation for back face culling
  18672. */
  18673. enum Orientation {
  18674. /**
  18675. * Clockwise
  18676. */
  18677. CW = 0,
  18678. /** Counter clockwise */
  18679. CCW = 1
  18680. }
  18681. /**
  18682. * Defines angle representation
  18683. */
  18684. class Angle {
  18685. private _radians;
  18686. /**
  18687. * Creates an Angle object of "radians" radians (float).
  18688. */
  18689. constructor(radians: number);
  18690. /**
  18691. * Get value in degrees
  18692. * @returns the Angle value in degrees (float)
  18693. */
  18694. degrees(): number;
  18695. /**
  18696. * Get value in radians
  18697. * @returns the Angle value in radians (float)
  18698. */
  18699. radians(): number;
  18700. /**
  18701. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18702. * @param a defines first vector
  18703. * @param b defines second vector
  18704. * @returns a new Angle
  18705. */
  18706. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18707. /**
  18708. * Gets a new Angle object from the given float in radians
  18709. * @param radians defines the angle value in radians
  18710. * @returns a new Angle
  18711. */
  18712. static FromRadians(radians: number): Angle;
  18713. /**
  18714. * Gets a new Angle object from the given float in degrees
  18715. * @param degrees defines the angle value in degrees
  18716. * @returns a new Angle
  18717. */
  18718. static FromDegrees(degrees: number): Angle;
  18719. }
  18720. class Arc2 {
  18721. startPoint: Vector2;
  18722. midPoint: Vector2;
  18723. endPoint: Vector2;
  18724. centerPoint: Vector2;
  18725. radius: number;
  18726. angle: Angle;
  18727. startAngle: Angle;
  18728. orientation: Orientation;
  18729. /**
  18730. * Creates an Arc object from the three given points : start, middle and end.
  18731. */
  18732. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18733. }
  18734. class Path2 {
  18735. private _points;
  18736. private _length;
  18737. closed: boolean;
  18738. /**
  18739. * Creates a Path2 object from the starting 2D coordinates x and y.
  18740. */
  18741. constructor(x: number, y: number);
  18742. /**
  18743. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18744. * Returns the updated Path2.
  18745. */
  18746. addLineTo(x: number, y: number): Path2;
  18747. /**
  18748. * 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.
  18749. * Returns the updated Path2.
  18750. */
  18751. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18752. /**
  18753. * Closes the Path2.
  18754. * Returns the Path2.
  18755. */
  18756. close(): Path2;
  18757. /**
  18758. * Returns the Path2 total length (float).
  18759. */
  18760. length(): number;
  18761. /**
  18762. * Returns the Path2 internal array of points.
  18763. */
  18764. getPoints(): Vector2[];
  18765. /**
  18766. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18767. */
  18768. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18769. /**
  18770. * Returns a new Path2 starting at the coordinates (x, y).
  18771. */
  18772. static StartingAt(x: number, y: number): Path2;
  18773. }
  18774. class Path3D {
  18775. path: Vector3[];
  18776. private _curve;
  18777. private _distances;
  18778. private _tangents;
  18779. private _normals;
  18780. private _binormals;
  18781. private _raw;
  18782. /**
  18783. * new Path3D(path, normal, raw)
  18784. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18785. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18786. * path : an array of Vector3, the curve axis of the Path3D
  18787. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18788. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18789. */
  18790. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18791. /**
  18792. * Returns the Path3D array of successive Vector3 designing its curve.
  18793. */
  18794. getCurve(): Vector3[];
  18795. /**
  18796. * Returns an array populated with tangent vectors on each Path3D curve point.
  18797. */
  18798. getTangents(): Vector3[];
  18799. /**
  18800. * Returns an array populated with normal vectors on each Path3D curve point.
  18801. */
  18802. getNormals(): Vector3[];
  18803. /**
  18804. * Returns an array populated with binormal vectors on each Path3D curve point.
  18805. */
  18806. getBinormals(): Vector3[];
  18807. /**
  18808. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18809. */
  18810. getDistances(): number[];
  18811. /**
  18812. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18813. * Returns the same object updated.
  18814. */
  18815. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18816. private _compute;
  18817. private _getFirstNonNullVector;
  18818. private _getLastNonNullVector;
  18819. private _normalVector;
  18820. }
  18821. class Curve3 {
  18822. private _points;
  18823. private _length;
  18824. /**
  18825. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18826. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18827. * @param v1 (Vector3) the control point
  18828. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18829. * @param nbPoints (integer) the wanted number of points in the curve
  18830. */
  18831. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18832. /**
  18833. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18834. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18835. * @param v1 (Vector3) the first control point
  18836. * @param v2 (Vector3) the second control point
  18837. * @param v3 (Vector3) the end point of the Cubic Bezier
  18838. * @param nbPoints (integer) the wanted number of points in the curve
  18839. */
  18840. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18841. /**
  18842. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18843. * @param p1 (Vector3) the origin point of the Hermite Spline
  18844. * @param t1 (Vector3) the tangent vector at the origin point
  18845. * @param p2 (Vector3) the end point of the Hermite Spline
  18846. * @param t2 (Vector3) the tangent vector at the end point
  18847. * @param nbPoints (integer) the wanted number of points in the curve
  18848. */
  18849. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18850. /**
  18851. * Returns a Curve3 object along a CatmullRom Spline curve :
  18852. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18853. * @param nbPoints (integer) the wanted number of points between each curve control points
  18854. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18855. */
  18856. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18857. /**
  18858. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18859. * A Curve3 is designed from a series of successive Vector3.
  18860. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18861. */
  18862. constructor(points: Vector3[]);
  18863. /**
  18864. * Returns the Curve3 stored array of successive Vector3
  18865. */
  18866. getPoints(): Vector3[];
  18867. /**
  18868. * Returns the computed length (float) of the curve.
  18869. */
  18870. length(): number;
  18871. /**
  18872. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18873. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18874. * curveA and curveB keep unchanged.
  18875. */
  18876. continue(curve: Curve3): Curve3;
  18877. private _computeLength;
  18878. }
  18879. class PositionNormalVertex {
  18880. position: Vector3;
  18881. normal: Vector3;
  18882. constructor(position?: Vector3, normal?: Vector3);
  18883. clone(): PositionNormalVertex;
  18884. }
  18885. class PositionNormalTextureVertex {
  18886. position: Vector3;
  18887. normal: Vector3;
  18888. uv: Vector2;
  18889. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18890. clone(): PositionNormalTextureVertex;
  18891. }
  18892. class Tmp {
  18893. static Color3: Color3[];
  18894. static Color4: Color4[];
  18895. static Vector2: Vector2[];
  18896. static Vector3: Vector3[];
  18897. static Vector4: Vector4[];
  18898. static Quaternion: Quaternion[];
  18899. static Matrix: Matrix[];
  18900. }
  18901. }
  18902. declare module BABYLON {
  18903. /**
  18904. * Class representing spherical polynomial coefficients to the 3rd degree
  18905. */
  18906. class SphericalPolynomial {
  18907. /**
  18908. * The x coefficients of the spherical polynomial
  18909. */
  18910. x: Vector3;
  18911. /**
  18912. * The y coefficients of the spherical polynomial
  18913. */
  18914. y: Vector3;
  18915. /**
  18916. * The z coefficients of the spherical polynomial
  18917. */
  18918. z: Vector3;
  18919. /**
  18920. * The xx coefficients of the spherical polynomial
  18921. */
  18922. xx: Vector3;
  18923. /**
  18924. * The yy coefficients of the spherical polynomial
  18925. */
  18926. yy: Vector3;
  18927. /**
  18928. * The zz coefficients of the spherical polynomial
  18929. */
  18930. zz: Vector3;
  18931. /**
  18932. * The xy coefficients of the spherical polynomial
  18933. */
  18934. xy: Vector3;
  18935. /**
  18936. * The yz coefficients of the spherical polynomial
  18937. */
  18938. yz: Vector3;
  18939. /**
  18940. * The zx coefficients of the spherical polynomial
  18941. */
  18942. zx: Vector3;
  18943. /**
  18944. * Adds an ambient color to the spherical polynomial
  18945. * @param color the color to add
  18946. */
  18947. addAmbient(color: Color3): void;
  18948. /**
  18949. * Scales the spherical polynomial by the given amount
  18950. * @param scale the amount to scale
  18951. */
  18952. scale(scale: number): void;
  18953. /**
  18954. * Gets the spherical polynomial from harmonics
  18955. * @param harmonics the spherical harmonics
  18956. * @returns the spherical polynomial
  18957. */
  18958. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18959. /**
  18960. * Constructs a spherical polynomial from an array.
  18961. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18962. * @returns the spherical polynomial
  18963. */
  18964. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18965. }
  18966. /**
  18967. * Class representing spherical harmonics coefficients to the 3rd degree
  18968. */
  18969. class SphericalHarmonics {
  18970. /**
  18971. * The l0,0 coefficients of the spherical harmonics
  18972. */
  18973. l00: Vector3;
  18974. /**
  18975. * The l1,-1 coefficients of the spherical harmonics
  18976. */
  18977. l1_1: Vector3;
  18978. /**
  18979. * The l1,0 coefficients of the spherical harmonics
  18980. */
  18981. l10: Vector3;
  18982. /**
  18983. * The l1,1 coefficients of the spherical harmonics
  18984. */
  18985. l11: Vector3;
  18986. /**
  18987. * The l2,-2 coefficients of the spherical harmonics
  18988. */
  18989. l2_2: Vector3;
  18990. /**
  18991. * The l2,-1 coefficients of the spherical harmonics
  18992. */
  18993. l2_1: Vector3;
  18994. /**
  18995. * The l2,0 coefficients of the spherical harmonics
  18996. */
  18997. l20: Vector3;
  18998. /**
  18999. * The l2,1 coefficients of the spherical harmonics
  19000. */
  19001. l21: Vector3;
  19002. /**
  19003. * The l2,2 coefficients of the spherical harmonics
  19004. */
  19005. lL22: Vector3;
  19006. /**
  19007. * Adds a light to the spherical harmonics
  19008. * @param direction the direction of the light
  19009. * @param color the color of the light
  19010. * @param deltaSolidAngle the delta solid angle of the light
  19011. */
  19012. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19013. /**
  19014. * Scales the spherical harmonics by the given amount
  19015. * @param scale the amount to scale
  19016. */
  19017. scale(scale: number): void;
  19018. /**
  19019. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19020. *
  19021. * ```
  19022. * E_lm = A_l * L_lm
  19023. * ```
  19024. *
  19025. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19026. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19027. * the scaling factors are given in equation 9.
  19028. */
  19029. convertIncidentRadianceToIrradiance(): void;
  19030. /**
  19031. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19032. *
  19033. * ```
  19034. * L = (1/pi) * E * rho
  19035. * ```
  19036. *
  19037. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19038. */
  19039. convertIrradianceToLambertianRadiance(): void;
  19040. /**
  19041. * Gets the spherical harmonics from polynomial
  19042. * @param polynomial the spherical polynomial
  19043. * @returns the spherical harmonics
  19044. */
  19045. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19046. /**
  19047. * Constructs a spherical harmonics from an array.
  19048. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19049. * @returns the spherical harmonics
  19050. */
  19051. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19052. }
  19053. }
  19054. declare module BABYLON {
  19055. /**
  19056. * Class used to store all common mesh properties
  19057. */
  19058. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19059. /** No occlusion */
  19060. static OCCLUSION_TYPE_NONE: number;
  19061. /** Occlusion set to optimisitic */
  19062. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19063. /** Occlusion set to strict */
  19064. static OCCLUSION_TYPE_STRICT: number;
  19065. /** Use an accurante occlusion algorithm */
  19066. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19067. /** Use a conservative occlusion algorithm */
  19068. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19069. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19070. static readonly CULLINGSTRATEGY_STANDARD: number;
  19071. /** Culling strategy with bounding sphere only and then frustum culling */
  19072. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19073. /**
  19074. * No billboard
  19075. */
  19076. static readonly BILLBOARDMODE_NONE: number;
  19077. /** Billboard on X axis */
  19078. static readonly BILLBOARDMODE_X: number;
  19079. /** Billboard on Y axis */
  19080. static readonly BILLBOARDMODE_Y: number;
  19081. /** Billboard on Z axis */
  19082. static readonly BILLBOARDMODE_Z: number;
  19083. /** Billboard on all axes */
  19084. static readonly BILLBOARDMODE_ALL: number;
  19085. private _facetPositions;
  19086. private _facetNormals;
  19087. private _facetPartitioning;
  19088. private _facetNb;
  19089. private _partitioningSubdivisions;
  19090. private _partitioningBBoxRatio;
  19091. private _facetDataEnabled;
  19092. private _facetParameters;
  19093. private _bbSize;
  19094. private _subDiv;
  19095. private _facetDepthSort;
  19096. private _facetDepthSortEnabled;
  19097. private _depthSortedIndices;
  19098. private _depthSortedFacets;
  19099. private _facetDepthSortFunction;
  19100. private _facetDepthSortFrom;
  19101. private _facetDepthSortOrigin;
  19102. private _invertedMatrix;
  19103. /** Gets ot sets the culling strategy to use to find visible meshes */
  19104. cullingStrategy: number;
  19105. /**
  19106. * Gets the number of facets in the mesh
  19107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19108. */
  19109. readonly facetNb: number;
  19110. /**
  19111. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19113. */
  19114. partitioningSubdivisions: number;
  19115. /**
  19116. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19117. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19119. */
  19120. partitioningBBoxRatio: number;
  19121. /**
  19122. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19123. * Works only for updatable meshes.
  19124. * Doesn't work with multi-materials
  19125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19126. */
  19127. mustDepthSortFacets: boolean;
  19128. /**
  19129. * The location (Vector3) where the facet depth sort must be computed from.
  19130. * By default, the active camera position.
  19131. * Used only when facet depth sort is enabled
  19132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19133. */
  19134. facetDepthSortFrom: Vector3;
  19135. /**
  19136. * gets a boolean indicating if facetData is enabled
  19137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19138. */
  19139. readonly isFacetDataEnabled: boolean;
  19140. /** @hidden */
  19141. /**
  19142. * An event triggered when this mesh collides with another one
  19143. */
  19144. onCollideObservable: Observable<AbstractMesh>;
  19145. private _onCollideObserver;
  19146. /** Set a function to call when this mesh collides with another one */
  19147. onCollide: () => void;
  19148. /**
  19149. * An event triggered when the collision's position changes
  19150. */
  19151. onCollisionPositionChangeObservable: Observable<Vector3>;
  19152. private _onCollisionPositionChangeObserver;
  19153. /** Set a function to call when the collision's position changes */
  19154. onCollisionPositionChange: () => void;
  19155. /**
  19156. * An event triggered when material is changed
  19157. */
  19158. onMaterialChangedObservable: Observable<AbstractMesh>;
  19159. /**
  19160. * Gets or sets the orientation for POV movement & rotation
  19161. */
  19162. definedFacingForward: boolean;
  19163. /**
  19164. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19165. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19166. * * 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.
  19167. * @see http://doc.babylonjs.com/features/occlusionquery
  19168. */
  19169. occlusionQueryAlgorithmType: number;
  19170. /**
  19171. * 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:
  19172. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19173. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19174. * * 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.
  19175. * @see http://doc.babylonjs.com/features/occlusionquery
  19176. */
  19177. occlusionType: number;
  19178. /**
  19179. * 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.
  19180. * The default value is -1 which means don't break the query and wait till the result
  19181. * @see http://doc.babylonjs.com/features/occlusionquery
  19182. */
  19183. occlusionRetryCount: number;
  19184. /** @hidden */
  19185. /** @hidden */
  19186. /**
  19187. * 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
  19188. * @see http://doc.babylonjs.com/features/occlusionquery
  19189. */
  19190. isOccluded: boolean;
  19191. /** @hidden */
  19192. /**
  19193. * Flag to check the progress status of the query
  19194. * @see http://doc.babylonjs.com/features/occlusionquery
  19195. */
  19196. readonly isOcclusionQueryInProgress: boolean;
  19197. /** @hidden */
  19198. private _visibility;
  19199. /**
  19200. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19201. */
  19202. /**
  19203. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19204. */
  19205. visibility: number;
  19206. /** Gets or sets the alpha index used to sort transparent meshes
  19207. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19208. */
  19209. alphaIndex: number;
  19210. /**
  19211. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19212. */
  19213. isVisible: boolean;
  19214. /**
  19215. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19216. */
  19217. isPickable: boolean;
  19218. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19219. showSubMeshesBoundingBox: boolean;
  19220. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19221. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19222. */
  19223. isBlocker: boolean;
  19224. /**
  19225. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19226. */
  19227. enablePointerMoveEvents: boolean;
  19228. /**
  19229. * Specifies the rendering group id for this mesh (0 by default)
  19230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19231. */
  19232. renderingGroupId: number;
  19233. private _material;
  19234. /** Gets or sets current material */
  19235. material: Nullable<Material>;
  19236. private _receiveShadows;
  19237. /**
  19238. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19239. * @see http://doc.babylonjs.com/babylon101/shadows
  19240. */
  19241. receiveShadows: boolean;
  19242. /** Defines color to use when rendering outline */
  19243. outlineColor: Color3;
  19244. /** Define width to use when rendering outline */
  19245. outlineWidth: number;
  19246. /** Defines color to use when rendering overlay */
  19247. overlayColor: Color3;
  19248. /** Defines alpha to use when rendering overlay */
  19249. overlayAlpha: number;
  19250. private _hasVertexAlpha;
  19251. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19252. hasVertexAlpha: boolean;
  19253. private _useVertexColors;
  19254. /** 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) */
  19255. useVertexColors: boolean;
  19256. private _computeBonesUsingShaders;
  19257. /**
  19258. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19259. */
  19260. computeBonesUsingShaders: boolean;
  19261. private _numBoneInfluencers;
  19262. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19263. numBoneInfluencers: number;
  19264. private _applyFog;
  19265. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19266. applyFog: boolean;
  19267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19268. useOctreeForRenderingSelection: boolean;
  19269. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19270. useOctreeForPicking: boolean;
  19271. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19272. useOctreeForCollisions: boolean;
  19273. private _layerMask;
  19274. /**
  19275. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19276. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19277. */
  19278. layerMask: number;
  19279. /**
  19280. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19281. */
  19282. alwaysSelectAsActiveMesh: boolean;
  19283. /**
  19284. * Gets or sets the current action manager
  19285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19286. */
  19287. actionManager: Nullable<ActionManager>;
  19288. /**
  19289. * Gets or sets impostor used for physic simulation
  19290. * @see http://doc.babylonjs.com/features/physics_engine
  19291. */
  19292. physicsImpostor: Nullable<PhysicsImpostor>;
  19293. private _checkCollisions;
  19294. private _collisionMask;
  19295. private _collisionGroup;
  19296. /**
  19297. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19299. */
  19300. ellipsoid: Vector3;
  19301. /**
  19302. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19304. */
  19305. ellipsoidOffset: Vector3;
  19306. private _collider;
  19307. private _oldPositionForCollisions;
  19308. private _diffPositionForCollisions;
  19309. /**
  19310. * Gets or sets a collision mask used to mask collisions (default is -1).
  19311. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19312. */
  19313. collisionMask: number;
  19314. /**
  19315. * Gets or sets the current collision group mask (-1 by default).
  19316. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19317. */
  19318. collisionGroup: number;
  19319. /**
  19320. * Defines edge width used when edgesRenderer is enabled
  19321. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19322. */
  19323. edgesWidth: number;
  19324. /**
  19325. * Defines edge color used when edgesRenderer is enabled
  19326. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19327. */
  19328. edgesColor: Color4;
  19329. /** @hidden */
  19330. private _collisionsTransformMatrix;
  19331. private _collisionsScalingMatrix;
  19332. /** @hidden */
  19333. /** @hidden */
  19334. /** @hidden */
  19335. /**
  19336. * Gets or sets the list of subMeshes
  19337. * @see http://doc.babylonjs.com/how_to/multi_materials
  19338. */
  19339. subMeshes: SubMesh[];
  19340. /** @hidden */
  19341. /** @hidden */
  19342. /** @hidden */
  19343. /** @hidden */
  19344. protected readonly _positions: Nullable<Vector3[]>;
  19345. /** @hidden */
  19346. /** @hidden */
  19347. private _skeleton;
  19348. /** @hidden */
  19349. /**
  19350. * Gets or sets a skeleton to apply skining transformations
  19351. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19352. */
  19353. skeleton: Nullable<Skeleton>;
  19354. /**
  19355. * An event triggered when the mesh is rebuilt.
  19356. */
  19357. onRebuildObservable: Observable<AbstractMesh>;
  19358. /**
  19359. * Creates a new AbstractMesh
  19360. * @param name defines the name of the mesh
  19361. * @param scene defines the hosting scene
  19362. */
  19363. constructor(name: string, scene?: Nullable<Scene>);
  19364. /**
  19365. * Returns the string "AbstractMesh"
  19366. * @returns "AbstractMesh"
  19367. */
  19368. getClassName(): string;
  19369. /**
  19370. * Gets a string representation of the current mesh
  19371. * @param fullDetails defines a boolean indicating if full details must be included
  19372. * @returns a string representation of the current mesh
  19373. */
  19374. toString(fullDetails?: boolean): string;
  19375. /** @hidden */
  19376. /** @hidden */
  19377. /** @hidden */
  19378. /** @hidden */
  19379. /** @hidden */
  19380. private _markSubMeshesAsDirty;
  19381. /** @hidden */
  19382. /** @hidden */
  19383. /** @hidden */
  19384. /**
  19385. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19386. */
  19387. scaling: Vector3;
  19388. /**
  19389. * Returns true if the mesh is blocked. Implemented by child classes
  19390. */
  19391. readonly isBlocked: boolean;
  19392. /**
  19393. * Returns the mesh itself by default. Implemented by child classes
  19394. * @param camera defines the camera to use to pick the right LOD level
  19395. * @returns the currentAbstractMesh
  19396. */
  19397. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19398. /**
  19399. * Returns 0 by default. Implemented by child classes
  19400. * @returns an integer
  19401. */
  19402. getTotalVertices(): number;
  19403. /**
  19404. * Returns null by default. Implemented by child classes
  19405. * @returns null
  19406. */
  19407. getIndices(): Nullable<IndicesArray>;
  19408. /**
  19409. * Returns the array of the requested vertex data kind. Implemented by child classes
  19410. * @param kind defines the vertex data kind to use
  19411. * @returns null
  19412. */
  19413. getVerticesData(kind: string): Nullable<FloatArray>;
  19414. /**
  19415. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19416. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19417. * Note that a new underlying VertexBuffer object is created each call.
  19418. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19419. * @param kind defines vertex data kind:
  19420. * * BABYLON.VertexBuffer.PositionKind
  19421. * * BABYLON.VertexBuffer.UVKind
  19422. * * BABYLON.VertexBuffer.UV2Kind
  19423. * * BABYLON.VertexBuffer.UV3Kind
  19424. * * BABYLON.VertexBuffer.UV4Kind
  19425. * * BABYLON.VertexBuffer.UV5Kind
  19426. * * BABYLON.VertexBuffer.UV6Kind
  19427. * * BABYLON.VertexBuffer.ColorKind
  19428. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19429. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19430. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19431. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19432. * @param data defines the data source
  19433. * @param updatable defines if the data must be flagged as updatable (or static)
  19434. * @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
  19435. * @returns the current mesh
  19436. */
  19437. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19438. /**
  19439. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19440. * If the mesh has no geometry, it is simply returned as it is.
  19441. * @param kind defines vertex data kind:
  19442. * * BABYLON.VertexBuffer.PositionKind
  19443. * * BABYLON.VertexBuffer.UVKind
  19444. * * BABYLON.VertexBuffer.UV2Kind
  19445. * * BABYLON.VertexBuffer.UV3Kind
  19446. * * BABYLON.VertexBuffer.UV4Kind
  19447. * * BABYLON.VertexBuffer.UV5Kind
  19448. * * BABYLON.VertexBuffer.UV6Kind
  19449. * * BABYLON.VertexBuffer.ColorKind
  19450. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19451. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19452. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19453. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19454. * @param data defines the data source
  19455. * @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
  19456. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19457. * @returns the current mesh
  19458. */
  19459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19460. /**
  19461. * Sets the mesh indices,
  19462. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19463. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19464. * @param totalVertices Defines the total number of vertices
  19465. * @returns the current mesh
  19466. */
  19467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19468. /**
  19469. * Gets a boolean indicating if specific vertex data is present
  19470. * @param kind defines the vertex data kind to use
  19471. * @returns true is data kind is present
  19472. */
  19473. isVerticesDataPresent(kind: string): boolean;
  19474. /**
  19475. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19476. * @returns a BoundingInfo
  19477. */
  19478. getBoundingInfo(): BoundingInfo;
  19479. /**
  19480. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19481. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19482. * @returns the current mesh
  19483. */
  19484. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19485. /**
  19486. * Overwrite the current bounding info
  19487. * @param boundingInfo defines the new bounding info
  19488. * @returns the current mesh
  19489. */
  19490. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19491. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19492. readonly useBones: boolean;
  19493. /** @hidden */
  19494. /** @hidden */
  19495. /** @hidden */
  19496. /**
  19497. * Gets the current world matrix
  19498. * @returns a Matrix
  19499. */
  19500. getWorldMatrix(): Matrix;
  19501. /** @hidden */
  19502. /**
  19503. * Perform relative position change from the point of view of behind the front of the mesh.
  19504. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19505. * Supports definition of mesh facing forward or backward
  19506. * @param amountRight defines the distance on the right axis
  19507. * @param amountUp defines the distance on the up axis
  19508. * @param amountForward defines the distance on the forward axis
  19509. * @returns the current mesh
  19510. */
  19511. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19512. /**
  19513. * Calculate relative position change from the point of view of behind the front of the mesh.
  19514. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19515. * Supports definition of mesh facing forward or backward
  19516. * @param amountRight defines the distance on the right axis
  19517. * @param amountUp defines the distance on the up axis
  19518. * @param amountForward defines the distance on the forward axis
  19519. * @returns the new displacement vector
  19520. */
  19521. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19522. /**
  19523. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19524. * Supports definition of mesh facing forward or backward
  19525. * @param flipBack defines the flip
  19526. * @param twirlClockwise defines the twirl
  19527. * @param tiltRight defines the tilt
  19528. * @returns the current mesh
  19529. */
  19530. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19531. /**
  19532. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19533. * Supports definition of mesh facing forward or backward.
  19534. * @param flipBack defines the flip
  19535. * @param twirlClockwise defines the twirl
  19536. * @param tiltRight defines the tilt
  19537. * @returns the new rotation vector
  19538. */
  19539. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19540. /**
  19541. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19542. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19543. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  19544. * @returns the new bounding vectors
  19545. */
  19546. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19547. min: Vector3;
  19548. max: Vector3;
  19549. };
  19550. /** @hidden */
  19551. /** @hidden */
  19552. /** @hidden */
  19553. protected _afterComputeWorldMatrix(): void;
  19554. /**
  19555. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19556. * A mesh is in the frustum if its bounding box intersects the frustum
  19557. * @param frustumPlanes defines the frustum to test
  19558. * @returns true if the mesh is in the frustum planes
  19559. */
  19560. isInFrustum(frustumPlanes: Plane[]): boolean;
  19561. /**
  19562. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19563. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19564. * @param frustumPlanes defines the frustum to test
  19565. * @returns true if the mesh is completely in the frustum planes
  19566. */
  19567. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19568. /**
  19569. * True if the mesh intersects another mesh or a SolidParticle object
  19570. * @param mesh defines a target mesh or SolidParticle to test
  19571. * @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)
  19572. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19573. * @returns true if there is an intersection
  19574. */
  19575. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19576. /**
  19577. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19578. * @param point defines the point to test
  19579. * @returns true if there is an intersection
  19580. */
  19581. intersectsPoint(point: Vector3): boolean;
  19582. /**
  19583. * Gets the current physics impostor
  19584. * @see http://doc.babylonjs.com/features/physics_engine
  19585. * @returns a physics impostor or null
  19586. */
  19587. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19588. /**
  19589. * Gets the position of the current mesh in camera space
  19590. * @param camera defines the camera to use
  19591. * @returns a position
  19592. */
  19593. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19594. /**
  19595. * Returns the distance from the mesh to the active camera
  19596. * @param camera defines the camera to use
  19597. * @returns the distance
  19598. */
  19599. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19600. /**
  19601. * Apply a physic impulse to the mesh
  19602. * @param force defines the force to apply
  19603. * @param contactPoint defines where to apply the force
  19604. * @returns the current mesh
  19605. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19606. */
  19607. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19608. /**
  19609. * Creates a physic joint between two meshes
  19610. * @param otherMesh defines the other mesh to use
  19611. * @param pivot1 defines the pivot to use on this mesh
  19612. * @param pivot2 defines the pivot to use on the other mesh
  19613. * @param options defines additional options (can be plugin dependent)
  19614. * @returns the current mesh
  19615. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19616. */
  19617. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19618. /**
  19619. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19621. */
  19622. checkCollisions: boolean;
  19623. /**
  19624. * Gets Collider object used to compute collisions (not physics)
  19625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19626. */
  19627. readonly collider: Collider;
  19628. /**
  19629. * Move the mesh using collision engine
  19630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19631. * @param displacement defines the requested displacement vector
  19632. * @returns the current mesh
  19633. */
  19634. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19635. private _onCollisionPositionChange;
  19636. /** @hidden */
  19637. /** @hidden */
  19638. /** @hidden */
  19639. /** @hidden */
  19640. /**
  19641. * Checks if the passed Ray intersects with the mesh
  19642. * @param ray defines the ray to use
  19643. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19644. * @returns the picking info
  19645. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19646. */
  19647. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19648. /**
  19649. * Clones the current mesh
  19650. * @param name defines the mesh name
  19651. * @param newParent defines the new mesh parent
  19652. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19653. * @returns the new mesh
  19654. */
  19655. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19656. /**
  19657. * Disposes all the submeshes of the current meshnp
  19658. * @returns the current mesh
  19659. */
  19660. releaseSubMeshes(): AbstractMesh;
  19661. /**
  19662. * Releases resources associated with this abstract mesh.
  19663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19665. */
  19666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19667. /**
  19668. * Adds the passed mesh as a child to the current mesh
  19669. * @param mesh defines the child mesh
  19670. * @returns the current mesh
  19671. */
  19672. addChild(mesh: AbstractMesh): AbstractMesh;
  19673. /**
  19674. * Removes the passed mesh from the current mesh children list
  19675. * @param mesh defines the child mesh
  19676. * @returns the current mesh
  19677. */
  19678. removeChild(mesh: AbstractMesh): AbstractMesh;
  19679. /** @hidden */
  19680. private _initFacetData;
  19681. /**
  19682. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19683. * This method can be called within the render loop.
  19684. * 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
  19685. * @returns the current mesh
  19686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19687. */
  19688. updateFacetData(): AbstractMesh;
  19689. /**
  19690. * Returns the facetLocalNormals array.
  19691. * The normals are expressed in the mesh local spac
  19692. * @returns an array of Vector3
  19693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19694. */
  19695. getFacetLocalNormals(): Vector3[];
  19696. /**
  19697. * Returns the facetLocalPositions array.
  19698. * The facet positions are expressed in the mesh local space
  19699. * @returns an array of Vector3
  19700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19701. */
  19702. getFacetLocalPositions(): Vector3[];
  19703. /**
  19704. * Returns the facetLocalPartioning array
  19705. * @returns an array of array of numbers
  19706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19707. */
  19708. getFacetLocalPartitioning(): number[][];
  19709. /**
  19710. * Returns the i-th facet position in the world system.
  19711. * This method allocates a new Vector3 per call
  19712. * @param i defines the facet index
  19713. * @returns a new Vector3
  19714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19715. */
  19716. getFacetPosition(i: number): Vector3;
  19717. /**
  19718. * Sets the reference Vector3 with the i-th facet position in the world system
  19719. * @param i defines the facet index
  19720. * @param ref defines the target vector
  19721. * @returns the current mesh
  19722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19723. */
  19724. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19725. /**
  19726. * Returns the i-th facet normal in the world system.
  19727. * This method allocates a new Vector3 per call
  19728. * @param i defines the facet index
  19729. * @returns a new Vector3
  19730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19731. */
  19732. getFacetNormal(i: number): Vector3;
  19733. /**
  19734. * Sets the reference Vector3 with the i-th facet normal in the world system
  19735. * @param i defines the facet index
  19736. * @param ref defines the target vector
  19737. * @returns the current mesh
  19738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19739. */
  19740. getFacetNormalToRef(i: number, ref: Vector3): this;
  19741. /**
  19742. * 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)
  19743. * @param x defines x coordinate
  19744. * @param y defines y coordinate
  19745. * @param z defines z coordinate
  19746. * @returns the array of facet indexes
  19747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19748. */
  19749. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19750. /**
  19751. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19752. * @param projected sets as the (x,y,z) world projection on the facet
  19753. * @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
  19754. * @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
  19755. * @param x defines x coordinate
  19756. * @param y defines y coordinate
  19757. * @param z defines z coordinate
  19758. * @returns the face index if found (or null instead)
  19759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19760. */
  19761. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19762. /**
  19763. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19764. * @param projected sets as the (x,y,z) local projection on the facet
  19765. * @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
  19766. * @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
  19767. * @param x defines x coordinate
  19768. * @param y defines y coordinate
  19769. * @param z defines z coordinate
  19770. * @returns the face index if found (or null instead)
  19771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19772. */
  19773. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19774. /**
  19775. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19776. * @returns the parameters
  19777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19778. */
  19779. getFacetDataParameters(): any;
  19780. /**
  19781. * Disables the feature FacetData and frees the related memory
  19782. * @returns the current mesh
  19783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19784. */
  19785. disableFacetData(): AbstractMesh;
  19786. /**
  19787. * Updates the AbstractMesh indices array
  19788. * @param indices defines the data source
  19789. * @returns the current mesh
  19790. */
  19791. updateIndices(indices: IndicesArray): AbstractMesh;
  19792. /**
  19793. * Creates new normals data for the mesh
  19794. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19795. * @returns the current mesh
  19796. */
  19797. createNormals(updatable: boolean): AbstractMesh;
  19798. /**
  19799. * Align the mesh with a normal
  19800. * @param normal defines the normal to use
  19801. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19802. * @returns the current mesh
  19803. */
  19804. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19805. /** @hidden */
  19806. }
  19807. }
  19808. declare module BABYLON {
  19809. class Buffer {
  19810. private _engine;
  19811. private _buffer;
  19812. /** @hidden */
  19813. private _updatable;
  19814. private _instanced;
  19815. /**
  19816. * Gets the byte stride.
  19817. */
  19818. readonly byteStride: number;
  19819. /**
  19820. * Constructor
  19821. * @param engine the engine
  19822. * @param data the data to use for this buffer
  19823. * @param updatable whether the data is updatable
  19824. * @param stride the stride (optional)
  19825. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19826. * @param instanced whether the buffer is instanced (optional)
  19827. * @param useBytes set to true if the stride in in bytes (optional)
  19828. */
  19829. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19830. /**
  19831. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19832. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19833. * @param offset defines offset in the buffer (0 by default)
  19834. * @param size defines the size in floats of attributes (position is 3 for instance)
  19835. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19836. * @param instanced defines if the vertex buffer contains indexed data
  19837. * @param useBytes defines if the offset and stride are in bytes
  19838. * @returns the new vertex buffer
  19839. */
  19840. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19841. isUpdatable(): boolean;
  19842. getData(): Nullable<DataArray>;
  19843. getBuffer(): Nullable<WebGLBuffer>;
  19844. /**
  19845. * Gets the stride in float32 units (i.e. byte stride / 4).
  19846. * May not be an integer if the byte stride is not divisible by 4.
  19847. * DEPRECATED. Use byteStride instead.
  19848. * @returns the stride in float32 units
  19849. */
  19850. getStrideSize(): number;
  19851. create(data?: Nullable<DataArray>): void;
  19852. /** @hidden */
  19853. update(data: DataArray): void;
  19854. /**
  19855. * Updates the data directly.
  19856. * @param data the new data
  19857. * @param offset the new offset
  19858. * @param vertexCount the vertex count (optional)
  19859. * @param useBytes set to true if the offset is in bytes
  19860. */
  19861. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19862. dispose(): void;
  19863. }
  19864. }
  19865. declare module BABYLON {
  19866. class CSG {
  19867. private polygons;
  19868. matrix: Matrix;
  19869. position: Vector3;
  19870. rotation: Vector3;
  19871. rotationQuaternion: Nullable<Quaternion>;
  19872. scaling: Vector3;
  19873. static FromMesh(mesh: Mesh): CSG;
  19874. private static FromPolygons;
  19875. clone(): CSG;
  19876. union(csg: CSG): CSG;
  19877. unionInPlace(csg: CSG): void;
  19878. subtract(csg: CSG): CSG;
  19879. subtractInPlace(csg: CSG): void;
  19880. intersect(csg: CSG): CSG;
  19881. intersectInPlace(csg: CSG): void;
  19882. inverse(): CSG;
  19883. inverseInPlace(): void;
  19884. copyTransformAttributes(csg: CSG): CSG;
  19885. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19886. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19887. }
  19888. }
  19889. declare module BABYLON {
  19890. /**
  19891. * Class used to store geometry data (vertex buffers + index buffer)
  19892. */
  19893. class Geometry implements IGetSetVerticesData {
  19894. /**
  19895. * Gets or sets the unique ID of the geometry
  19896. */
  19897. id: string;
  19898. /**
  19899. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19900. */
  19901. delayLoadState: number;
  19902. /**
  19903. * Gets the file containing the data to load when running in delay load state
  19904. */
  19905. delayLoadingFile: Nullable<string>;
  19906. /**
  19907. * Callback called when the geometry is updated
  19908. */
  19909. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19910. private _scene;
  19911. private _engine;
  19912. private _meshes;
  19913. private _totalVertices;
  19914. /** @hidden */
  19915. /** @hidden */
  19916. ;
  19917. private _isDisposed;
  19918. private _extend;
  19919. private _boundingBias;
  19920. /** @hidden */
  19921. private _indexBuffer;
  19922. private _indexBufferIsUpdatable;
  19923. /** @hidden */
  19924. /** @hidden */
  19925. /** @hidden */
  19926. private _vertexArrayObjects;
  19927. private _updatable;
  19928. /** @hidden */
  19929. /**
  19930. * 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
  19931. */
  19932. /**
  19933. * 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
  19934. */
  19935. boundingBias: Vector2;
  19936. /**
  19937. * Static function used to attach a new empty geometry to a mesh
  19938. * @param mesh defines the mesh to attach the geometry to
  19939. * @returns the new {BABYLON.Geometry}
  19940. */
  19941. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19942. /**
  19943. * Creates a new geometry
  19944. * @param id defines the unique ID
  19945. * @param scene defines the hosting scene
  19946. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19947. * @param updatable defines if geometry must be updatable (false by default)
  19948. * @param mesh defines the mesh that will be associated with the geometry
  19949. */
  19950. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19951. /**
  19952. * Gets the current extend of the geometry
  19953. */
  19954. readonly extend: {
  19955. minimum: Vector3;
  19956. maximum: Vector3;
  19957. };
  19958. /**
  19959. * Gets the hosting scene
  19960. * @returns the hosting {BABYLON.Scene}
  19961. */
  19962. getScene(): Scene;
  19963. /**
  19964. * Gets the hosting engine
  19965. * @returns the hosting {BABYLON.Engine}
  19966. */
  19967. getEngine(): Engine;
  19968. /**
  19969. * Defines if the geometry is ready to use
  19970. * @returns true if the geometry is ready to be used
  19971. */
  19972. isReady(): boolean;
  19973. /**
  19974. * Gets a value indicating that the geometry should not be serialized
  19975. */
  19976. readonly doNotSerialize: boolean;
  19977. /** @hidden */
  19978. /**
  19979. * Affects all geometry data in one call
  19980. * @param vertexData defines the geometry data
  19981. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19982. */
  19983. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19984. /**
  19985. * Set specific vertex data
  19986. * @param kind defines the data kind (Position, normal, etc...)
  19987. * @param data defines the vertex data to use
  19988. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19989. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19990. */
  19991. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19992. /**
  19993. * Removes a specific vertex data
  19994. * @param kind defines the data kind (Position, normal, etc...)
  19995. */
  19996. removeVerticesData(kind: string): void;
  19997. /**
  19998. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19999. * @param buffer defines the vertex buffer to use
  20000. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20001. */
  20002. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20003. /**
  20004. * Update a specific vertex buffer
  20005. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20006. * It will do nothing if the buffer is not updatable
  20007. * @param kind defines the data kind (Position, normal, etc...)
  20008. * @param data defines the data to use
  20009. * @param offset defines the offset in the target buffer where to store the data
  20010. * @param useBytes set to true if the offset is in bytes
  20011. */
  20012. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20013. /**
  20014. * Update a specific vertex buffer
  20015. * This function will create a new buffer if the current one is not updatable
  20016. * @param kind defines the data kind (Position, normal, etc...)
  20017. * @param data defines the data to use
  20018. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20019. */
  20020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20021. private _updateBoundingInfo;
  20022. /** @hidden */
  20023. /**
  20024. * Gets total number of vertices
  20025. * @returns the total number of vertices
  20026. */
  20027. getTotalVertices(): number;
  20028. /**
  20029. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20030. * @param kind defines the data kind (Position, normal, etc...)
  20031. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20032. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20033. * @returns a float array containing vertex data
  20034. */
  20035. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20036. /**
  20037. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20038. * @param kind defines the data kind (Position, normal, etc...)
  20039. * @returns true if the vertex buffer with the specified kind is updatable
  20040. */
  20041. isVertexBufferUpdatable(kind: string): boolean;
  20042. /**
  20043. * Gets a specific vertex buffer
  20044. * @param kind defines the data kind (Position, normal, etc...)
  20045. * @returns a {BABYLON.VertexBuffer}
  20046. */
  20047. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20048. /**
  20049. * Returns all vertex buffers
  20050. * @return an object holding all vertex buffers indexed by kind
  20051. */
  20052. getVertexBuffers(): Nullable<{
  20053. [key: string]: VertexBuffer;
  20054. }>;
  20055. /**
  20056. * Gets a boolean indicating if specific vertex buffer is present
  20057. * @param kind defines the data kind (Position, normal, etc...)
  20058. * @returns true if data is present
  20059. */
  20060. isVerticesDataPresent(kind: string): boolean;
  20061. /**
  20062. * Gets a list of all attached data kinds (Position, normal, etc...)
  20063. * @returns a list of string containing all kinds
  20064. */
  20065. getVerticesDataKinds(): string[];
  20066. /**
  20067. * Update index buffer
  20068. * @param indices defines the indices to store in the index buffer
  20069. * @param offset defines the offset in the target buffer where to store the data
  20070. */
  20071. updateIndices(indices: IndicesArray, offset?: number): void;
  20072. /**
  20073. * Creates a new index buffer
  20074. * @param indices defines the indices to store in the index buffer
  20075. * @param totalVertices defines the total number of vertices (could be null)
  20076. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20077. */
  20078. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20079. /**
  20080. * Return the total number of indices
  20081. * @returns the total number of indices
  20082. */
  20083. getTotalIndices(): number;
  20084. /**
  20085. * Gets the index buffer array
  20086. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20087. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20088. * @returns the index buffer array
  20089. */
  20090. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20091. /**
  20092. * Gets the index buffer
  20093. * @return the index buffer
  20094. */
  20095. getIndexBuffer(): Nullable<WebGLBuffer>;
  20096. /** @hidden */
  20097. /**
  20098. * Release the associated resources for a specific mesh
  20099. * @param mesh defines the source mesh
  20100. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20101. */
  20102. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20103. /**
  20104. * Apply current geometry to a given mesh
  20105. * @param mesh defines the mesh to apply geometry to
  20106. */
  20107. applyToMesh(mesh: Mesh): void;
  20108. private _updateExtend;
  20109. private _applyToMesh;
  20110. private notifyUpdate;
  20111. /**
  20112. * Load the geometry if it was flagged as delay loaded
  20113. * @param scene defines the hosting scene
  20114. * @param onLoaded defines a callback called when the geometry is loaded
  20115. */
  20116. load(scene: Scene, onLoaded?: () => void): void;
  20117. private _queueLoad;
  20118. /**
  20119. * Invert the geometry to move from a right handed system to a left handed one.
  20120. */
  20121. toLeftHanded(): void;
  20122. /** @hidden */
  20123. /** @hidden */
  20124. /**
  20125. * Gets a value indicating if the geometry is disposed
  20126. * @returns true if the geometry was disposed
  20127. */
  20128. isDisposed(): boolean;
  20129. private _disposeVertexArrayObjects;
  20130. /**
  20131. * Free all associated resources
  20132. */
  20133. dispose(): void;
  20134. /**
  20135. * Clone the current geometry into a new geometry
  20136. * @param id defines the unique ID of the new geometry
  20137. * @returns a new geometry object
  20138. */
  20139. copy(id: string): Geometry;
  20140. /**
  20141. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20142. * @return a JSON representation of the current geometry data (without the vertices data)
  20143. */
  20144. serialize(): any;
  20145. private toNumberArray;
  20146. /**
  20147. * Serialize all vertices data into a JSON oject
  20148. * @returns a JSON representation of the current geometry data
  20149. */
  20150. serializeVerticeData(): any;
  20151. /**
  20152. * Extracts a clone of a mesh geometry
  20153. * @param mesh defines the source mesh
  20154. * @param id defines the unique ID of the new geometry object
  20155. * @returns the new geometry object
  20156. */
  20157. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20158. /**
  20159. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20160. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20161. * Be aware Math.random() could cause collisions, but:
  20162. * "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"
  20163. * @returns a string containing a new GUID
  20164. */
  20165. static RandomId(): string;
  20166. /** @hidden */
  20167. private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20168. private static _CleanMatricesWeights;
  20169. /**
  20170. * Create a new geometry from persisted data (Using .babylon file format)
  20171. * @param parsedVertexData defines the persisted data
  20172. * @param scene defines the hosting scene
  20173. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20174. * @returns the new geometry object
  20175. */
  20176. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20177. }
  20178. /**
  20179. * Abstract class used to provide common services for all typed geometries
  20180. * @hidden
  20181. */
  20182. class _PrimitiveGeometry extends Geometry {
  20183. private _canBeRegenerated;
  20184. private _beingRegenerated;
  20185. /**
  20186. * Creates a new typed geometry
  20187. * @param id defines the unique ID of the geometry
  20188. * @param scene defines the hosting scene
  20189. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20190. * @param mesh defines the hosting mesh (can be null)
  20191. */
  20192. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20193. /**
  20194. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20195. * @returns true if the geometry can be regenerated
  20196. */
  20197. canBeRegenerated(): boolean;
  20198. /**
  20199. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20200. */
  20201. regenerate(): void;
  20202. /**
  20203. * Clone the geometry
  20204. * @param id defines the unique ID of the new geometry
  20205. * @returns the new geometry
  20206. */
  20207. asNewGeometry(id: string): Geometry;
  20208. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20209. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20210. /** @hidden */
  20211. copy(id: string): Geometry;
  20212. serialize(): any;
  20213. }
  20214. /**
  20215. * Creates a ribbon geometry
  20216. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20217. */
  20218. class RibbonGeometry extends _PrimitiveGeometry {
  20219. /**
  20220. * Defines the array of paths to use
  20221. */
  20222. pathArray: Vector3[][];
  20223. /**
  20224. * Defines if the last and first points of each path in your pathArray must be joined
  20225. */
  20226. closeArray: boolean;
  20227. /**
  20228. * Defines if the last and first points of each path in your pathArray must be joined
  20229. */
  20230. closePath: boolean;
  20231. /**
  20232. * Defines the offset between points
  20233. */
  20234. offset: number;
  20235. /**
  20236. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20237. */
  20238. side: number;
  20239. /**
  20240. * Creates a ribbon geometry
  20241. * @param id defines the unique ID of the geometry
  20242. * @param scene defines the hosting scene
  20243. * @param pathArray defines the array of paths to use
  20244. * @param closeArray defines if the last path and the first path must be joined
  20245. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20246. * @param offset defines the offset between points
  20247. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20248. * @param mesh defines the hosting mesh (can be null)
  20249. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20250. */
  20251. constructor(id: string, scene: Scene,
  20252. /**
  20253. * Defines the array of paths to use
  20254. */
  20255. pathArray: Vector3[][],
  20256. /**
  20257. * Defines if the last and first points of each path in your pathArray must be joined
  20258. */
  20259. closeArray: boolean,
  20260. /**
  20261. * Defines if the last and first points of each path in your pathArray must be joined
  20262. */
  20263. closePath: boolean,
  20264. /**
  20265. * Defines the offset between points
  20266. */
  20267. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20268. /**
  20269. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20270. */
  20271. side?: number);
  20272. /** @hidden */
  20273. copy(id: string): Geometry;
  20274. }
  20275. /**
  20276. * Creates a box geometry
  20277. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20278. */
  20279. class BoxGeometry extends _PrimitiveGeometry {
  20280. /**
  20281. * Defines the zise of the box (width, height and depth are the same)
  20282. */
  20283. size: number;
  20284. /**
  20285. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20286. */
  20287. side: number;
  20288. /**
  20289. * Creates a box geometry
  20290. * @param id defines the unique ID of the geometry
  20291. * @param scene defines the hosting scene
  20292. * @param size defines the zise of the box (width, height and depth are the same)
  20293. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20294. * @param mesh defines the hosting mesh (can be null)
  20295. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20296. */
  20297. constructor(id: string, scene: Scene,
  20298. /**
  20299. * Defines the zise of the box (width, height and depth are the same)
  20300. */
  20301. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20302. /**
  20303. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20304. */
  20305. side?: number);
  20306. /** @hidden */
  20307. copy(id: string): Geometry;
  20308. serialize(): any;
  20309. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20310. }
  20311. /**
  20312. * Creates a sphere geometry
  20313. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20314. */
  20315. class SphereGeometry extends _PrimitiveGeometry {
  20316. /**
  20317. * Defines the number of segments to use to create the sphere
  20318. */
  20319. segments: number;
  20320. /**
  20321. * Defines the diameter of the sphere
  20322. */
  20323. diameter: number;
  20324. /**
  20325. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20326. */
  20327. side: number;
  20328. /**
  20329. * Create a new sphere geometry
  20330. * @param id defines the unique ID of the geometry
  20331. * @param scene defines the hosting scene
  20332. * @param segments defines the number of segments to use to create the sphere
  20333. * @param diameter defines the diameter of the sphere
  20334. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20335. * @param mesh defines the hosting mesh (can be null)
  20336. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20337. */
  20338. constructor(id: string, scene: Scene,
  20339. /**
  20340. * Defines the number of segments to use to create the sphere
  20341. */
  20342. segments: number,
  20343. /**
  20344. * Defines the diameter of the sphere
  20345. */
  20346. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20347. /**
  20348. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20349. */
  20350. side?: number);
  20351. /** @hidden */
  20352. copy(id: string): Geometry;
  20353. serialize(): any;
  20354. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20355. }
  20356. /**
  20357. * Creates a disc geometry
  20358. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20359. */
  20360. class DiscGeometry extends _PrimitiveGeometry {
  20361. /**
  20362. * Defines the radius of the disc
  20363. */
  20364. radius: number;
  20365. /**
  20366. * Defines the tesselation factor to apply to the disc
  20367. */
  20368. tessellation: number;
  20369. /**
  20370. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20371. */
  20372. side: number;
  20373. /**
  20374. * Creates a new disc geometry
  20375. * @param id defines the unique ID of the geometry
  20376. * @param scene defines the hosting scene
  20377. * @param radius defines the radius of the disc
  20378. * @param tessellation defines the tesselation factor to apply to the disc
  20379. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20380. * @param mesh defines the hosting mesh (can be null)
  20381. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20382. */
  20383. constructor(id: string, scene: Scene,
  20384. /**
  20385. * Defines the radius of the disc
  20386. */
  20387. radius: number,
  20388. /**
  20389. * Defines the tesselation factor to apply to the disc
  20390. */
  20391. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20392. /**
  20393. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20394. */
  20395. side?: number);
  20396. /** @hidden */
  20397. copy(id: string): Geometry;
  20398. }
  20399. /**
  20400. * Creates a new cylinder geometry
  20401. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20402. */
  20403. class CylinderGeometry extends _PrimitiveGeometry {
  20404. /**
  20405. * Defines the height of the cylinder
  20406. */
  20407. height: number;
  20408. /**
  20409. * Defines the diameter of the cylinder's top cap
  20410. */
  20411. diameterTop: number;
  20412. /**
  20413. * Defines the diameter of the cylinder's bottom cap
  20414. */
  20415. diameterBottom: number;
  20416. /**
  20417. * Defines the tessellation factor to apply to the cylinder
  20418. */
  20419. tessellation: number;
  20420. /**
  20421. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20422. */
  20423. subdivisions: number;
  20424. /**
  20425. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20426. */
  20427. side: number;
  20428. /**
  20429. * Creates a new cylinder geometry
  20430. * @param id defines the unique ID of the geometry
  20431. * @param scene defines the hosting scene
  20432. * @param height defines the height of the cylinder
  20433. * @param diameterTop defines the diameter of the cylinder's top cap
  20434. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20435. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20436. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20437. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20438. * @param mesh defines the hosting mesh (can be null)
  20439. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20440. */
  20441. constructor(id: string, scene: Scene,
  20442. /**
  20443. * Defines the height of the cylinder
  20444. */
  20445. height: number,
  20446. /**
  20447. * Defines the diameter of the cylinder's top cap
  20448. */
  20449. diameterTop: number,
  20450. /**
  20451. * Defines the diameter of the cylinder's bottom cap
  20452. */
  20453. diameterBottom: number,
  20454. /**
  20455. * Defines the tessellation factor to apply to the cylinder
  20456. */
  20457. tessellation: number,
  20458. /**
  20459. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20460. */
  20461. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20462. /**
  20463. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20464. */
  20465. side?: number);
  20466. /** @hidden */
  20467. copy(id: string): Geometry;
  20468. serialize(): any;
  20469. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20470. }
  20471. /**
  20472. * Creates a new torus geometry
  20473. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20474. */
  20475. class TorusGeometry extends _PrimitiveGeometry {
  20476. /**
  20477. * Defines the diameter of the torus
  20478. */
  20479. diameter: number;
  20480. /**
  20481. * Defines the thickness of the torus (ie. internal diameter)
  20482. */
  20483. thickness: number;
  20484. /**
  20485. * Defines the tesselation factor to apply to the torus
  20486. */
  20487. tessellation: number;
  20488. /**
  20489. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20490. */
  20491. side: number;
  20492. /**
  20493. * Creates a new torus geometry
  20494. * @param id defines the unique ID of the geometry
  20495. * @param scene defines the hosting scene
  20496. * @param diameter defines the diameter of the torus
  20497. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20498. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20499. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20500. * @param mesh defines the hosting mesh (can be null)
  20501. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20502. */
  20503. constructor(id: string, scene: Scene,
  20504. /**
  20505. * Defines the diameter of the torus
  20506. */
  20507. diameter: number,
  20508. /**
  20509. * Defines the thickness of the torus (ie. internal diameter)
  20510. */
  20511. thickness: number,
  20512. /**
  20513. * Defines the tesselation factor to apply to the torus
  20514. */
  20515. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20516. /**
  20517. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20518. */
  20519. side?: number);
  20520. /** @hidden */
  20521. copy(id: string): Geometry;
  20522. serialize(): any;
  20523. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20524. }
  20525. /**
  20526. * Creates a new ground geometry
  20527. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20528. */
  20529. class GroundGeometry extends _PrimitiveGeometry {
  20530. /**
  20531. * Defines the width of the ground
  20532. */
  20533. width: number;
  20534. /**
  20535. * Defines the height of the ground
  20536. */
  20537. height: number;
  20538. /**
  20539. * Defines the subdivisions to apply to the ground
  20540. */
  20541. subdivisions: number;
  20542. /**
  20543. * Creates a new ground geometry
  20544. * @param id defines the unique ID of the geometry
  20545. * @param scene defines the hosting scene
  20546. * @param width defines the width of the ground
  20547. * @param height defines the height of the ground
  20548. * @param subdivisions defines the subdivisions to apply to the ground
  20549. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20550. * @param mesh defines the hosting mesh (can be null)
  20551. */
  20552. constructor(id: string, scene: Scene,
  20553. /**
  20554. * Defines the width of the ground
  20555. */
  20556. width: number,
  20557. /**
  20558. * Defines the height of the ground
  20559. */
  20560. height: number,
  20561. /**
  20562. * Defines the subdivisions to apply to the ground
  20563. */
  20564. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20565. /** @hidden */
  20566. copy(id: string): Geometry;
  20567. serialize(): any;
  20568. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20569. }
  20570. /**
  20571. * Creates a tiled ground geometry
  20572. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20573. */
  20574. class TiledGroundGeometry extends _PrimitiveGeometry {
  20575. /**
  20576. * Defines the minimum value on X axis
  20577. */
  20578. xmin: number;
  20579. /**
  20580. * Defines the minimum value on Z axis
  20581. */
  20582. zmin: number;
  20583. /**
  20584. * Defines the maximum value on X axis
  20585. */
  20586. xmax: number;
  20587. /**
  20588. * Defines the maximum value on Z axis
  20589. */
  20590. zmax: number;
  20591. /**
  20592. * Defines the subdivisions to apply to the ground
  20593. */
  20594. subdivisions: {
  20595. w: number;
  20596. h: number;
  20597. };
  20598. /**
  20599. * Defines the precision to use when computing the tiles
  20600. */
  20601. precision: {
  20602. w: number;
  20603. h: number;
  20604. };
  20605. /**
  20606. * Creates a tiled ground geometry
  20607. * @param id defines the unique ID of the geometry
  20608. * @param scene defines the hosting scene
  20609. * @param xmin defines the minimum value on X axis
  20610. * @param zmin defines the minimum value on Z axis
  20611. * @param xmax defines the maximum value on X axis
  20612. * @param zmax defines the maximum value on Z axis
  20613. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20614. * @param precision defines the precision to use when computing the tiles
  20615. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20616. * @param mesh defines the hosting mesh (can be null)
  20617. */
  20618. constructor(id: string, scene: Scene,
  20619. /**
  20620. * Defines the minimum value on X axis
  20621. */
  20622. xmin: number,
  20623. /**
  20624. * Defines the minimum value on Z axis
  20625. */
  20626. zmin: number,
  20627. /**
  20628. * Defines the maximum value on X axis
  20629. */
  20630. xmax: number,
  20631. /**
  20632. * Defines the maximum value on Z axis
  20633. */
  20634. zmax: number,
  20635. /**
  20636. * Defines the subdivisions to apply to the ground
  20637. */
  20638. subdivisions: {
  20639. w: number;
  20640. h: number;
  20641. },
  20642. /**
  20643. * Defines the precision to use when computing the tiles
  20644. */
  20645. precision: {
  20646. w: number;
  20647. h: number;
  20648. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20649. /** @hidden */
  20650. copy(id: string): Geometry;
  20651. }
  20652. /**
  20653. * Creates a plane geometry
  20654. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20655. */
  20656. class PlaneGeometry extends _PrimitiveGeometry {
  20657. /**
  20658. * Defines the size of the plane (width === height)
  20659. */
  20660. size: number;
  20661. /**
  20662. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20663. */
  20664. side: number;
  20665. /**
  20666. * Creates a plane geometry
  20667. * @param id defines the unique ID of the geometry
  20668. * @param scene defines the hosting scene
  20669. * @param size defines the size of the plane (width === height)
  20670. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20671. * @param mesh defines the hosting mesh (can be null)
  20672. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20673. */
  20674. constructor(id: string, scene: Scene,
  20675. /**
  20676. * Defines the size of the plane (width === height)
  20677. */
  20678. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20679. /**
  20680. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20681. */
  20682. side?: number);
  20683. /** @hidden */
  20684. copy(id: string): Geometry;
  20685. serialize(): any;
  20686. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20687. }
  20688. /**
  20689. * Creates a torus knot geometry
  20690. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20691. */
  20692. class TorusKnotGeometry extends _PrimitiveGeometry {
  20693. /**
  20694. * Defines the radius of the torus knot
  20695. */
  20696. radius: number;
  20697. /**
  20698. * Defines the thickness of the torus knot tube
  20699. */
  20700. tube: number;
  20701. /**
  20702. * Defines the number of radial segments
  20703. */
  20704. radialSegments: number;
  20705. /**
  20706. * Defines the number of tubular segments
  20707. */
  20708. tubularSegments: number;
  20709. /**
  20710. * Defines the first number of windings
  20711. */
  20712. p: number;
  20713. /**
  20714. * Defines the second number of windings
  20715. */
  20716. q: number;
  20717. /**
  20718. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20719. */
  20720. side: number;
  20721. /**
  20722. * Creates a torus knot geometry
  20723. * @param id defines the unique ID of the geometry
  20724. * @param scene defines the hosting scene
  20725. * @param radius defines the radius of the torus knot
  20726. * @param tube defines the thickness of the torus knot tube
  20727. * @param radialSegments defines the number of radial segments
  20728. * @param tubularSegments defines the number of tubular segments
  20729. * @param p defines the first number of windings
  20730. * @param q defines the second number of windings
  20731. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20732. * @param mesh defines the hosting mesh (can be null)
  20733. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20734. */
  20735. constructor(id: string, scene: Scene,
  20736. /**
  20737. * Defines the radius of the torus knot
  20738. */
  20739. radius: number,
  20740. /**
  20741. * Defines the thickness of the torus knot tube
  20742. */
  20743. tube: number,
  20744. /**
  20745. * Defines the number of radial segments
  20746. */
  20747. radialSegments: number,
  20748. /**
  20749. * Defines the number of tubular segments
  20750. */
  20751. tubularSegments: number,
  20752. /**
  20753. * Defines the first number of windings
  20754. */
  20755. p: number,
  20756. /**
  20757. * Defines the second number of windings
  20758. */
  20759. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20760. /**
  20761. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20762. */
  20763. side?: number);
  20764. /** @hidden */
  20765. copy(id: string): Geometry;
  20766. serialize(): any;
  20767. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20768. }
  20769. }
  20770. declare module BABYLON {
  20771. class GroundMesh extends Mesh {
  20772. generateOctree: boolean;
  20773. private _heightQuads;
  20774. /** @hidden */
  20775. /** @hidden */
  20776. /** @hidden */
  20777. /** @hidden */
  20778. /** @hidden */
  20779. /** @hidden */
  20780. /** @hidden */
  20781. /** @hidden */
  20782. constructor(name: string, scene: Scene);
  20783. getClassName(): string;
  20784. readonly subdivisions: number;
  20785. readonly subdivisionsX: number;
  20786. readonly subdivisionsY: number;
  20787. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20788. /**
  20789. * Returns a height (y) value in the Worl system :
  20790. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20791. * Returns the ground y position if (x, z) are outside the ground surface.
  20792. */
  20793. getHeightAtCoordinates(x: number, z: number): number;
  20794. /**
  20795. * Returns a normalized vector (Vector3) orthogonal to the ground
  20796. * at the ground coordinates (x, z) expressed in the World system.
  20797. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20798. */
  20799. getNormalAtCoordinates(x: number, z: number): Vector3;
  20800. /**
  20801. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20802. * at the ground coordinates (x, z) expressed in the World system.
  20803. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20804. * Returns the GroundMesh.
  20805. */
  20806. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20807. /**
  20808. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20809. * if the ground has been updated.
  20810. * This can be used in the render loop.
  20811. * Returns the GroundMesh.
  20812. */
  20813. updateCoordinateHeights(): GroundMesh;
  20814. private _getFacetAt;
  20815. private _initHeightQuads;
  20816. private _computeHeightQuads;
  20817. serialize(serializationObject: any): void;
  20818. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20819. }
  20820. }
  20821. declare module BABYLON {
  20822. /**
  20823. * Creates an instance based on a source mesh.
  20824. */
  20825. class InstancedMesh extends AbstractMesh {
  20826. private _sourceMesh;
  20827. private _currentLOD;
  20828. constructor(name: string, source: Mesh);
  20829. /**
  20830. * Returns the string "InstancedMesh".
  20831. */
  20832. getClassName(): string;
  20833. readonly receiveShadows: boolean;
  20834. readonly material: Nullable<Material>;
  20835. readonly visibility: number;
  20836. readonly skeleton: Nullable<Skeleton>;
  20837. renderingGroupId: number;
  20838. /**
  20839. * Returns the total number of vertices (integer).
  20840. */
  20841. getTotalVertices(): number;
  20842. readonly sourceMesh: Mesh;
  20843. /**
  20844. * Is this node ready to be used/rendered
  20845. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20846. * @return {boolean} is it ready
  20847. */
  20848. isReady(completeCheck?: boolean): boolean;
  20849. /**
  20850. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20851. */
  20852. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20853. /**
  20854. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20855. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20856. * The `data` are either a numeric array either a Float32Array.
  20857. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20858. * 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).
  20859. * Note that a new underlying VertexBuffer object is created each call.
  20860. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20861. *
  20862. * Possible `kind` values :
  20863. * - BABYLON.VertexBuffer.PositionKind
  20864. * - BABYLON.VertexBuffer.UVKind
  20865. * - BABYLON.VertexBuffer.UV2Kind
  20866. * - BABYLON.VertexBuffer.UV3Kind
  20867. * - BABYLON.VertexBuffer.UV4Kind
  20868. * - BABYLON.VertexBuffer.UV5Kind
  20869. * - BABYLON.VertexBuffer.UV6Kind
  20870. * - BABYLON.VertexBuffer.ColorKind
  20871. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20872. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20873. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20874. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20875. *
  20876. * Returns the Mesh.
  20877. */
  20878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20879. /**
  20880. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20881. * If the mesh has no geometry, it is simply returned as it is.
  20882. * The `data` are either a numeric array either a Float32Array.
  20883. * No new underlying VertexBuffer object is created.
  20884. * 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.
  20885. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20886. *
  20887. * Possible `kind` values :
  20888. * - BABYLON.VertexBuffer.PositionKind
  20889. * - BABYLON.VertexBuffer.UVKind
  20890. * - BABYLON.VertexBuffer.UV2Kind
  20891. * - BABYLON.VertexBuffer.UV3Kind
  20892. * - BABYLON.VertexBuffer.UV4Kind
  20893. * - BABYLON.VertexBuffer.UV5Kind
  20894. * - BABYLON.VertexBuffer.UV6Kind
  20895. * - BABYLON.VertexBuffer.ColorKind
  20896. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20897. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20898. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20899. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20900. *
  20901. * Returns the Mesh.
  20902. */
  20903. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20904. /**
  20905. * Sets the mesh indices.
  20906. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20907. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20908. * This method creates a new index buffer each call.
  20909. * Returns the Mesh.
  20910. */
  20911. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20912. /**
  20913. * Boolean : True if the mesh owns the requested kind of data.
  20914. */
  20915. isVerticesDataPresent(kind: string): boolean;
  20916. /**
  20917. * Returns an array of indices (IndicesArray).
  20918. */
  20919. getIndices(): Nullable<IndicesArray>;
  20920. protected readonly _positions: Nullable<Vector3[]>;
  20921. /**
  20922. * Sets a new updated BoundingInfo to the mesh.
  20923. * Returns the mesh.
  20924. */
  20925. refreshBoundingInfo(): InstancedMesh;
  20926. /** @hidden */
  20927. /** @hidden */
  20928. /**
  20929. * Returns the current associated LOD AbstractMesh.
  20930. */
  20931. getLOD(camera: Camera): AbstractMesh;
  20932. /** @hidden */
  20933. /** @hidden */
  20934. /**
  20935. * Creates a new InstancedMesh from the current mesh.
  20936. * - name (string) : the cloned mesh name
  20937. * - newParent (optional Node) : the optional Node to parent the clone to.
  20938. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20939. *
  20940. * Returns the clone.
  20941. */
  20942. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20943. /**
  20944. * Disposes the InstancedMesh.
  20945. * Returns nothing.
  20946. */
  20947. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20948. }
  20949. }
  20950. declare module BABYLON {
  20951. class LinesMesh extends Mesh {
  20952. useVertexColor?: boolean | undefined;
  20953. useVertexAlpha?: boolean | undefined;
  20954. color: Color3;
  20955. alpha: number;
  20956. /**
  20957. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20958. * This margin is expressed in world space coordinates, so its value may vary.
  20959. * Default value is 0.1
  20960. * @returns the intersection Threshold value.
  20961. */
  20962. /**
  20963. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20964. * This margin is expressed in world space coordinates, so its value may vary.
  20965. * @param value the new threshold to apply
  20966. */
  20967. intersectionThreshold: number;
  20968. private _intersectionThreshold;
  20969. private _colorShader;
  20970. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20971. /**
  20972. * Returns the string "LineMesh"
  20973. */
  20974. getClassName(): string;
  20975. /**
  20976. * @hidden
  20977. */
  20978. /**
  20979. * @hidden
  20980. */
  20981. material: Material;
  20982. /**
  20983. * @hidden
  20984. */
  20985. readonly checkCollisions: boolean;
  20986. createInstance(name: string): InstancedMesh;
  20987. /** @hidden */
  20988. /** @hidden */
  20989. dispose(doNotRecurse?: boolean): void;
  20990. /**
  20991. * Returns a new LineMesh object cloned from the current one.
  20992. */
  20993. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20994. }
  20995. }
  20996. declare module BABYLON {
  20997. /**
  20998. * @hidden
  20999. **/
  21000. class _InstancesBatch {
  21001. mustReturn: boolean;
  21002. visibleInstances: Nullable<InstancedMesh[]>[];
  21003. renderSelf: boolean[];
  21004. }
  21005. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21006. private static _FRONTSIDE: number;
  21007. private static _BACKSIDE: number;
  21008. private static _DOUBLESIDE: number;
  21009. private static _DEFAULTSIDE: number;
  21010. private static _NO_CAP: number;
  21011. private static _CAP_START: number;
  21012. private static _CAP_END: number;
  21013. private static _CAP_ALL: number;
  21014. /**
  21015. * Mesh side orientation : usually the external or front surface
  21016. */
  21017. static readonly FRONTSIDE: number;
  21018. /**
  21019. * Mesh side orientation : usually the internal or back surface
  21020. */
  21021. static readonly BACKSIDE: number;
  21022. /**
  21023. * Mesh side orientation : both internal and external or front and back surfaces
  21024. */
  21025. static readonly DOUBLESIDE: number;
  21026. /**
  21027. * Mesh side orientation : by default, `FRONTSIDE`
  21028. */
  21029. static readonly DEFAULTSIDE: number;
  21030. /**
  21031. * Mesh cap setting : no cap
  21032. */
  21033. static readonly NO_CAP: number;
  21034. /**
  21035. * Mesh cap setting : one cap at the beginning of the mesh
  21036. */
  21037. static readonly CAP_START: number;
  21038. /**
  21039. * Mesh cap setting : one cap at the end of the mesh
  21040. */
  21041. static readonly CAP_END: number;
  21042. /**
  21043. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21044. */
  21045. static readonly CAP_ALL: number;
  21046. private _onBeforeRenderObservable;
  21047. private _onAfterRenderObservable;
  21048. private _onBeforeDrawObservable;
  21049. /**
  21050. * An event triggered before rendering the mesh
  21051. */
  21052. readonly onBeforeRenderObservable: Observable<Mesh>;
  21053. /**
  21054. * An event triggered after rendering the mesh
  21055. */
  21056. readonly onAfterRenderObservable: Observable<Mesh>;
  21057. /**
  21058. * An event triggered before drawing the mesh
  21059. */
  21060. readonly onBeforeDrawObservable: Observable<Mesh>;
  21061. private _onBeforeDrawObserver;
  21062. onBeforeDraw: () => void;
  21063. delayLoadState: number;
  21064. instances: InstancedMesh[];
  21065. delayLoadingFile: string;
  21066. /** @hidden */
  21067. private _LODLevels;
  21068. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21069. private _morphTargetManager;
  21070. morphTargetManager: Nullable<MorphTargetManager>;
  21071. /** @hidden */
  21072. /** @hidden */
  21073. /** @hidden */
  21074. /** @hidden */
  21075. private _renderIdForInstances;
  21076. private _batchCache;
  21077. private _instancesBufferSize;
  21078. private _instancesBuffer;
  21079. private _instancesData;
  21080. private _overridenInstanceCount;
  21081. private _effectiveMaterial;
  21082. /** @hidden */
  21083. private _preActivateId;
  21084. /** @hidden */
  21085. overrideMaterialSideOrientation: Nullable<number>;
  21086. private _areNormalsFrozen;
  21087. private _sourcePositions;
  21088. private _sourceNormals;
  21089. private _source;
  21090. readonly source: Nullable<Mesh>;
  21091. isUnIndexed: boolean;
  21092. /**
  21093. * @constructor
  21094. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21095. * @param {Scene} scene The scene to add this mesh to.
  21096. * @param {Node} parent The parent of this mesh, if it has one
  21097. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21098. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21099. * When false, achieved by calling a clone(), also passing False.
  21100. * This will make creation of children, recursive.
  21101. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21102. */
  21103. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21104. /**
  21105. * Returns the string "Mesh".
  21106. */
  21107. getClassName(): string;
  21108. /**
  21109. * Returns a string.
  21110. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21111. */
  21112. toString(fullDetails?: boolean): string;
  21113. /** @hidden */
  21114. /**
  21115. * True if the mesh has some Levels Of Details (LOD).
  21116. * Returns a boolean.
  21117. */
  21118. readonly hasLODLevels: boolean;
  21119. /**
  21120. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21121. * @returns an array of {BABYLON.MeshLODLevel}
  21122. */
  21123. getLODLevels(): MeshLODLevel[];
  21124. private _sortLODLevels;
  21125. /**
  21126. * Add a mesh as LOD level triggered at the given distance.
  21127. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21128. * @param distance The distance from the center of the object to show this level
  21129. * @param mesh The mesh to be added as LOD level (can be null)
  21130. * @return This mesh (for chaining)
  21131. */
  21132. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21133. /**
  21134. * Returns the LOD level mesh at the passed distance or null if not found.
  21135. * It is related to the method `addLODLevel(distance, mesh)`.
  21136. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21137. * Returns an object Mesh or `null`.
  21138. */
  21139. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21140. /**
  21141. * Remove a mesh from the LOD array
  21142. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21143. * @param {Mesh} mesh The mesh to be removed.
  21144. * @return {Mesh} This mesh (for chaining)
  21145. */
  21146. removeLODLevel(mesh: Mesh): Mesh;
  21147. /**
  21148. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21149. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21150. */
  21151. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21152. /**
  21153. * Returns the mesh internal Geometry object.
  21154. */
  21155. readonly geometry: Nullable<Geometry>;
  21156. /**
  21157. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21158. */
  21159. getTotalVertices(): number;
  21160. /**
  21161. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21162. * 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.
  21163. * You can force the copy with forceCopy === true
  21164. * Returns null if the mesh has no geometry or no vertex buffer.
  21165. * Possible `kind` values :
  21166. * - BABYLON.VertexBuffer.PositionKind
  21167. * - BABYLON.VertexBuffer.UVKind
  21168. * - BABYLON.VertexBuffer.UV2Kind
  21169. * - BABYLON.VertexBuffer.UV3Kind
  21170. * - BABYLON.VertexBuffer.UV4Kind
  21171. * - BABYLON.VertexBuffer.UV5Kind
  21172. * - BABYLON.VertexBuffer.UV6Kind
  21173. * - BABYLON.VertexBuffer.ColorKind
  21174. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21175. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21176. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21177. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21178. */
  21179. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21180. /**
  21181. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21182. * Returns `null` if the mesh has no geometry.
  21183. * Possible `kind` values :
  21184. * - BABYLON.VertexBuffer.PositionKind
  21185. * - BABYLON.VertexBuffer.UVKind
  21186. * - BABYLON.VertexBuffer.UV2Kind
  21187. * - BABYLON.VertexBuffer.UV3Kind
  21188. * - BABYLON.VertexBuffer.UV4Kind
  21189. * - BABYLON.VertexBuffer.UV5Kind
  21190. * - BABYLON.VertexBuffer.UV6Kind
  21191. * - BABYLON.VertexBuffer.ColorKind
  21192. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21193. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21194. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21195. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21196. */
  21197. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21198. isVerticesDataPresent(kind: string): boolean;
  21199. /**
  21200. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21201. * Possible `kind` values :
  21202. * - BABYLON.VertexBuffer.PositionKind
  21203. * - BABYLON.VertexBuffer.UVKind
  21204. * - BABYLON.VertexBuffer.UV2Kind
  21205. * - BABYLON.VertexBuffer.UV3Kind
  21206. * - BABYLON.VertexBuffer.UV4Kind
  21207. * - BABYLON.VertexBuffer.UV5Kind
  21208. * - BABYLON.VertexBuffer.UV6Kind
  21209. * - BABYLON.VertexBuffer.ColorKind
  21210. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21211. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21212. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21213. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21214. */
  21215. isVertexBufferUpdatable(kind: string): boolean;
  21216. /**
  21217. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21218. * Possible `kind` values :
  21219. * - BABYLON.VertexBuffer.PositionKind
  21220. * - BABYLON.VertexBuffer.UVKind
  21221. * - BABYLON.VertexBuffer.UV2Kind
  21222. * - BABYLON.VertexBuffer.UV3Kind
  21223. * - BABYLON.VertexBuffer.UV4Kind
  21224. * - BABYLON.VertexBuffer.UV5Kind
  21225. * - BABYLON.VertexBuffer.UV6Kind
  21226. * - BABYLON.VertexBuffer.ColorKind
  21227. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21228. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21229. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21230. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21231. */
  21232. getVerticesDataKinds(): string[];
  21233. /**
  21234. * Returns a positive integer : the total number of indices in this mesh geometry.
  21235. * Returns zero if the mesh has no geometry.
  21236. */
  21237. getTotalIndices(): number;
  21238. /**
  21239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21240. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21242. * @returns the indices array or an empty array if the mesh has no geometry
  21243. */
  21244. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21245. readonly isBlocked: boolean;
  21246. /**
  21247. * Determine if the current mesh is ready to be rendered
  21248. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21249. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21250. * @returns true if all associated assets are ready (material, textures, shaders)
  21251. */
  21252. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21253. /**
  21254. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21255. * This property is pertinent only for updatable parametric shapes.
  21256. */
  21257. readonly areNormalsFrozen: boolean;
  21258. /**
  21259. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21260. * It has no effect at all on other shapes.
  21261. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21262. * Returns the Mesh.
  21263. */
  21264. freezeNormals(): Mesh;
  21265. /**
  21266. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21267. * It has no effect at all on other shapes.
  21268. * It reactivates the mesh normals computation if it was previously frozen.
  21269. * Returns the Mesh.
  21270. */
  21271. unfreezeNormals(): Mesh;
  21272. /**
  21273. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21274. */
  21275. overridenInstanceCount: number;
  21276. /** @hidden */
  21277. /** @hidden */
  21278. /** @hidden */
  21279. /**
  21280. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21281. * This means the mesh underlying bounding box and sphere are recomputed.
  21282. * Returns the Mesh.
  21283. */
  21284. refreshBoundingInfo(): Mesh;
  21285. /** @hidden */
  21286. private _getPositionData;
  21287. /** @hidden */
  21288. subdivide(count: number): void;
  21289. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21290. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21291. /**
  21292. * Sets the mesh VertexBuffer.
  21293. * Returns the Mesh.
  21294. */
  21295. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21297. /**
  21298. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21299. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21300. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21301. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21302. * Returns the Mesh.
  21303. */
  21304. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21305. /**
  21306. * Creates a un-shared specific occurence of the geometry for the mesh.
  21307. * Returns the Mesh.
  21308. */
  21309. makeGeometryUnique(): Mesh;
  21310. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21311. /**
  21312. * Update the current index buffer
  21313. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21314. * Returns the Mesh.
  21315. */
  21316. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21317. /**
  21318. * Invert the geometry to move from a right handed system to a left handed one.
  21319. * Returns the Mesh.
  21320. */
  21321. toLeftHanded(): Mesh;
  21322. /** @hidden */
  21323. /** @hidden */
  21324. /**
  21325. * Registers for this mesh a javascript function called just before the rendering process.
  21326. * This function is passed the current mesh.
  21327. * Return the Mesh.
  21328. */
  21329. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21330. /**
  21331. * Disposes a previously registered javascript function called before the rendering.
  21332. * This function is passed the current mesh.
  21333. * Returns the Mesh.
  21334. */
  21335. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21336. /**
  21337. * Registers for this mesh a javascript function called just after the rendering is complete.
  21338. * This function is passed the current mesh.
  21339. * Returns the Mesh.
  21340. */
  21341. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21342. /**
  21343. * Disposes a previously registered javascript function called after the rendering.
  21344. * This function is passed the current mesh.
  21345. * Return the Mesh.
  21346. */
  21347. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21348. /** @hidden */
  21349. /** @hidden */
  21350. /** @hidden */
  21351. /**
  21352. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21353. * @param subMesh defines the subMesh to render
  21354. * @param enableAlphaMode defines if alpha mode can be changed
  21355. * @returns the current mesh
  21356. */
  21357. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21358. private _onBeforeDraw;
  21359. /**
  21360. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21361. */
  21362. getEmittedParticleSystems(): IParticleSystem[];
  21363. /**
  21364. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21365. */
  21366. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21367. /**
  21368. * Normalize matrix weights so that all vertices have a total weight set to 1
  21369. */
  21370. cleanMatrixWeights(): void;
  21371. /** @hidden */
  21372. private _queueLoad;
  21373. /**
  21374. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21375. * A mesh is in the frustum if its bounding box intersects the frustum
  21376. * @param frustumPlanes defines the frustum to test
  21377. * @returns true if the mesh is in the frustum planes
  21378. */
  21379. isInFrustum(frustumPlanes: Plane[]): boolean;
  21380. /**
  21381. * Sets the mesh material by the material or multiMaterial `id` property.
  21382. * The material `id` is a string identifying the material or the multiMaterial.
  21383. * This method returns the Mesh.
  21384. */
  21385. setMaterialByID(id: string): Mesh;
  21386. /**
  21387. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21388. */
  21389. getAnimatables(): IAnimatable[];
  21390. /**
  21391. * Modifies the mesh geometry according to the passed transformation matrix.
  21392. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21393. * The mesh normals are modified using the same transformation.
  21394. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21395. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21396. * Returns the Mesh.
  21397. */
  21398. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21399. /**
  21400. * Modifies the mesh geometry according to its own current World Matrix.
  21401. * The mesh World Matrix is then reset.
  21402. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21403. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21404. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21405. * Returns the Mesh.
  21406. */
  21407. bakeCurrentTransformIntoVertices(): Mesh;
  21408. protected readonly _positions: Nullable<Vector3[]>;
  21409. /** @hidden */
  21410. /** @hidden */
  21411. /**
  21412. * Returns a new Mesh object generated from the current mesh properties.
  21413. * This method must not get confused with createInstance().
  21414. * The parameter `name` is a string, the name given to the new mesh.
  21415. * The optional parameter `newParent` can be any Node object (default `null`).
  21416. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21417. * 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.
  21418. */
  21419. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21420. /**
  21421. * Releases resources associated with this mesh.
  21422. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21423. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21424. */
  21425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21426. /**
  21427. * Modifies the mesh geometry according to a displacement map.
  21428. * 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.
  21429. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21430. * This method returns nothing.
  21431. * @param url is a string, the URL from the image file is to be downloaded.
  21432. * @param minHeight is the lower limit of the displacement.
  21433. * @param maxHeight is the upper limit of the displacement.
  21434. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21435. * @param uvOffset is an optional vector2 used to offset UV.
  21436. * @param uvScale is an optional vector2 used to scale UV.
  21437. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21438. * @returns the Mesh.
  21439. */
  21440. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21441. /**
  21442. * Modifies the mesh geometry according to a displacementMap buffer.
  21443. * 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.
  21444. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21445. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21446. * @param heightMapWidth is the width of the buffer image.
  21447. * @param heightMapHeight is the height of the buffer image.
  21448. * @param minHeight is the lower limit of the displacement.
  21449. * @param maxHeight is the upper limit of the displacement.
  21450. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21451. * @param uvOffset is an optional vector2 used to offset UV.
  21452. * @param uvScale is an optional vector2 used to scale UV.
  21453. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21454. * @returns the Mesh.
  21455. */
  21456. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21457. /**
  21458. * Modify the mesh to get a flat shading rendering.
  21459. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21460. * This method returns the Mesh.
  21461. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21462. */
  21463. convertToFlatShadedMesh(): Mesh;
  21464. /**
  21465. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21466. * In other words, more vertices, no more indices and a single bigger VBO.
  21467. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21468. * Returns the Mesh.
  21469. */
  21470. convertToUnIndexedMesh(): Mesh;
  21471. /**
  21472. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21473. * This method returns the Mesh.
  21474. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21475. */
  21476. flipFaces(flipNormals?: boolean): Mesh;
  21477. /**
  21478. * Creates a new InstancedMesh object from the mesh model.
  21479. * An instance shares the same properties and the same material than its model.
  21480. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  21481. * Only these properties of each instance can then be set individually :
  21482. * - position
  21483. * - rotation
  21484. * - rotationQuaternion
  21485. * - setPivotMatrix
  21486. * - scaling
  21487. *
  21488. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21489. * Warning : this method is not supported for Line mesh and LineSystem
  21490. */
  21491. createInstance(name: string): InstancedMesh;
  21492. /**
  21493. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21494. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21495. * This method returns the Mesh.
  21496. */
  21497. synchronizeInstances(): Mesh;
  21498. /**
  21499. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21500. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21501. * This should be used together with the simplification to avoid disappearing triangles.
  21502. * Returns the Mesh.
  21503. * @param successCallback an optional success callback to be called after the optimization finished.
  21504. */
  21505. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21506. serialize(serializationObject: any): void;
  21507. /** @hidden */
  21508. /**
  21509. * Returns a new Mesh object parsed from the source provided.
  21510. * The parameter `parsedMesh` is the source.
  21511. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21512. */
  21513. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21514. /**
  21515. * Creates a ribbon mesh.
  21516. * Please consider using the same method from the MeshBuilder class instead.
  21517. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21518. *
  21519. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21520. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21521. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21522. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21523. * 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.
  21524. * 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.
  21525. * 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
  21526. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21527. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21528. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21529. */
  21530. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21531. /**
  21532. * Creates a plane polygonal mesh. By default, this is a disc.
  21533. * Please consider using the same method from the MeshBuilder class instead.
  21534. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21535. * 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.
  21536. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21537. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21538. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21539. */
  21540. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21541. /**
  21542. * Creates a box mesh.
  21543. * Please consider using the same method from the MeshBuilder class instead.
  21544. * The parameter `size` sets the size (float) of each box side (default 1).
  21545. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21546. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21547. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21548. */
  21549. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21550. /**
  21551. * Creates a sphere mesh.
  21552. * Please consider using the same method from the MeshBuilder class instead.
  21553. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21554. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21555. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21556. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21557. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21558. */
  21559. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21560. /**
  21561. * Creates a cylinder or a cone mesh.
  21562. * Please consider using the same method from the MeshBuilder class instead.
  21563. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21564. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21565. * 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.
  21566. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21567. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21568. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21569. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21570. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21571. */
  21572. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21573. /**
  21574. * Creates a torus mesh.
  21575. * Please consider using the same method from the MeshBuilder class instead.
  21576. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21577. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21578. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21579. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21580. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21581. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21582. */
  21583. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21584. /**
  21585. * Creates a torus knot mesh.
  21586. * Please consider using the same method from the MeshBuilder class instead.
  21587. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21588. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21589. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21590. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21591. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21592. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21594. */
  21595. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21596. /**
  21597. * Creates a line mesh.
  21598. * Please consider using the same method from the MeshBuilder class instead.
  21599. * 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.
  21600. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21601. * The parameter `points` is an array successive Vector3.
  21602. * 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
  21603. * When updating an instance, remember that only point positions can change, not the number of points.
  21604. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21605. */
  21606. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21607. /**
  21608. * Creates a dashed line mesh.
  21609. * Please consider using the same method from the MeshBuilder class instead.
  21610. * 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.
  21611. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21612. * The parameter `points` is an array successive Vector3.
  21613. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21614. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21615. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21616. * 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
  21617. * When updating an instance, remember that only point positions can change, not the number of points.
  21618. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21619. */
  21620. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21621. /**
  21622. * Creates a polygon mesh.
  21623. * Please consider using the same method from the MeshBuilder class instead.
  21624. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21625. * 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.
  21626. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21627. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21628. * Remember you can only change the shape positions, not their number when updating a polygon.
  21629. */
  21630. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21631. /**
  21632. * Creates an extruded polygon mesh, with depth in the Y direction.
  21633. * Please consider using the same method from the MeshBuilder class instead.
  21634. */
  21635. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21636. /**
  21637. * Creates an extruded shape mesh.
  21638. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21639. * Please consider using the same method from the MeshBuilder class instead.
  21640. *
  21641. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21642. * 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
  21643. * extruded along the Z axis.
  21644. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21645. * 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.
  21646. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21647. * 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
  21648. * 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
  21649. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21650. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21651. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21652. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21653. */
  21654. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21655. /**
  21656. * Creates an custom extruded shape mesh.
  21657. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21658. * Please consider using the same method from the MeshBuilder class instead.
  21659. *
  21660. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21661. * 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
  21662. * extruded along the Z axis.
  21663. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21664. * 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
  21665. * and the distance of this point from the begining of the path :
  21666. * ```javascript
  21667. * var rotationFunction = function(i, distance) {
  21668. * // do things
  21669. * return rotationValue; }
  21670. * ```
  21671. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21672. * 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
  21673. * and the distance of this point from the begining of the path :
  21674. * ```javascript
  21675. * var scaleFunction = function(i, distance) {
  21676. * // do things
  21677. * return scaleValue;}
  21678. * ```
  21679. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21680. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21681. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21682. * 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
  21683. * 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
  21684. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21685. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21686. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21687. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21688. */
  21689. 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;
  21690. /**
  21691. * Creates lathe mesh.
  21692. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21693. * Please consider using the same method from the MeshBuilder class instead.
  21694. * 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
  21695. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21696. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21697. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21698. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21699. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21700. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21701. */
  21702. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21703. /**
  21704. * Creates a plane mesh.
  21705. * Please consider using the same method from the MeshBuilder class instead.
  21706. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21707. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21708. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21709. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21710. */
  21711. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21712. /**
  21713. * Creates a ground mesh.
  21714. * Please consider using the same method from the MeshBuilder class instead.
  21715. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21716. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21718. */
  21719. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21720. /**
  21721. * Creates a tiled ground mesh.
  21722. * Please consider using the same method from the MeshBuilder class instead.
  21723. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21724. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21725. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21726. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21727. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21728. * numbers of subdivisions on the ground width and height of each tile.
  21729. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21730. */
  21731. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21732. w: number;
  21733. h: number;
  21734. }, precision: {
  21735. w: number;
  21736. h: number;
  21737. }, scene: Scene, updatable?: boolean): Mesh;
  21738. /**
  21739. * Creates a ground mesh from a height map.
  21740. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21741. * Please consider using the same method from the MeshBuilder class instead.
  21742. * The parameter `url` sets the URL of the height map image resource.
  21743. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21744. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21745. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21746. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21747. * 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).
  21748. * This function is passed the newly built mesh :
  21749. * ```javascript
  21750. * function(mesh) { // do things
  21751. * return; }
  21752. * ```
  21753. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21754. */
  21755. 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;
  21756. /**
  21757. * Creates a tube mesh.
  21758. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21759. * Please consider using the same method from the MeshBuilder class instead.
  21760. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21761. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21762. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21763. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21764. * 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.
  21765. * It must return a radius value (positive float) :
  21766. * ```javascript
  21767. * var radiusFunction = function(i, distance) {
  21768. * // do things
  21769. * return radius; }
  21770. * ```
  21771. * 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
  21772. * 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
  21773. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21774. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21775. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21776. */
  21777. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21778. (i: number, distance: number): number;
  21779. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21780. /**
  21781. * Creates a polyhedron mesh.
  21782. * Please consider using the same method from the MeshBuilder class instead.
  21783. * 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
  21784. * to choose the wanted type.
  21785. * The parameter `size` (positive float, default 1) sets the polygon size.
  21786. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21787. * 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`.
  21788. * 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
  21789. * 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)`).
  21790. * 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
  21791. * 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.
  21792. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21793. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21794. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21795. */
  21796. static CreatePolyhedron(name: string, options: {
  21797. type?: number;
  21798. size?: number;
  21799. sizeX?: number;
  21800. sizeY?: number;
  21801. sizeZ?: number;
  21802. custom?: any;
  21803. faceUV?: Vector4[];
  21804. faceColors?: Color4[];
  21805. updatable?: boolean;
  21806. sideOrientation?: number;
  21807. }, scene: Scene): Mesh;
  21808. /**
  21809. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21810. * Please consider using the same method from the MeshBuilder class instead.
  21811. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21812. * 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`).
  21813. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21814. * 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.
  21815. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21816. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21817. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21818. */
  21819. static CreateIcoSphere(name: string, options: {
  21820. radius?: number;
  21821. flat?: boolean;
  21822. subdivisions?: number;
  21823. sideOrientation?: number;
  21824. updatable?: boolean;
  21825. }, scene: Scene): Mesh;
  21826. /**
  21827. * Creates a decal mesh.
  21828. * Please consider using the same method from the MeshBuilder class instead.
  21829. * 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.
  21830. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21831. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21832. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21833. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21834. */
  21835. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21836. /**
  21837. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21838. */
  21839. setPositionsForCPUSkinning(): Float32Array;
  21840. /**
  21841. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21842. */
  21843. setNormalsForCPUSkinning(): Float32Array;
  21844. /**
  21845. * Updates the vertex buffer by applying transformation from the bones.
  21846. * Returns the Mesh.
  21847. *
  21848. * @param {skeleton} skeleton to apply
  21849. */
  21850. applySkeleton(skeleton: Skeleton): Mesh;
  21851. /**
  21852. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21853. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21854. */
  21855. static MinMax(meshes: AbstractMesh[]): {
  21856. min: Vector3;
  21857. max: Vector3;
  21858. };
  21859. /**
  21860. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21861. */
  21862. static Center(meshesOrMinMaxVector: {
  21863. min: Vector3;
  21864. max: Vector3;
  21865. } | AbstractMesh[]): Vector3;
  21866. /**
  21867. * Merge the array of meshes into a single mesh for performance reasons.
  21868. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  21869. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  21870. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21871. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21872. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21873. */
  21874. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21875. }
  21876. }
  21877. declare module BABYLON {
  21878. /**
  21879. * Define an interface for all classes that will get and set the data on vertices
  21880. */
  21881. interface IGetSetVerticesData {
  21882. isVerticesDataPresent(kind: string): boolean;
  21883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21884. /**
  21885. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21886. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21888. * @returns the indices array or an empty array if the mesh has no geometry
  21889. */
  21890. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21891. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21892. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21893. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21894. }
  21895. /**
  21896. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21897. */
  21898. class VertexData {
  21899. /**
  21900. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21901. */
  21902. positions: Nullable<FloatArray>;
  21903. /**
  21904. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21905. */
  21906. normals: Nullable<FloatArray>;
  21907. /**
  21908. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21909. */
  21910. tangents: Nullable<FloatArray>;
  21911. /**
  21912. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21913. */
  21914. uvs: Nullable<FloatArray>;
  21915. /**
  21916. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21917. */
  21918. uvs2: Nullable<FloatArray>;
  21919. /**
  21920. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21921. */
  21922. uvs3: Nullable<FloatArray>;
  21923. /**
  21924. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21925. */
  21926. uvs4: Nullable<FloatArray>;
  21927. /**
  21928. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21929. */
  21930. uvs5: Nullable<FloatArray>;
  21931. /**
  21932. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21933. */
  21934. uvs6: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21937. */
  21938. colors: Nullable<FloatArray>;
  21939. /**
  21940. * 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).
  21941. */
  21942. matricesIndices: Nullable<FloatArray>;
  21943. /**
  21944. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21945. */
  21946. matricesWeights: Nullable<FloatArray>;
  21947. /**
  21948. * An array extending the number of possible indices
  21949. */
  21950. matricesIndicesExtra: Nullable<FloatArray>;
  21951. /**
  21952. * An array extending the number of possible weights when the number of indices is extended
  21953. */
  21954. matricesWeightsExtra: Nullable<FloatArray>;
  21955. /**
  21956. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21957. */
  21958. indices: Nullable<IndicesArray>;
  21959. /**
  21960. * Uses the passed data array to set the set the values for the specified kind of data
  21961. * @param data a linear array of floating numbers
  21962. * @param kind the type of data that is being set, eg positions, colors etc
  21963. */
  21964. set(data: FloatArray, kind: string): void;
  21965. /**
  21966. * Associates the vertexData to the passed Mesh.
  21967. * Sets it as updatable or not (default `false`)
  21968. * @param mesh the mesh the vertexData is applied to
  21969. * @param updatable when used and having the value true allows new data to update the vertexData
  21970. * @returns the VertexData
  21971. */
  21972. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21973. /**
  21974. * Associates the vertexData to the passed Geometry.
  21975. * Sets it as updatable or not (default `false`)
  21976. * @param geometry the geometry the vertexData is applied to
  21977. * @param updatable when used and having the value true allows new data to update the vertexData
  21978. * @returns VertexData
  21979. */
  21980. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21981. /**
  21982. * Updates the associated mesh
  21983. * @param mesh the mesh to be updated
  21984. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21985. * @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
  21986. * @returns VertexData
  21987. */
  21988. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21989. /**
  21990. * Updates the associated geometry
  21991. * @param geometry the geometry to be updated
  21992. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21993. * @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
  21994. * @returns VertexData.
  21995. */
  21996. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21997. private _applyTo;
  21998. private _update;
  21999. /**
  22000. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22001. * @param matrix the transforming matrix
  22002. * @returns the VertexData
  22003. */
  22004. transform(matrix: Matrix): VertexData;
  22005. /**
  22006. * Merges the passed VertexData into the current one
  22007. * @param other the VertexData to be merged into the current one
  22008. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22009. * @returns the modified VertexData
  22010. */
  22011. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22012. private _mergeElement;
  22013. private _validate;
  22014. /**
  22015. * Serializes the VertexData
  22016. * @returns a serialized object
  22017. */
  22018. serialize(): any;
  22019. /**
  22020. * Extracts the vertexData from a mesh
  22021. * @param mesh the mesh from which to extract the VertexData
  22022. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22023. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22024. * @returns the object VertexData associated to the passed mesh
  22025. */
  22026. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22027. /**
  22028. * Extracts the vertexData from the geometry
  22029. * @param geometry the geometry from which to extract the VertexData
  22030. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22031. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22032. * @returns the object VertexData associated to the passed mesh
  22033. */
  22034. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22035. private static _ExtractFrom;
  22036. /**
  22037. * Creates the VertexData for a Ribbon
  22038. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22039. * * pathArray array of paths, each of which an array of successive Vector3
  22040. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22041. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22042. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22047. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22048. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22049. * @returns the VertexData of the ribbon
  22050. */
  22051. static CreateRibbon(options: {
  22052. pathArray: Vector3[][];
  22053. closeArray?: boolean;
  22054. closePath?: boolean;
  22055. offset?: number;
  22056. sideOrientation?: number;
  22057. frontUVs?: Vector4;
  22058. backUVs?: Vector4;
  22059. invertUV?: boolean;
  22060. uvs?: Vector2[];
  22061. colors?: Color4[];
  22062. }): VertexData;
  22063. /**
  22064. * Creates the VertexData for a box
  22065. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22066. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22067. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22068. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22069. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22070. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22071. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22072. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22073. * * 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)
  22074. * * 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)
  22075. * @returns the VertexData of the box
  22076. */
  22077. static CreateBox(options: {
  22078. size?: number;
  22079. width?: number;
  22080. height?: number;
  22081. depth?: number;
  22082. faceUV?: Vector4[];
  22083. faceColors?: Color4[];
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. }): VertexData;
  22088. /**
  22089. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22090. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22091. * * segments sets the number of horizontal strips optional, default 32
  22092. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22093. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22094. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22095. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22096. * * 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
  22097. * * 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
  22098. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22099. * * 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)
  22100. * * 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)
  22101. * @returns the VertexData of the ellipsoid
  22102. */
  22103. static CreateSphere(options: {
  22104. segments?: number;
  22105. diameter?: number;
  22106. diameterX?: number;
  22107. diameterY?: number;
  22108. diameterZ?: number;
  22109. arc?: number;
  22110. slice?: number;
  22111. sideOrientation?: number;
  22112. frontUVs?: Vector4;
  22113. backUVs?: Vector4;
  22114. }): VertexData;
  22115. /**
  22116. * Creates the VertexData for a cylinder, cone or prism
  22117. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22118. * * height sets the height (y direction) of the cylinder, optional, default 2
  22119. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22120. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22121. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22122. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22123. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22124. * * 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
  22125. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22126. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22127. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22128. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22129. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22130. * * 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)
  22131. * * 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)
  22132. * @returns the VertexData of the cylinder, cone or prism
  22133. */
  22134. static CreateCylinder(options: {
  22135. height?: number;
  22136. diameterTop?: number;
  22137. diameterBottom?: number;
  22138. diameter?: number;
  22139. tessellation?: number;
  22140. subdivisions?: number;
  22141. arc?: number;
  22142. faceColors?: Color4[];
  22143. faceUV?: Vector4[];
  22144. hasRings?: boolean;
  22145. enclose?: boolean;
  22146. sideOrientation?: number;
  22147. frontUVs?: Vector4;
  22148. backUVs?: Vector4;
  22149. }): VertexData;
  22150. /**
  22151. * Creates the VertexData for a torus
  22152. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22153. * * diameter the diameter of the torus, optional default 1
  22154. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22155. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22156. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22157. * * 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)
  22158. * * 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)
  22159. * @returns the VertexData of the torus
  22160. */
  22161. static CreateTorus(options: {
  22162. diameter?: number;
  22163. thickness?: number;
  22164. tessellation?: number;
  22165. sideOrientation?: number;
  22166. frontUVs?: Vector4;
  22167. backUVs?: Vector4;
  22168. }): VertexData;
  22169. /**
  22170. * Creates the VertexData of the LineSystem
  22171. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22172. * - lines an array of lines, each line being an array of successive Vector3
  22173. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22174. * @returns the VertexData of the LineSystem
  22175. */
  22176. static CreateLineSystem(options: {
  22177. lines: Vector3[][];
  22178. colors?: Nullable<Color4[][]>;
  22179. }): VertexData;
  22180. /**
  22181. * Create the VertexData for a DashedLines
  22182. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22183. * - points an array successive Vector3
  22184. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22185. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22186. * - dashNb the intended total number of dashes, optional, default 200
  22187. * @returns the VertexData for the DashedLines
  22188. */
  22189. static CreateDashedLines(options: {
  22190. points: Vector3[];
  22191. dashSize?: number;
  22192. gapSize?: number;
  22193. dashNb?: number;
  22194. }): VertexData;
  22195. /**
  22196. * Creates the VertexData for a Ground
  22197. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22198. * - width the width (x direction) of the ground, optional, default 1
  22199. * - height the height (z direction) of the ground, optional, default 1
  22200. * - subdivisions the number of subdivisions per side, optional, default 1
  22201. * @returns the VertexData of the Ground
  22202. */
  22203. static CreateGround(options: {
  22204. width?: number;
  22205. height?: number;
  22206. subdivisions?: number;
  22207. subdivisionsX?: number;
  22208. subdivisionsY?: number;
  22209. }): VertexData;
  22210. /**
  22211. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22212. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22213. * * xmin the ground minimum X coordinate, optional, default -1
  22214. * * zmin the ground minimum Z coordinate, optional, default -1
  22215. * * xmax the ground maximum X coordinate, optional, default 1
  22216. * * zmax the ground maximum Z coordinate, optional, default 1
  22217. * * 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}
  22218. * * 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}
  22219. * @returns the VertexData of the TiledGround
  22220. */
  22221. static CreateTiledGround(options: {
  22222. xmin: number;
  22223. zmin: number;
  22224. xmax: number;
  22225. zmax: number;
  22226. subdivisions?: {
  22227. w: number;
  22228. h: number;
  22229. };
  22230. precision?: {
  22231. w: number;
  22232. h: number;
  22233. };
  22234. }): VertexData;
  22235. /**
  22236. * Creates the VertexData of the Ground designed from a heightmap
  22237. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22238. * * width the width (x direction) of the ground
  22239. * * height the height (z direction) of the ground
  22240. * * subdivisions the number of subdivisions per side
  22241. * * minHeight the minimum altitude on the ground, optional, default 0
  22242. * * maxHeight the maximum altitude on the ground, optional default 1
  22243. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22244. * * buffer the array holding the image color data
  22245. * * bufferWidth the width of image
  22246. * * bufferHeight the height of image
  22247. * @returns the VertexData of the Ground designed from a heightmap
  22248. */
  22249. static CreateGroundFromHeightMap(options: {
  22250. width: number;
  22251. height: number;
  22252. subdivisions: number;
  22253. minHeight: number;
  22254. maxHeight: number;
  22255. colorFilter: Color3;
  22256. buffer: Uint8Array;
  22257. bufferWidth: number;
  22258. bufferHeight: number;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a Plane
  22262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22263. * * size sets the width and height of the plane to the value of size, optional default 1
  22264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22266. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * @returns the VertexData of the box
  22270. */
  22271. static CreatePlane(options: {
  22272. size?: number;
  22273. width?: number;
  22274. height?: number;
  22275. sideOrientation?: number;
  22276. frontUVs?: Vector4;
  22277. backUVs?: Vector4;
  22278. }): VertexData;
  22279. /**
  22280. * Creates the VertexData of the Disc or regular Polygon
  22281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22282. * * radius the radius of the disc, optional default 0.5
  22283. * * tessellation the number of polygon sides, optional, default 64
  22284. * * 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
  22285. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * @returns the VertexData of the box
  22289. */
  22290. static CreateDisc(options: {
  22291. radius?: number;
  22292. tessellation?: number;
  22293. arc?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22301. * @param polygon a mesh built from polygonTriangulation.build()
  22302. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22305. * @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)
  22306. * @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)
  22307. * @returns the VertexData of the Polygon
  22308. */
  22309. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22310. /**
  22311. * Creates the VertexData of the IcoSphere
  22312. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22313. * * radius the radius of the IcoSphere, optional default 1
  22314. * * radiusX allows stretching in the x direction, optional, default radius
  22315. * * radiusY allows stretching in the y direction, optional, default radius
  22316. * * radiusZ allows stretching in the z direction, optional, default radius
  22317. * * flat when true creates a flat shaded mesh, optional, default true
  22318. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22319. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22320. * * 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)
  22321. * * 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)
  22322. * @returns the VertexData of the IcoSphere
  22323. */
  22324. static CreateIcoSphere(options: {
  22325. radius?: number;
  22326. radiusX?: number;
  22327. radiusY?: number;
  22328. radiusZ?: number;
  22329. flat?: boolean;
  22330. subdivisions?: number;
  22331. sideOrientation?: number;
  22332. frontUVs?: Vector4;
  22333. backUVs?: Vector4;
  22334. }): VertexData;
  22335. /**
  22336. * Creates the VertexData for a Polyhedron
  22337. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22338. * * type provided types are:
  22339. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22340. * * 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)
  22341. * * size the size of the IcoSphere, optional default 1
  22342. * * sizeX allows stretching in the x direction, optional, default size
  22343. * * sizeY allows stretching in the y direction, optional, default size
  22344. * * sizeZ allows stretching in the z direction, optional, default size
  22345. * * 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
  22346. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22347. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22348. * * flat when true creates a flat shaded mesh, optional, default true
  22349. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22350. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22351. * * 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)
  22352. * * 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)
  22353. * @returns the VertexData of the Polyhedron
  22354. */
  22355. static CreatePolyhedron(options: {
  22356. type?: number;
  22357. size?: number;
  22358. sizeX?: number;
  22359. sizeY?: number;
  22360. sizeZ?: number;
  22361. custom?: any;
  22362. faceUV?: Vector4[];
  22363. faceColors?: Color4[];
  22364. flat?: boolean;
  22365. sideOrientation?: number;
  22366. frontUVs?: Vector4;
  22367. backUVs?: Vector4;
  22368. }): VertexData;
  22369. /**
  22370. * Creates the VertexData for a TorusKnot
  22371. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22372. * * radius the radius of the torus knot, optional, default 2
  22373. * * tube the thickness of the tube, optional, default 0.5
  22374. * * radialSegments the number of sides on each tube segments, optional, default 32
  22375. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22376. * * p the number of windings around the z axis, optional, default 2
  22377. * * q the number of windings around the x axis, optional, default 3
  22378. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22379. * * 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)
  22380. * * 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)
  22381. * @returns the VertexData of the Torus Knot
  22382. */
  22383. static CreateTorusKnot(options: {
  22384. radius?: number;
  22385. tube?: number;
  22386. radialSegments?: number;
  22387. tubularSegments?: number;
  22388. p?: number;
  22389. q?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Compute normals for given positions and indices
  22396. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22397. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22398. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22399. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22400. * * facetNormals : optional array of facet normals (vector3)
  22401. * * facetPositions : optional array of facet positions (vector3)
  22402. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22403. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22404. * * bInfo : optional bounding info, required for facetPartitioning computation
  22405. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22406. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22407. * * useRightHandedSystem: optional boolean to for right handed system computation
  22408. * * depthSort : optional boolean to enable the facet depth sort computation
  22409. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22410. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22411. */
  22412. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22413. facetNormals?: any;
  22414. facetPositions?: any;
  22415. facetPartitioning?: any;
  22416. ratio?: number;
  22417. bInfo?: any;
  22418. bbSize?: Vector3;
  22419. subDiv?: any;
  22420. useRightHandedSystem?: boolean;
  22421. depthSort?: boolean;
  22422. distanceTo?: Vector3;
  22423. depthSortedFacets?: any;
  22424. }): void;
  22425. private static _ComputeSides;
  22426. /**
  22427. * Applies VertexData created from the imported parameters to the geometry
  22428. * @param parsedVertexData the parsed data from an imported file
  22429. * @param geometry the geometry to apply the VertexData to
  22430. */
  22431. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Class containing static functions to help procedurally build meshes
  22437. */
  22438. class MeshBuilder {
  22439. private static updateSideOrientation;
  22440. /**
  22441. * Creates a box mesh
  22442. * * The parameter `size` sets the size (float) of each box side (default 1)
  22443. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22444. * * 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)
  22445. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22447. * * 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
  22448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22449. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22450. * @param name defines the name of the mesh
  22451. * @param options defines the options used to create the mesh
  22452. * @param scene defines the hosting scene
  22453. * @returns the box mesh
  22454. */
  22455. static CreateBox(name: string, options: {
  22456. size?: number;
  22457. width?: number;
  22458. height?: number;
  22459. depth?: number;
  22460. faceUV?: Vector4[];
  22461. faceColors?: Color4[];
  22462. sideOrientation?: number;
  22463. frontUVs?: Vector4;
  22464. backUVs?: Vector4;
  22465. updatable?: boolean;
  22466. }, scene?: Nullable<Scene>): Mesh;
  22467. /**
  22468. * Creates a sphere mesh
  22469. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22470. * * 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`)
  22471. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22472. * * 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
  22473. * * 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)
  22474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22475. * * 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
  22476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22477. * @param name defines the name of the mesh
  22478. * @param options defines the options used to create the mesh
  22479. * @param scene defines the hosting scene
  22480. * @returns the sphere mesh
  22481. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22482. */
  22483. static CreateSphere(name: string, options: {
  22484. segments?: number;
  22485. diameter?: number;
  22486. diameterX?: number;
  22487. diameterY?: number;
  22488. diameterZ?: number;
  22489. arc?: number;
  22490. slice?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. updatable?: boolean;
  22495. }, scene: any): Mesh;
  22496. /**
  22497. * Creates a plane polygonal mesh. By default, this is a disc
  22498. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22499. * * 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
  22500. * * 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
  22501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22502. * * 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
  22503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22504. * @param name defines the name of the mesh
  22505. * @param options defines the options used to create the mesh
  22506. * @param scene defines the hosting scene
  22507. * @returns the plane polygonal mesh
  22508. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22509. */
  22510. static CreateDisc(name: string, options: {
  22511. radius?: number;
  22512. tessellation?: number;
  22513. arc?: number;
  22514. updatable?: boolean;
  22515. sideOrientation?: number;
  22516. frontUVs?: Vector4;
  22517. backUVs?: Vector4;
  22518. }, scene?: Nullable<Scene>): Mesh;
  22519. /**
  22520. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22521. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22522. * * 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`)
  22523. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22524. * * 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
  22525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22526. * * 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
  22527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22528. * @param name defines the name of the mesh
  22529. * @param options defines the options used to create the mesh
  22530. * @param scene defines the hosting scene
  22531. * @returns the icosahedron mesh
  22532. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22533. */
  22534. static CreateIcoSphere(name: string, options: {
  22535. radius?: number;
  22536. radiusX?: number;
  22537. radiusY?: number;
  22538. radiusZ?: number;
  22539. flat?: boolean;
  22540. subdivisions?: number;
  22541. sideOrientation?: number;
  22542. frontUVs?: Vector4;
  22543. backUVs?: Vector4;
  22544. updatable?: boolean;
  22545. }, scene: Scene): Mesh;
  22546. /**
  22547. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22548. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22549. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22550. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22551. * * 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
  22552. * * 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
  22553. * * 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
  22554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22555. * * 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
  22556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22557. * * 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
  22558. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22559. * * 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
  22560. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22562. * @param name defines the name of the mesh
  22563. * @param options defines the options used to create the mesh
  22564. * @param scene defines the hosting scene
  22565. * @returns the ribbon mesh
  22566. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22567. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22568. */
  22569. static CreateRibbon(name: string, options: {
  22570. pathArray: Vector3[][];
  22571. closeArray?: boolean;
  22572. closePath?: boolean;
  22573. offset?: number;
  22574. updatable?: boolean;
  22575. sideOrientation?: number;
  22576. frontUVs?: Vector4;
  22577. backUVs?: Vector4;
  22578. instance?: Mesh;
  22579. invertUV?: boolean;
  22580. uvs?: Vector2[];
  22581. colors?: Color4[];
  22582. }, scene?: Nullable<Scene>): Mesh;
  22583. /**
  22584. * Creates a cylinder or a cone mesh
  22585. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22586. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22587. * * 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.
  22588. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22589. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22590. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22591. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22592. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22593. * * 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).
  22594. * * 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
  22595. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22596. * * 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
  22597. * * 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.
  22598. * * If `enclose` is false, a ring surface is one element.
  22599. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22600. * * 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
  22601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22602. * * 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
  22603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22604. * @param name defines the name of the mesh
  22605. * @param options defines the options used to create the mesh
  22606. * @param scene defines the hosting scene
  22607. * @returns the cylinder mesh
  22608. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22609. */
  22610. static CreateCylinder(name: string, options: {
  22611. height?: number;
  22612. diameterTop?: number;
  22613. diameterBottom?: number;
  22614. diameter?: number;
  22615. tessellation?: number;
  22616. subdivisions?: number;
  22617. arc?: number;
  22618. faceColors?: Color4[];
  22619. faceUV?: Vector4[];
  22620. updatable?: boolean;
  22621. hasRings?: boolean;
  22622. enclose?: boolean;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. }, scene: any): Mesh;
  22627. /**
  22628. * Creates a torus mesh
  22629. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22630. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22631. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22633. * * 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
  22634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22635. * @param name defines the name of the mesh
  22636. * @param options defines the options used to create the mesh
  22637. * @param scene defines the hosting scene
  22638. * @returns the torus mesh
  22639. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22640. */
  22641. static CreateTorus(name: string, options: {
  22642. diameter?: number;
  22643. thickness?: number;
  22644. tessellation?: number;
  22645. updatable?: boolean;
  22646. sideOrientation?: number;
  22647. frontUVs?: Vector4;
  22648. backUVs?: Vector4;
  22649. }, scene: any): Mesh;
  22650. /**
  22651. * Creates a torus knot mesh
  22652. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22653. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22654. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22655. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22657. * * 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
  22658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22659. * @param name defines the name of the mesh
  22660. * @param options defines the options used to create the mesh
  22661. * @param scene defines the hosting scene
  22662. * @returns the torus knot mesh
  22663. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22664. */
  22665. static CreateTorusKnot(name: string, options: {
  22666. radius?: number;
  22667. tube?: number;
  22668. radialSegments?: number;
  22669. tubularSegments?: number;
  22670. p?: number;
  22671. q?: number;
  22672. updatable?: boolean;
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. }, scene: any): Mesh;
  22677. /**
  22678. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22679. * * 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
  22680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22681. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22682. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22683. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22685. * * 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
  22686. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22688. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22689. * @param name defines the name of the new line system
  22690. * @param options defines the options used to create the line system
  22691. * @param scene defines the hosting scene
  22692. * @returns a new line system mesh
  22693. */
  22694. static CreateLineSystem(name: string, options: {
  22695. lines: Vector3[][];
  22696. updatable?: boolean;
  22697. instance?: Nullable<LinesMesh>;
  22698. colors?: Nullable<Color4[][]>;
  22699. useVertexAlpha?: boolean;
  22700. }, scene: Nullable<Scene>): LinesMesh;
  22701. /**
  22702. * Creates a line mesh
  22703. * 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
  22704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22705. * * The parameter `points` is an array successive Vector3
  22706. * * 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
  22707. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22708. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22709. * * When updating an instance, remember that only point positions can change, not the number of points
  22710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22711. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22712. * @param name defines the name of the new line system
  22713. * @param options defines the options used to create the line system
  22714. * @param scene defines the hosting scene
  22715. * @returns a new line mesh
  22716. */
  22717. static CreateLines(name: string, options: {
  22718. points: Vector3[];
  22719. updatable?: boolean;
  22720. instance?: Nullable<LinesMesh>;
  22721. colors?: Color4[];
  22722. useVertexAlpha?: boolean;
  22723. }, scene?: Nullable<Scene>): LinesMesh;
  22724. /**
  22725. * Creates a dashed line mesh
  22726. * * 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
  22727. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22728. * * The parameter `points` is an array successive Vector3
  22729. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22730. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22731. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22732. * * 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
  22733. * * When updating an instance, remember that only point positions can change, not the number of points
  22734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22735. * @param name defines the name of the mesh
  22736. * @param options defines the options used to create the mesh
  22737. * @param scene defines the hosting scene
  22738. * @returns the dashed line mesh
  22739. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22740. */
  22741. static CreateDashedLines(name: string, options: {
  22742. points: Vector3[];
  22743. dashSize?: number;
  22744. gapSize?: number;
  22745. dashNb?: number;
  22746. updatable?: boolean;
  22747. instance?: LinesMesh;
  22748. }, scene?: Nullable<Scene>): LinesMesh;
  22749. /**
  22750. * 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.
  22751. * * 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.
  22752. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22753. * * 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.
  22754. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22755. * * 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
  22756. * * 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
  22757. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22759. * * 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
  22760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22762. * @param name defines the name of the mesh
  22763. * @param options defines the options used to create the mesh
  22764. * @param scene defines the hosting scene
  22765. * @returns the extruded shape mesh
  22766. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22768. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22769. */
  22770. static ExtrudeShape(name: string, options: {
  22771. shape: Vector3[];
  22772. path: Vector3[];
  22773. scale?: number;
  22774. rotation?: number;
  22775. cap?: number;
  22776. updatable?: boolean;
  22777. sideOrientation?: number;
  22778. frontUVs?: Vector4;
  22779. backUVs?: Vector4;
  22780. instance?: Mesh;
  22781. invertUV?: boolean;
  22782. }, scene?: Nullable<Scene>): Mesh;
  22783. /**
  22784. * Creates an custom extruded shape mesh.
  22785. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22786. * * 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.
  22787. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22788. * * 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
  22789. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22790. * * 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
  22791. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22792. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22793. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22794. * * 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
  22795. * * 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
  22796. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22798. * * 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
  22799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22801. * @param name defines the name of the mesh
  22802. * @param options defines the options used to create the mesh
  22803. * @param scene defines the hosting scene
  22804. * @returns the custom extruded shape mesh
  22805. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22806. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22807. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22808. */
  22809. static ExtrudeShapeCustom(name: string, options: {
  22810. shape: Vector3[];
  22811. path: Vector3[];
  22812. scaleFunction?: any;
  22813. rotationFunction?: any;
  22814. ribbonCloseArray?: boolean;
  22815. ribbonClosePath?: boolean;
  22816. cap?: number;
  22817. updatable?: boolean;
  22818. sideOrientation?: number;
  22819. frontUVs?: Vector4;
  22820. backUVs?: Vector4;
  22821. instance?: Mesh;
  22822. invertUV?: boolean;
  22823. }, scene: Scene): Mesh;
  22824. /**
  22825. * Creates lathe mesh.
  22826. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22827. * * 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
  22828. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22829. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22830. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  22831. * * 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
  22832. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22833. * * 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
  22834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22835. * * 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
  22836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22838. * @param name defines the name of the mesh
  22839. * @param options defines the options used to create the mesh
  22840. * @param scene defines the hosting scene
  22841. * @returns the lathe mesh
  22842. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22843. */
  22844. static CreateLathe(name: string, options: {
  22845. shape: Vector3[];
  22846. radius?: number;
  22847. tessellation?: number;
  22848. clip?: number;
  22849. arc?: number;
  22850. closed?: boolean;
  22851. updatable?: boolean;
  22852. sideOrientation?: number;
  22853. frontUVs?: Vector4;
  22854. backUVs?: Vector4;
  22855. cap?: number;
  22856. invertUV?: boolean;
  22857. }, scene: Scene): Mesh;
  22858. /**
  22859. * Creates a plane mesh
  22860. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22861. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22862. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22864. * * 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
  22865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22866. * @param name defines the name of the mesh
  22867. * @param options defines the options used to create the mesh
  22868. * @param scene defines the hosting scene
  22869. * @returns the plane mesh
  22870. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22871. */
  22872. static CreatePlane(name: string, options: {
  22873. size?: number;
  22874. width?: number;
  22875. height?: number;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. updatable?: boolean;
  22880. sourcePlane?: Plane;
  22881. }, scene: Scene): Mesh;
  22882. /**
  22883. * Creates a ground mesh
  22884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22887. * @param name defines the name of the mesh
  22888. * @param options defines the options used to create the mesh
  22889. * @param scene defines the hosting scene
  22890. * @returns the ground mesh
  22891. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22892. */
  22893. static CreateGround(name: string, options: {
  22894. width?: number;
  22895. height?: number;
  22896. subdivisions?: number;
  22897. subdivisionsX?: number;
  22898. subdivisionsY?: number;
  22899. updatable?: boolean;
  22900. }, scene: any): Mesh;
  22901. /**
  22902. * Creates a tiled ground mesh
  22903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22905. * * 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
  22906. * * 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
  22907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22908. * @param name defines the name of the mesh
  22909. * @param options defines the options used to create the mesh
  22910. * @param scene defines the hosting scene
  22911. * @returns the tiled ground mesh
  22912. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22913. */
  22914. static CreateTiledGround(name: string, options: {
  22915. xmin: number;
  22916. zmin: number;
  22917. xmax: number;
  22918. zmax: number;
  22919. subdivisions?: {
  22920. w: number;
  22921. h: number;
  22922. };
  22923. precision?: {
  22924. w: number;
  22925. h: number;
  22926. };
  22927. updatable?: boolean;
  22928. }, scene: Scene): Mesh;
  22929. /**
  22930. * Creates a ground mesh from a height map
  22931. * * The parameter `url` sets the URL of the height map image resource.
  22932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22936. * * 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.
  22937. * * 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).
  22938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22939. * @param name defines the name of the mesh
  22940. * @param url defines the url to the height map
  22941. * @param options defines the options used to create the mesh
  22942. * @param scene defines the hosting scene
  22943. * @returns the ground mesh
  22944. * @see http://doc.babylonjs.com/babylon101/height_map
  22945. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22946. */
  22947. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22948. width?: number;
  22949. height?: number;
  22950. subdivisions?: number;
  22951. minHeight?: number;
  22952. maxHeight?: number;
  22953. colorFilter?: Color3;
  22954. updatable?: boolean;
  22955. onReady?: (mesh: GroundMesh) => void;
  22956. }, scene: Scene): GroundMesh;
  22957. /**
  22958. * Creates a polygon mesh
  22959. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22960. * * 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
  22961. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22963. * * 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)
  22964. * * Remember you can only change the shape positions, not their number when updating a polygon
  22965. * @param name defines the name of the mesh
  22966. * @param options defines the options used to create the mesh
  22967. * @param scene defines the hosting scene
  22968. * @returns the polygon mesh
  22969. */
  22970. static CreatePolygon(name: string, options: {
  22971. shape: Vector3[];
  22972. holes?: Vector3[][];
  22973. depth?: number;
  22974. faceUV?: Vector4[];
  22975. faceColors?: Color4[];
  22976. updatable?: boolean;
  22977. sideOrientation?: number;
  22978. frontUVs?: Vector4;
  22979. backUVs?: Vector4;
  22980. }, scene: Scene): Mesh;
  22981. /**
  22982. * Creates an extruded polygon mesh, with depth in the Y direction.
  22983. * * 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)
  22984. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22985. * @param name defines the name of the mesh
  22986. * @param options defines the options used to create the mesh
  22987. * @param scene defines the hosting scene
  22988. * @returns the polygon mesh
  22989. */
  22990. static ExtrudePolygon(name: string, options: {
  22991. shape: Vector3[];
  22992. holes?: Vector3[][];
  22993. depth?: number;
  22994. faceUV?: Vector4[];
  22995. faceColors?: Color4[];
  22996. updatable?: boolean;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }, scene: Scene): Mesh;
  23001. /**
  23002. * Creates a tube mesh.
  23003. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23004. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23005. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23006. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23007. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23008. * * 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)
  23009. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23010. * * 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
  23011. * * 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
  23012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23013. * * 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
  23014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23016. * @param name defines the name of the mesh
  23017. * @param options defines the options used to create the mesh
  23018. * @param scene defines the hosting scene
  23019. * @returns the tube mesh
  23020. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23021. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23022. */
  23023. static CreateTube(name: string, options: {
  23024. path: Vector3[];
  23025. radius?: number;
  23026. tessellation?: number;
  23027. radiusFunction?: {
  23028. (i: number, distance: number): number;
  23029. };
  23030. cap?: number;
  23031. arc?: number;
  23032. updatable?: boolean;
  23033. sideOrientation?: number;
  23034. frontUVs?: Vector4;
  23035. backUVs?: Vector4;
  23036. instance?: Mesh;
  23037. invertUV?: boolean;
  23038. }, scene: Scene): Mesh;
  23039. /**
  23040. * Creates a polyhedron mesh
  23041. * * 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
  23042. * * The parameter `size` (positive float, default 1) sets the polygon size
  23043. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23044. * * 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`
  23045. * * 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
  23046. * * 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)`)
  23047. * * 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
  23048. * * 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
  23049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23050. * * 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
  23051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23052. * @param name defines the name of the mesh
  23053. * @param options defines the options used to create the mesh
  23054. * @param scene defines the hosting scene
  23055. * @returns the polyhedron mesh
  23056. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23057. */
  23058. static CreatePolyhedron(name: string, options: {
  23059. type?: number;
  23060. size?: number;
  23061. sizeX?: number;
  23062. sizeY?: number;
  23063. sizeZ?: number;
  23064. custom?: any;
  23065. faceUV?: Vector4[];
  23066. faceColors?: Color4[];
  23067. flat?: boolean;
  23068. updatable?: boolean;
  23069. sideOrientation?: number;
  23070. frontUVs?: Vector4;
  23071. backUVs?: Vector4;
  23072. }, scene: Scene): Mesh;
  23073. /**
  23074. * Creates a decal mesh.
  23075. * 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
  23076. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23077. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23078. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23079. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23080. * @param name defines the name of the mesh
  23081. * @param sourceMesh defines the mesh where the decal must be applied
  23082. * @param options defines the options used to create the mesh
  23083. * @param scene defines the hosting scene
  23084. * @returns the decal mesh
  23085. * @see http://doc.babylonjs.com/how_to/decals
  23086. */
  23087. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23088. position?: Vector3;
  23089. normal?: Vector3;
  23090. size?: Vector3;
  23091. angle?: number;
  23092. }): Mesh;
  23093. private static _ExtrudeShapeGeneric;
  23094. }
  23095. }
  23096. declare module BABYLON {
  23097. class MeshLODLevel {
  23098. distance: number;
  23099. mesh: Nullable<Mesh>;
  23100. constructor(distance: number, mesh: Nullable<Mesh>);
  23101. }
  23102. }
  23103. declare module BABYLON {
  23104. /**
  23105. * A simplifier interface for future simplification implementations.
  23106. */
  23107. interface ISimplifier {
  23108. /**
  23109. * Simplification of a given mesh according to the given settings.
  23110. * Since this requires computation, it is assumed that the function runs async.
  23111. * @param settings The settings of the simplification, including quality and distance
  23112. * @param successCallback A callback that will be called after the mesh was simplified.
  23113. * @param errorCallback in case of an error, this callback will be called. optional.
  23114. */
  23115. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23116. }
  23117. /**
  23118. * Expected simplification settings.
  23119. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23120. */
  23121. interface ISimplificationSettings {
  23122. quality: number;
  23123. distance: number;
  23124. optimizeMesh?: boolean;
  23125. }
  23126. class SimplificationSettings implements ISimplificationSettings {
  23127. quality: number;
  23128. distance: number;
  23129. optimizeMesh?: boolean | undefined;
  23130. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23131. }
  23132. interface ISimplificationTask {
  23133. settings: Array<ISimplificationSettings>;
  23134. simplificationType: SimplificationType;
  23135. mesh: Mesh;
  23136. successCallback?: () => void;
  23137. parallelProcessing: boolean;
  23138. }
  23139. class SimplificationQueue {
  23140. private _simplificationArray;
  23141. running: boolean;
  23142. constructor();
  23143. addTask(task: ISimplificationTask): void;
  23144. executeNext(): void;
  23145. runSimplification(task: ISimplificationTask): void;
  23146. private getSimplifier;
  23147. }
  23148. /**
  23149. * The implemented types of simplification
  23150. * At the moment only Quadratic Error Decimation is implemented
  23151. */
  23152. enum SimplificationType {
  23153. /** Quadratic error decimation */
  23154. QUADRATIC = 0
  23155. }
  23156. class DecimationTriangle {
  23157. vertices: Array<DecimationVertex>;
  23158. normal: Vector3;
  23159. error: Array<number>;
  23160. deleted: boolean;
  23161. isDirty: boolean;
  23162. borderFactor: number;
  23163. deletePending: boolean;
  23164. originalOffset: number;
  23165. constructor(vertices: Array<DecimationVertex>);
  23166. }
  23167. class DecimationVertex {
  23168. position: Vector3;
  23169. id: number;
  23170. q: QuadraticMatrix;
  23171. isBorder: boolean;
  23172. triangleStart: number;
  23173. triangleCount: number;
  23174. originalOffsets: Array<number>;
  23175. constructor(position: Vector3, id: number);
  23176. updatePosition(newPosition: Vector3): void;
  23177. }
  23178. class QuadraticMatrix {
  23179. data: Array<number>;
  23180. constructor(data?: Array<number>);
  23181. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23182. addInPlace(matrix: QuadraticMatrix): void;
  23183. addArrayInPlace(data: Array<number>): void;
  23184. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23185. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23186. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23187. }
  23188. class Reference {
  23189. vertexId: number;
  23190. triangleId: number;
  23191. constructor(vertexId: number, triangleId: number);
  23192. }
  23193. /**
  23194. * An implementation of the Quadratic Error simplification algorithm.
  23195. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23196. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23197. * @author RaananW
  23198. */
  23199. class QuadraticErrorSimplification implements ISimplifier {
  23200. private _mesh;
  23201. private triangles;
  23202. private vertices;
  23203. private references;
  23204. private _reconstructedMesh;
  23205. syncIterations: number;
  23206. aggressiveness: number;
  23207. decimationIterations: number;
  23208. boundingBoxEpsilon: number;
  23209. constructor(_mesh: Mesh);
  23210. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23211. private runDecimation;
  23212. private initWithMesh;
  23213. private init;
  23214. private reconstructMesh;
  23215. private initDecimatedMesh;
  23216. private isFlipped;
  23217. private updateTriangles;
  23218. private identifyBorder;
  23219. private updateMesh;
  23220. private vertexError;
  23221. private calculateError;
  23222. }
  23223. }
  23224. declare module BABYLON {
  23225. interface Scene {
  23226. /** @hidden (Backing field) */
  23227. /**
  23228. * Gets or sets the simplification queue attached to the scene
  23229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23230. */
  23231. simplificationQueue: SimplificationQueue;
  23232. }
  23233. interface Mesh {
  23234. /**
  23235. * Simplify the mesh according to the given array of settings.
  23236. * Function will return immediately and will simplify async. It returns the Mesh.
  23237. * @param settings a collection of simplification settings.
  23238. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23239. * @param type the type of simplification to run.
  23240. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23241. */
  23242. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23243. }
  23244. /**
  23245. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23246. * created in a scene
  23247. */
  23248. class SimplicationQueueSceneComponent implements ISceneComponent {
  23249. /**
  23250. * The component name helpfull to identify the component in the list of scene components.
  23251. */
  23252. readonly name: string;
  23253. /**
  23254. * The scene the component belongs to.
  23255. */
  23256. scene: Scene;
  23257. /**
  23258. * Creates a new instance of the component for the given scene
  23259. * @param scene Defines the scene to register the component in
  23260. */
  23261. constructor(scene: Scene);
  23262. /**
  23263. * Registers the component in a given scene
  23264. */
  23265. register(): void;
  23266. /**
  23267. * Rebuilds the elements related to this component in case of
  23268. * context lost for instance.
  23269. */
  23270. rebuild(): void;
  23271. /**
  23272. * Disposes the component and the associated ressources
  23273. */
  23274. dispose(): void;
  23275. private _beforeCameraUpdate;
  23276. }
  23277. }
  23278. declare module BABYLON {
  23279. class Polygon {
  23280. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23281. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23282. static Parse(input: string): Vector2[];
  23283. static StartingAt(x: number, y: number): Path2;
  23284. }
  23285. class PolygonMeshBuilder {
  23286. private _points;
  23287. private _outlinepoints;
  23288. private _holes;
  23289. private _name;
  23290. private _scene;
  23291. private _epoints;
  23292. private _eholes;
  23293. private _addToepoint;
  23294. constructor(name: string, contours: Path2, scene: Scene);
  23295. constructor(name: string, contours: Vector2[], scene: Scene);
  23296. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23297. build(updatable?: boolean, depth?: number): Mesh;
  23298. private addSide;
  23299. }
  23300. }
  23301. declare module BABYLON {
  23302. class BaseSubMesh {
  23303. /** @hidden */
  23304. /** @hidden */
  23305. readonly effect: Nullable<Effect>;
  23306. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23307. }
  23308. class SubMesh extends BaseSubMesh implements ICullable {
  23309. materialIndex: number;
  23310. verticesStart: number;
  23311. verticesCount: number;
  23312. indexStart: number;
  23313. indexCount: number;
  23314. linesIndexCount: number;
  23315. private _mesh;
  23316. private _renderingMesh;
  23317. private _boundingInfo;
  23318. private _linesIndexBuffer;
  23319. /** @hidden */
  23320. /** @hidden */
  23321. /** @hidden */
  23322. /** @hidden */
  23323. /** @hidden */
  23324. /** @hidden */
  23325. /** @hidden */
  23326. private _currentMaterial;
  23327. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23328. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23329. readonly IsGlobal: boolean;
  23330. /**
  23331. * Returns the submesh BoudingInfo object.
  23332. */
  23333. getBoundingInfo(): BoundingInfo;
  23334. /**
  23335. * Sets the submesh BoundingInfo.
  23336. * Return the SubMesh.
  23337. */
  23338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23339. /**
  23340. * Returns the mesh of the current submesh.
  23341. */
  23342. getMesh(): AbstractMesh;
  23343. /**
  23344. * Returns the rendering mesh of the submesh.
  23345. */
  23346. getRenderingMesh(): Mesh;
  23347. /**
  23348. * Returns the submesh material.
  23349. */
  23350. getMaterial(): Nullable<Material>;
  23351. /**
  23352. * Sets a new updated BoundingInfo object to the submesh.
  23353. * Returns the SubMesh.
  23354. */
  23355. refreshBoundingInfo(): SubMesh;
  23356. /** @hidden */
  23357. /**
  23358. * Updates the submesh BoundingInfo.
  23359. * Returns the Submesh.
  23360. */
  23361. updateBoundingInfo(world: Matrix): SubMesh;
  23362. /**
  23363. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23364. * Boolean returned.
  23365. */
  23366. isInFrustum(frustumPlanes: Plane[]): boolean;
  23367. /**
  23368. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23369. * Boolean returned.
  23370. */
  23371. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23372. /**
  23373. * Renders the submesh.
  23374. * Returns it.
  23375. */
  23376. render(enableAlphaMode: boolean): SubMesh;
  23377. /**
  23378. * Returns a new Index Buffer.
  23379. * Type returned : WebGLBuffer.
  23380. */
  23381. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23382. /**
  23383. * True is the passed Ray intersects the submesh bounding box.
  23384. * Boolean returned.
  23385. */
  23386. canIntersects(ray: Ray): boolean;
  23387. /**
  23388. * Returns an object IntersectionInfo.
  23389. */
  23390. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23391. /** @hidden */
  23392. /**
  23393. * Creates a new Submesh from the passed Mesh.
  23394. */
  23395. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23396. /**
  23397. * Disposes the Submesh.
  23398. * Returns nothing.
  23399. */
  23400. dispose(): void;
  23401. /**
  23402. * Creates a new Submesh from the passed parameters :
  23403. * - materialIndex (integer) : the index of the main mesh material.
  23404. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23405. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23406. * - mesh (Mesh) : the main mesh to create the submesh from.
  23407. * - renderingMesh (optional Mesh) : rendering mesh.
  23408. */
  23409. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23410. }
  23411. }
  23412. declare module BABYLON {
  23413. class TransformNode extends Node {
  23414. static BILLBOARDMODE_NONE: number;
  23415. static BILLBOARDMODE_X: number;
  23416. static BILLBOARDMODE_Y: number;
  23417. static BILLBOARDMODE_Z: number;
  23418. static BILLBOARDMODE_ALL: number;
  23419. private _forward;
  23420. private _forwardInverted;
  23421. private _up;
  23422. private _right;
  23423. private _rightInverted;
  23424. private _rotation;
  23425. private _rotationQuaternion;
  23426. protected _scaling: Vector3;
  23427. protected _isDirty: boolean;
  23428. private _transformToBoneReferal;
  23429. /**
  23430. * Set the billboard mode. Default is 0.
  23431. *
  23432. * | Value | Type | Description |
  23433. * | --- | --- | --- |
  23434. * | 0 | BILLBOARDMODE_NONE | |
  23435. * | 1 | BILLBOARDMODE_X | |
  23436. * | 2 | BILLBOARDMODE_Y | |
  23437. * | 4 | BILLBOARDMODE_Z | |
  23438. * | 7 | BILLBOARDMODE_ALL | |
  23439. *
  23440. */
  23441. billboardMode: number;
  23442. scalingDeterminant: number;
  23443. infiniteDistance: boolean;
  23444. /**
  23445. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23446. * By default the system will update normals to compensate
  23447. */
  23448. ignoreNonUniformScaling: boolean;
  23449. position: Vector3;
  23450. /** @hidden */
  23451. private _localWorld;
  23452. /** @hidden */
  23453. /** @hidden */
  23454. private _absolutePosition;
  23455. private _pivotMatrix;
  23456. private _pivotMatrixInverse;
  23457. private _postMultiplyPivotMatrix;
  23458. protected _isWorldMatrixFrozen: boolean;
  23459. /**
  23460. * An event triggered after the world matrix is updated
  23461. */
  23462. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23463. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23464. /**
  23465. * Gets a string identifying the name of the class
  23466. * @returns "TransformNode" string
  23467. */
  23468. getClassName(): string;
  23469. /**
  23470. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23471. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23472. * Default : (0.0, 0.0, 0.0)
  23473. */
  23474. rotation: Vector3;
  23475. /**
  23476. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23477. * Default : (1.0, 1.0, 1.0)
  23478. */
  23479. /**
  23480. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23481. * Default : (1.0, 1.0, 1.0)
  23482. */
  23483. scaling: Vector3;
  23484. /**
  23485. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23486. * It's null by default.
  23487. * 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)
  23488. */
  23489. rotationQuaternion: Nullable<Quaternion>;
  23490. /**
  23491. * The forward direction of that transform in world space.
  23492. */
  23493. readonly forward: Vector3;
  23494. /**
  23495. * The up direction of that transform in world space.
  23496. */
  23497. readonly up: Vector3;
  23498. /**
  23499. * The right direction of that transform in world space.
  23500. */
  23501. readonly right: Vector3;
  23502. /**
  23503. * Returns the latest update of the World matrix
  23504. * Returns a Matrix.
  23505. */
  23506. getWorldMatrix(): Matrix;
  23507. /** @hidden */
  23508. /**
  23509. * Returns directly the latest state of the mesh World matrix.
  23510. * A Matrix is returned.
  23511. */
  23512. readonly worldMatrixFromCache: Matrix;
  23513. /**
  23514. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23515. * Returns the TransformNode.
  23516. */
  23517. updatePoseMatrix(matrix: Matrix): TransformNode;
  23518. /**
  23519. * Returns the mesh Pose matrix.
  23520. * Returned object : Matrix
  23521. */
  23522. getPoseMatrix(): Matrix;
  23523. /** @hidden */
  23524. /** @hidden */
  23525. markAsDirty(property: string): TransformNode;
  23526. /**
  23527. * Returns the current mesh absolute position.
  23528. * Returns a Vector3.
  23529. */
  23530. readonly absolutePosition: Vector3;
  23531. /**
  23532. * Sets a new matrix to apply before all other transformation
  23533. * @param matrix defines the transform matrix
  23534. * @returns the current TransformNode
  23535. */
  23536. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23537. /**
  23538. * Sets a new pivot matrix to the current node
  23539. * @param matrix defines the new pivot matrix to use
  23540. * @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
  23541. * @returns the current TransformNode
  23542. */
  23543. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23544. /**
  23545. * Returns the mesh pivot matrix.
  23546. * Default : Identity.
  23547. * A Matrix is returned.
  23548. */
  23549. getPivotMatrix(): Matrix;
  23550. /**
  23551. * Prevents the World matrix to be computed any longer.
  23552. * Returns the TransformNode.
  23553. */
  23554. freezeWorldMatrix(): TransformNode;
  23555. /**
  23556. * Allows back the World matrix computation.
  23557. * Returns the TransformNode.
  23558. */
  23559. unfreezeWorldMatrix(): this;
  23560. /**
  23561. * True if the World matrix has been frozen.
  23562. * Returns a boolean.
  23563. */
  23564. readonly isWorldMatrixFrozen: boolean;
  23565. /**
  23566. * Retuns the mesh absolute position in the World.
  23567. * Returns a Vector3.
  23568. */
  23569. getAbsolutePosition(): Vector3;
  23570. /**
  23571. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23572. * Returns the TransformNode.
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Sets the mesh position in its local space.
  23577. * Returns the TransformNode.
  23578. */
  23579. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23580. /**
  23581. * Returns the mesh position in the local space from the current World matrix values.
  23582. * Returns a new Vector3.
  23583. */
  23584. getPositionExpressedInLocalSpace(): Vector3;
  23585. /**
  23586. * Translates the mesh along the passed Vector3 in its local space.
  23587. * Returns the TransformNode.
  23588. */
  23589. locallyTranslate(vector3: Vector3): TransformNode;
  23590. private static _lookAtVectorCache;
  23591. /**
  23592. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23593. * @param targetPoint the position (must be in same space as current mesh) to look at
  23594. * @param yawCor optional yaw (y-axis) correction in radians
  23595. * @param pitchCor optional pitch (x-axis) correction in radians
  23596. * @param rollCor optional roll (z-axis) correction in radians
  23597. * @param space the choosen space of the target
  23598. * @returns the TransformNode.
  23599. */
  23600. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23601. /**
  23602. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23603. * This Vector3 is expressed in the World space.
  23604. */
  23605. getDirection(localAxis: Vector3): Vector3;
  23606. /**
  23607. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23608. * localAxis is expressed in the mesh local space.
  23609. * result is computed in the Wordl space from the mesh World matrix.
  23610. * Returns the TransformNode.
  23611. */
  23612. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23613. /**
  23614. * Sets a new pivot point to the current node
  23615. * @param point defines the new pivot point to use
  23616. * @param space defines if the point is in world or local space (local by default)
  23617. * @returns the current TransformNode
  23618. */
  23619. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23620. /**
  23621. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23622. */
  23623. getPivotPoint(): Vector3;
  23624. /**
  23625. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23626. * Returns the TransformNode.
  23627. */
  23628. getPivotPointToRef(result: Vector3): TransformNode;
  23629. /**
  23630. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23631. */
  23632. getAbsolutePivotPoint(): Vector3;
  23633. /**
  23634. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23635. * Returns the TransformNode.
  23636. */
  23637. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23638. /**
  23639. * Defines the passed node as the parent of the current node.
  23640. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23641. * Returns the TransformNode.
  23642. */
  23643. setParent(node: Nullable<Node>): TransformNode;
  23644. private _nonUniformScaling;
  23645. readonly nonUniformScaling: boolean;
  23646. /** @hidden */
  23647. /**
  23648. * Attach the current TransformNode to another TransformNode associated with a bone
  23649. * @param bone Bone affecting the TransformNode
  23650. * @param affectedTransformNode TransformNode associated with the bone
  23651. */
  23652. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23653. detachFromBone(): TransformNode;
  23654. private static _rotationAxisCache;
  23655. /**
  23656. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23657. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23658. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23659. * The passed axis is also normalized.
  23660. * Returns the TransformNode.
  23661. */
  23662. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23663. /**
  23664. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23665. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23666. * The passed axis is also normalized.
  23667. * Returns the TransformNode.
  23668. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23669. */
  23670. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23671. /**
  23672. * Translates the mesh along the axis vector for the passed distance in the given space.
  23673. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23674. * Returns the TransformNode.
  23675. */
  23676. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23677. /**
  23678. * Adds a rotation step to the mesh current rotation.
  23679. * x, y, z are Euler angles expressed in radians.
  23680. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23681. * This means this rotation is made in the mesh local space only.
  23682. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23683. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23684. * ```javascript
  23685. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23686. * ```
  23687. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23688. * 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.
  23689. * Returns the TransformNode.
  23690. */
  23691. addRotation(x: number, y: number, z: number): TransformNode;
  23692. /**
  23693. * Computes the mesh World matrix and returns it.
  23694. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23695. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23696. * If the parameter `force`is set to `true`, the actual computation is done.
  23697. * Returns the mesh World Matrix.
  23698. */
  23699. computeWorldMatrix(force?: boolean): Matrix;
  23700. protected _afterComputeWorldMatrix(): void;
  23701. /**
  23702. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23703. * @param func: callback function to add
  23704. *
  23705. * Returns the TransformNode.
  23706. */
  23707. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23708. /**
  23709. * Removes a registered callback function.
  23710. * Returns the TransformNode.
  23711. */
  23712. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23713. /**
  23714. * Clone the current transform node
  23715. * Returns the new transform node
  23716. * @param name Name of the new clone
  23717. * @param newParent New parent for the clone
  23718. * @param doNotCloneChildren Do not clone children hierarchy
  23719. */
  23720. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23721. serialize(currentSerializationObject?: any): any;
  23722. /**
  23723. * Returns a new TransformNode object parsed from the source provided.
  23724. * The parameter `parsedMesh` is the source.
  23725. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23726. */
  23727. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23728. /**
  23729. * Releases resources associated with this transform node.
  23730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23732. */
  23733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23734. }
  23735. }
  23736. declare module BABYLON {
  23737. class VertexBuffer {
  23738. /** @hidden */
  23739. private _kind;
  23740. private _size;
  23741. private _ownsBuffer;
  23742. private _instanced;
  23743. private _instanceDivisor;
  23744. /**
  23745. * The byte type.
  23746. */
  23747. static readonly BYTE: number;
  23748. /**
  23749. * The unsigned byte type.
  23750. */
  23751. static readonly UNSIGNED_BYTE: number;
  23752. /**
  23753. * The short type.
  23754. */
  23755. static readonly SHORT: number;
  23756. /**
  23757. * The unsigned short type.
  23758. */
  23759. static readonly UNSIGNED_SHORT: number;
  23760. /**
  23761. * The integer type.
  23762. */
  23763. static readonly INT: number;
  23764. /**
  23765. * The unsigned integer type.
  23766. */
  23767. static readonly UNSIGNED_INT: number;
  23768. /**
  23769. * The float type.
  23770. */
  23771. static readonly FLOAT: number;
  23772. /**
  23773. * Gets or sets the instance divisor when in instanced mode
  23774. */
  23775. instanceDivisor: number;
  23776. /**
  23777. * Gets the byte stride.
  23778. */
  23779. readonly byteStride: number;
  23780. /**
  23781. * Gets the byte offset.
  23782. */
  23783. readonly byteOffset: number;
  23784. /**
  23785. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23786. */
  23787. readonly normalized: boolean;
  23788. /**
  23789. * Gets the data type of each component in the array.
  23790. */
  23791. readonly type: number;
  23792. /**
  23793. * Constructor
  23794. * @param engine the engine
  23795. * @param data the data to use for this vertex buffer
  23796. * @param kind the vertex buffer kind
  23797. * @param updatable whether the data is updatable
  23798. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23799. * @param stride the stride (optional)
  23800. * @param instanced whether the buffer is instanced (optional)
  23801. * @param offset the offset of the data (optional)
  23802. * @param size the number of components (optional)
  23803. * @param type the type of the component (optional)
  23804. * @param normalized whether the data contains normalized data (optional)
  23805. * @param useBytes set to true if stride and offset are in bytes (optional)
  23806. */
  23807. 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);
  23808. /** @hidden */
  23809. /**
  23810. * Returns the kind of the VertexBuffer (string).
  23811. */
  23812. getKind(): string;
  23813. /**
  23814. * Boolean : is the VertexBuffer updatable ?
  23815. */
  23816. isUpdatable(): boolean;
  23817. /**
  23818. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23819. */
  23820. getData(): Nullable<DataArray>;
  23821. /**
  23822. * Returns the WebGLBuffer associated to the VertexBuffer.
  23823. */
  23824. getBuffer(): Nullable<WebGLBuffer>;
  23825. /**
  23826. * Returns the stride as a multiple of the type byte length.
  23827. * DEPRECATED. Use byteStride instead.
  23828. */
  23829. getStrideSize(): number;
  23830. /**
  23831. * Returns the offset as a multiple of the type byte length.
  23832. * DEPRECATED. Use byteOffset instead.
  23833. */
  23834. getOffset(): number;
  23835. /**
  23836. * Returns the number of components per vertex attribute (integer).
  23837. */
  23838. getSize(): number;
  23839. /**
  23840. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23841. */
  23842. getIsInstanced(): boolean;
  23843. /**
  23844. * Returns the instancing divisor, zero for non-instanced (integer).
  23845. */
  23846. getInstanceDivisor(): number;
  23847. /**
  23848. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23849. * Returns the created WebGLBuffer.
  23850. */
  23851. create(data?: DataArray): void;
  23852. /**
  23853. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23854. * This function will create a new buffer if the current one is not updatable
  23855. * Returns the updated WebGLBuffer.
  23856. */
  23857. update(data: DataArray): void;
  23858. /**
  23859. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23860. * Returns the directly updated WebGLBuffer.
  23861. * @param data the new data
  23862. * @param offset the new offset
  23863. * @param useBytes set to true if the offset is in bytes
  23864. */
  23865. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23866. /**
  23867. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23868. */
  23869. dispose(): void;
  23870. /**
  23871. * Enumerates each value of this vertex buffer as numbers.
  23872. * @param count the number of values to enumerate
  23873. * @param callback the callback function called for each value
  23874. */
  23875. forEach(count: number, callback: (value: number, index: number) => void): void;
  23876. private static _PositionKind;
  23877. private static _NormalKind;
  23878. private static _TangentKind;
  23879. private static _UVKind;
  23880. private static _UV2Kind;
  23881. private static _UV3Kind;
  23882. private static _UV4Kind;
  23883. private static _UV5Kind;
  23884. private static _UV6Kind;
  23885. private static _ColorKind;
  23886. private static _MatricesIndicesKind;
  23887. private static _MatricesWeightsKind;
  23888. private static _MatricesIndicesExtraKind;
  23889. private static _MatricesWeightsExtraKind;
  23890. static readonly PositionKind: string;
  23891. static readonly NormalKind: string;
  23892. static readonly TangentKind: string;
  23893. static readonly UVKind: string;
  23894. static readonly UV2Kind: string;
  23895. static readonly UV3Kind: string;
  23896. static readonly UV4Kind: string;
  23897. static readonly UV5Kind: string;
  23898. static readonly UV6Kind: string;
  23899. static readonly ColorKind: string;
  23900. static readonly MatricesIndicesKind: string;
  23901. static readonly MatricesWeightsKind: string;
  23902. static readonly MatricesIndicesExtraKind: string;
  23903. static readonly MatricesWeightsExtraKind: string;
  23904. /**
  23905. * Deduces the stride given a kind.
  23906. * @param kind The kind string to deduce
  23907. * @returns The deduced stride
  23908. */
  23909. static DeduceStride(kind: string): number;
  23910. /**
  23911. * Gets the byte length of the given type.
  23912. * @param type the type
  23913. * @returns the number of bytes
  23914. */
  23915. static GetTypeByteLength(type: number): number;
  23916. /**
  23917. * Enumerates each value of the given parameters as numbers.
  23918. * @param data the data to enumerate
  23919. * @param byteOffset the byte offset of the data
  23920. * @param byteStride the byte stride of the data
  23921. * @param componentCount the number of components per element
  23922. * @param componentType the type of the component
  23923. * @param count the total number of components
  23924. * @param normalized whether the data is normalized
  23925. * @param callback the callback function called for each value
  23926. */
  23927. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23928. private static _GetFloatValue;
  23929. }
  23930. }
  23931. declare module BABYLON {
  23932. /**
  23933. * Defines a target to use with MorphTargetManager
  23934. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23935. */
  23936. class MorphTarget implements IAnimatable {
  23937. /** defines the name of the target */
  23938. name: string;
  23939. /**
  23940. * Gets or sets the list of animations
  23941. */
  23942. animations: Animation[];
  23943. private _scene;
  23944. private _positions;
  23945. private _normals;
  23946. private _tangents;
  23947. private _influence;
  23948. /**
  23949. * Observable raised when the influence changes
  23950. */
  23951. onInfluenceChanged: Observable<boolean>;
  23952. /**
  23953. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23954. */
  23955. influence: number;
  23956. private _animationPropertiesOverride;
  23957. /**
  23958. * Gets or sets the animation properties override
  23959. */
  23960. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23961. /**
  23962. * Creates a new MorphTarget
  23963. * @param name defines the name of the target
  23964. * @param influence defines the influence to use
  23965. */
  23966. constructor(
  23967. /** defines the name of the target */
  23968. name: string, influence?: number, scene?: Nullable<Scene>);
  23969. /**
  23970. * Gets a boolean defining if the target contains position data
  23971. */
  23972. readonly hasPositions: boolean;
  23973. /**
  23974. * Gets a boolean defining if the target contains normal data
  23975. */
  23976. readonly hasNormals: boolean;
  23977. /**
  23978. * Gets a boolean defining if the target contains tangent data
  23979. */
  23980. readonly hasTangents: boolean;
  23981. /**
  23982. * Affects position data to this target
  23983. * @param data defines the position data to use
  23984. */
  23985. setPositions(data: Nullable<FloatArray>): void;
  23986. /**
  23987. * Gets the position data stored in this target
  23988. * @returns a FloatArray containing the position data (or null if not present)
  23989. */
  23990. getPositions(): Nullable<FloatArray>;
  23991. /**
  23992. * Affects normal data to this target
  23993. * @param data defines the normal data to use
  23994. */
  23995. setNormals(data: Nullable<FloatArray>): void;
  23996. /**
  23997. * Gets the normal data stored in this target
  23998. * @returns a FloatArray containing the normal data (or null if not present)
  23999. */
  24000. getNormals(): Nullable<FloatArray>;
  24001. /**
  24002. * Affects tangent data to this target
  24003. * @param data defines the tangent data to use
  24004. */
  24005. setTangents(data: Nullable<FloatArray>): void;
  24006. /**
  24007. * Gets the tangent data stored in this target
  24008. * @returns a FloatArray containing the tangent data (or null if not present)
  24009. */
  24010. getTangents(): Nullable<FloatArray>;
  24011. /**
  24012. * Serializes the current target into a Serialization object
  24013. * @returns the serialized object
  24014. */
  24015. serialize(): any;
  24016. /**
  24017. * Creates a new target from serialized data
  24018. * @param serializationObject defines the serialized data to use
  24019. * @returns a new MorphTarget
  24020. */
  24021. static Parse(serializationObject: any): MorphTarget;
  24022. /**
  24023. * Creates a MorphTarget from mesh data
  24024. * @param mesh defines the source mesh
  24025. * @param name defines the name to use for the new target
  24026. * @param influence defines the influence to attach to the target
  24027. * @returns a new MorphTarget
  24028. */
  24029. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24030. }
  24031. }
  24032. declare module BABYLON {
  24033. /**
  24034. * This class is used to deform meshes using morphing between different targets
  24035. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24036. */
  24037. class MorphTargetManager {
  24038. private _targets;
  24039. private _targetObservable;
  24040. private _activeTargets;
  24041. private _scene;
  24042. private _influences;
  24043. private _supportsNormals;
  24044. private _supportsTangents;
  24045. private _vertexCount;
  24046. private _uniqueId;
  24047. private _tempInfluences;
  24048. /**
  24049. * Creates a new MorphTargetManager
  24050. * @param scene defines the current scene
  24051. */
  24052. constructor(scene?: Nullable<Scene>);
  24053. /**
  24054. * Gets the unique ID of this manager
  24055. */
  24056. readonly uniqueId: number;
  24057. /**
  24058. * Gets the number of vertices handled by this manager
  24059. */
  24060. readonly vertexCount: number;
  24061. /**
  24062. * Gets a boolean indicating if this manager supports morphing of normals
  24063. */
  24064. readonly supportsNormals: boolean;
  24065. /**
  24066. * Gets a boolean indicating if this manager supports morphing of tangents
  24067. */
  24068. readonly supportsTangents: boolean;
  24069. /**
  24070. * Gets the number of targets stored in this manager
  24071. */
  24072. readonly numTargets: number;
  24073. /**
  24074. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24075. */
  24076. readonly numInfluencers: number;
  24077. /**
  24078. * Gets the list of influences (one per target)
  24079. */
  24080. readonly influences: Float32Array;
  24081. /**
  24082. * Gets the active target at specified index. An active target is a target with an influence > 0
  24083. * @param index defines the index to check
  24084. * @returns the requested target
  24085. */
  24086. getActiveTarget(index: number): MorphTarget;
  24087. /**
  24088. * Gets the target at specified index
  24089. * @param index defines the index to check
  24090. * @returns the requested target
  24091. */
  24092. getTarget(index: number): MorphTarget;
  24093. /**
  24094. * Add a new target to this manager
  24095. * @param target defines the target to add
  24096. */
  24097. addTarget(target: MorphTarget): void;
  24098. /**
  24099. * Removes a target from the manager
  24100. * @param target defines the target to remove
  24101. */
  24102. removeTarget(target: MorphTarget): void;
  24103. /**
  24104. * Serializes the current manager into a Serialization object
  24105. * @returns the serialized object
  24106. */
  24107. serialize(): any;
  24108. private _syncActiveTargets;
  24109. /**
  24110. * Syncrhonize the targets with all the meshes using this morph target manager
  24111. */
  24112. synchronize(): void;
  24113. /**
  24114. * Creates a new MorphTargetManager from serialized data
  24115. * @param serializationObject defines the serialized data
  24116. * @param scene defines the hosting scene
  24117. * @returns the new MorphTargetManager
  24118. */
  24119. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24120. }
  24121. }
  24122. declare module BABYLON {
  24123. interface PhysicsImpostorJoint {
  24124. mainImpostor: PhysicsImpostor;
  24125. connectedImpostor: PhysicsImpostor;
  24126. joint: PhysicsJoint;
  24127. }
  24128. class PhysicsEngine {
  24129. private _physicsPlugin;
  24130. gravity: Vector3;
  24131. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24132. setGravity(gravity: Vector3): void;
  24133. /**
  24134. * Set the time step of the physics engine.
  24135. * default is 1/60.
  24136. * To slow it down, enter 1/600 for example.
  24137. * To speed it up, 1/30
  24138. * @param {number} newTimeStep the new timestep to apply to this world.
  24139. */
  24140. setTimeStep(newTimeStep?: number): void;
  24141. /**
  24142. * Get the time step of the physics engine.
  24143. */
  24144. getTimeStep(): number;
  24145. dispose(): void;
  24146. getPhysicsPluginName(): string;
  24147. static Epsilon: number;
  24148. private _impostors;
  24149. private _joints;
  24150. /**
  24151. * Adding a new impostor for the impostor tracking.
  24152. * This will be done by the impostor itself.
  24153. * @param {PhysicsImpostor} impostor the impostor to add
  24154. */
  24155. addImpostor(impostor: PhysicsImpostor): void;
  24156. /**
  24157. * Remove an impostor from the engine.
  24158. * This impostor and its mesh will not longer be updated by the physics engine.
  24159. * @param {PhysicsImpostor} impostor the impostor to remove
  24160. */
  24161. removeImpostor(impostor: PhysicsImpostor): void;
  24162. /**
  24163. * Add a joint to the physics engine
  24164. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24165. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24166. * @param {PhysicsJoint} the joint that will connect both impostors.
  24167. */
  24168. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24169. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24170. /**
  24171. * Called by the scene. no need to call it.
  24172. * @hidden
  24173. */
  24174. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24175. getImpostors(): Array<PhysicsImpostor>;
  24176. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24177. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24178. }
  24179. interface IPhysicsEnginePlugin {
  24180. world: any;
  24181. name: string;
  24182. setGravity(gravity: Vector3): void;
  24183. setTimeStep(timeStep: number): void;
  24184. getTimeStep(): number;
  24185. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24186. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24187. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24188. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24189. removePhysicsBody(impostor: PhysicsImpostor): void;
  24190. generateJoint(joint: PhysicsImpostorJoint): void;
  24191. removeJoint(joint: PhysicsImpostorJoint): void;
  24192. isSupported(): boolean;
  24193. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24194. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24195. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24196. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24197. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24198. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24199. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24200. getBodyMass(impostor: PhysicsImpostor): number;
  24201. getBodyFriction(impostor: PhysicsImpostor): number;
  24202. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24203. getBodyRestitution(impostor: PhysicsImpostor): number;
  24204. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24205. sleepBody(impostor: PhysicsImpostor): void;
  24206. wakeUpBody(impostor: PhysicsImpostor): void;
  24207. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24208. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24209. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24210. getRadius(impostor: PhysicsImpostor): number;
  24211. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24213. dispose(): void;
  24214. }
  24215. }
  24216. declare module BABYLON {
  24217. class PhysicsHelper {
  24218. private _scene;
  24219. private _physicsEngine;
  24220. constructor(scene: Scene);
  24221. /**
  24222. * @param {Vector3} origin the origin of the explosion
  24223. * @param {number} radius the explosion radius
  24224. * @param {number} strength the explosion strength
  24225. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24226. */
  24227. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24228. /**
  24229. * @param {Vector3} origin the origin of the explosion
  24230. * @param {number} radius the explosion radius
  24231. * @param {number} strength the explosion strength
  24232. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24233. */
  24234. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24235. /**
  24236. * @param {Vector3} origin the origin of the explosion
  24237. * @param {number} radius the explosion radius
  24238. * @param {number} strength the explosion strength
  24239. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24240. */
  24241. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24242. /**
  24243. * @param {Vector3} origin the origin of the updraft
  24244. * @param {number} radius the radius of the updraft
  24245. * @param {number} strength the strength of the updraft
  24246. * @param {number} height the height of the updraft
  24247. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24248. */
  24249. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24250. /**
  24251. * @param {Vector3} origin the of the vortex
  24252. * @param {number} radius the radius of the vortex
  24253. * @param {number} strength the strength of the vortex
  24254. * @param {number} height the height of the vortex
  24255. */
  24256. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24257. }
  24258. /***** Radial explosion *****/
  24259. class PhysicsRadialExplosionEvent {
  24260. private _scene;
  24261. private _sphere;
  24262. private _sphereOptions;
  24263. private _rays;
  24264. private _dataFetched;
  24265. constructor(scene: Scene);
  24266. /**
  24267. * Returns the data related to the radial explosion event (sphere & rays).
  24268. * @returns {PhysicsRadialExplosionEventData}
  24269. */
  24270. getData(): PhysicsRadialExplosionEventData;
  24271. /**
  24272. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24273. * @param impostor
  24274. * @param {Vector3} origin the origin of the explosion
  24275. * @param {number} radius the explosion radius
  24276. * @param {number} strength the explosion strength
  24277. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24278. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24279. */
  24280. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24281. /**
  24282. * Disposes the sphere.
  24283. * @param {bolean} force
  24284. */
  24285. dispose(force?: boolean): void;
  24286. /*** Helpers ***/
  24287. private _prepareSphere;
  24288. private _intersectsWithSphere;
  24289. }
  24290. /***** Gravitational Field *****/
  24291. class PhysicsGravitationalFieldEvent {
  24292. private _physicsHelper;
  24293. private _scene;
  24294. private _origin;
  24295. private _radius;
  24296. private _strength;
  24297. private _falloff;
  24298. private _tickCallback;
  24299. private _sphere;
  24300. private _dataFetched;
  24301. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24302. /**
  24303. * Returns the data related to the gravitational field event (sphere).
  24304. * @returns {PhysicsGravitationalFieldEventData}
  24305. */
  24306. getData(): PhysicsGravitationalFieldEventData;
  24307. /**
  24308. * Enables the gravitational field.
  24309. */
  24310. enable(): void;
  24311. /**
  24312. * Disables the gravitational field.
  24313. */
  24314. disable(): void;
  24315. /**
  24316. * Disposes the sphere.
  24317. * @param {bolean} force
  24318. */
  24319. dispose(force?: boolean): void;
  24320. private _tick;
  24321. }
  24322. /***** Updraft *****/
  24323. class PhysicsUpdraftEvent {
  24324. private _scene;
  24325. private _origin;
  24326. private _radius;
  24327. private _strength;
  24328. private _height;
  24329. private _updraftMode;
  24330. private _physicsEngine;
  24331. private _originTop;
  24332. private _originDirection;
  24333. private _tickCallback;
  24334. private _cylinder;
  24335. private _cylinderPosition;
  24336. private _dataFetched;
  24337. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24338. /**
  24339. * Returns the data related to the updraft event (cylinder).
  24340. * @returns {PhysicsUpdraftEventData}
  24341. */
  24342. getData(): PhysicsUpdraftEventData;
  24343. /**
  24344. * Enables the updraft.
  24345. */
  24346. enable(): void;
  24347. /**
  24348. * Disables the cortex.
  24349. */
  24350. disable(): void;
  24351. /**
  24352. * Disposes the sphere.
  24353. * @param {bolean} force
  24354. */
  24355. dispose(force?: boolean): void;
  24356. private getImpostorForceAndContactPoint;
  24357. private _tick;
  24358. /*** Helpers ***/
  24359. private _prepareCylinder;
  24360. private _intersectsWithCylinder;
  24361. }
  24362. /***** Vortex *****/
  24363. class PhysicsVortexEvent {
  24364. private _scene;
  24365. private _origin;
  24366. private _radius;
  24367. private _strength;
  24368. private _height;
  24369. private _physicsEngine;
  24370. private _originTop;
  24371. private _centripetalForceThreshold;
  24372. private _updraftMultiplier;
  24373. private _tickCallback;
  24374. private _cylinder;
  24375. private _cylinderPosition;
  24376. private _dataFetched;
  24377. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24378. /**
  24379. * Returns the data related to the vortex event (cylinder).
  24380. * @returns {PhysicsVortexEventData}
  24381. */
  24382. getData(): PhysicsVortexEventData;
  24383. /**
  24384. * Enables the vortex.
  24385. */
  24386. enable(): void;
  24387. /**
  24388. * Disables the cortex.
  24389. */
  24390. disable(): void;
  24391. /**
  24392. * Disposes the sphere.
  24393. * @param {bolean} force
  24394. */
  24395. dispose(force?: boolean): void;
  24396. private getImpostorForceAndContactPoint;
  24397. private _tick;
  24398. /*** Helpers ***/
  24399. private _prepareCylinder;
  24400. private _intersectsWithCylinder;
  24401. }
  24402. /***** Enums *****/
  24403. /**
  24404. * The strenght of the force in correspondence to the distance of the affected object
  24405. */
  24406. enum PhysicsRadialImpulseFalloff {
  24407. /** Defines that impulse is constant in strength across it's whole radius */
  24408. Constant = 0,
  24409. /** DEfines that impulse gets weaker if it's further from the origin */
  24410. Linear = 1
  24411. }
  24412. /**
  24413. * The strenght of the force in correspondence to the distance of the affected object
  24414. */
  24415. enum PhysicsUpdraftMode {
  24416. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24417. Center = 0,
  24418. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24419. Perpendicular = 1
  24420. }
  24421. /***** Data interfaces *****/
  24422. interface PhysicsForceAndContactPoint {
  24423. force: Vector3;
  24424. contactPoint: Vector3;
  24425. }
  24426. interface PhysicsRadialExplosionEventData {
  24427. sphere: Mesh;
  24428. rays: Array<Ray>;
  24429. }
  24430. interface PhysicsGravitationalFieldEventData {
  24431. sphere: Mesh;
  24432. }
  24433. interface PhysicsUpdraftEventData {
  24434. cylinder: Mesh;
  24435. }
  24436. interface PhysicsVortexEventData {
  24437. cylinder: Mesh;
  24438. }
  24439. }
  24440. declare module BABYLON {
  24441. interface PhysicsImpostorParameters {
  24442. mass: number;
  24443. friction?: number;
  24444. restitution?: number;
  24445. nativeOptions?: any;
  24446. ignoreParent?: boolean;
  24447. disableBidirectionalTransformation?: boolean;
  24448. }
  24449. interface IPhysicsEnabledObject {
  24450. position: Vector3;
  24451. rotationQuaternion: Nullable<Quaternion>;
  24452. scaling: Vector3;
  24453. rotation?: Vector3;
  24454. parent?: any;
  24455. getBoundingInfo(): BoundingInfo;
  24456. computeWorldMatrix(force: boolean): Matrix;
  24457. getWorldMatrix?(): Matrix;
  24458. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24459. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24460. getIndices?(): Nullable<IndicesArray>;
  24461. getScene?(): Scene;
  24462. getAbsolutePosition(): Vector3;
  24463. getAbsolutePivotPoint(): Vector3;
  24464. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24467. getClassName(): string;
  24468. }
  24469. class PhysicsImpostor {
  24470. object: IPhysicsEnabledObject;
  24471. type: number;
  24472. private _options;
  24473. private _scene?;
  24474. static DEFAULT_OBJECT_SIZE: Vector3;
  24475. static IDENTITY_QUATERNION: Quaternion;
  24476. private _physicsEngine;
  24477. private _physicsBody;
  24478. private _bodyUpdateRequired;
  24479. private _onBeforePhysicsStepCallbacks;
  24480. private _onAfterPhysicsStepCallbacks;
  24481. private _onPhysicsCollideCallbacks;
  24482. private _deltaPosition;
  24483. private _deltaRotation;
  24484. private _deltaRotationConjugated;
  24485. private _parent;
  24486. private _isDisposed;
  24487. private static _tmpVecs;
  24488. private static _tmpQuat;
  24489. readonly isDisposed: boolean;
  24490. mass: number;
  24491. friction: number;
  24492. restitution: number;
  24493. uniqueId: number;
  24494. private _joints;
  24495. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24496. /**
  24497. * This function will completly initialize this impostor.
  24498. * It will create a new body - but only if this mesh has no parent.
  24499. * If it has, this impostor will not be used other than to define the impostor
  24500. * of the child mesh.
  24501. * @hidden
  24502. */
  24503. private _getPhysicsParent;
  24504. /**
  24505. * Should a new body be generated.
  24506. */
  24507. isBodyInitRequired(): boolean;
  24508. setScalingUpdated(updated: boolean): void;
  24509. /**
  24510. * Force a regeneration of this or the parent's impostor's body.
  24511. * Use under cautious - This will remove all joints already implemented.
  24512. */
  24513. forceUpdate(): void;
  24514. /**
  24515. * Gets the body that holds this impostor. Either its own, or its parent.
  24516. */
  24517. /**
  24518. * Set the physics body. Used mainly by the physics engine/plugin
  24519. */
  24520. physicsBody: any;
  24521. parent: Nullable<PhysicsImpostor>;
  24522. resetUpdateFlags(): void;
  24523. getObjectExtendSize(): Vector3;
  24524. getObjectCenter(): Vector3;
  24525. /**
  24526. * Get a specific parametes from the options parameter.
  24527. */
  24528. getParam(paramName: string): any;
  24529. /**
  24530. * Sets a specific parameter in the options given to the physics plugin
  24531. */
  24532. setParam(paramName: string, value: number): void;
  24533. /**
  24534. * Specifically change the body's mass option. Won't recreate the physics body object
  24535. */
  24536. setMass(mass: number): void;
  24537. getLinearVelocity(): Nullable<Vector3>;
  24538. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24539. getAngularVelocity(): Nullable<Vector3>;
  24540. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24541. /**
  24542. * Execute a function with the physics plugin native code.
  24543. * Provide a function the will have two variables - the world object and the physics body object.
  24544. */
  24545. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24546. /**
  24547. * Register a function that will be executed before the physics world is stepping forward.
  24548. */
  24549. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24550. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24551. /**
  24552. * Register a function that will be executed after the physics step
  24553. */
  24554. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24555. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24556. /**
  24557. * register a function that will be executed when this impostor collides against a different body.
  24558. */
  24559. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24560. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24561. private _tmpQuat;
  24562. private _tmpQuat2;
  24563. getParentsRotation(): Quaternion;
  24564. /**
  24565. * this function is executed by the physics engine.
  24566. */
  24567. beforeStep: () => void;
  24568. /**
  24569. * this function is executed by the physics engine.
  24570. */
  24571. afterStep: () => void;
  24572. /**
  24573. * Legacy collision detection event support
  24574. */
  24575. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24576. onCollide: (e: {
  24577. body: any;
  24578. }) => void;
  24579. /**
  24580. * Apply a force
  24581. */
  24582. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24583. /**
  24584. * Apply an impulse
  24585. */
  24586. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24587. /**
  24588. * A help function to create a joint.
  24589. */
  24590. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24591. /**
  24592. * Add a joint to this impostor with a different impostor.
  24593. */
  24594. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24595. /**
  24596. * Will keep this body still, in a sleep mode.
  24597. */
  24598. sleep(): PhysicsImpostor;
  24599. /**
  24600. * Wake the body up.
  24601. */
  24602. wakeUp(): PhysicsImpostor;
  24603. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24604. dispose(): void;
  24605. setDeltaPosition(position: Vector3): void;
  24606. setDeltaRotation(rotation: Quaternion): void;
  24607. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24608. getRadius(): number;
  24609. /**
  24610. * Sync a bone with this impostor
  24611. * @param bone The bone to sync to the impostor.
  24612. * @param boneMesh The mesh that the bone is influencing.
  24613. * @param jointPivot The pivot of the joint / bone in local space.
  24614. * @param distToJoint Optional distance from the impostor to the joint.
  24615. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24616. */
  24617. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24618. /**
  24619. * Sync impostor to a bone
  24620. * @param bone The bone that the impostor will be synced to.
  24621. * @param boneMesh The mesh that the bone is influencing.
  24622. * @param jointPivot The pivot of the joint / bone in local space.
  24623. * @param distToJoint Optional distance from the impostor to the joint.
  24624. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24625. * @param boneAxis Optional vector3 axis the bone is aligned with
  24626. */
  24627. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24628. static NoImpostor: number;
  24629. static SphereImpostor: number;
  24630. static BoxImpostor: number;
  24631. static PlaneImpostor: number;
  24632. static MeshImpostor: number;
  24633. static CylinderImpostor: number;
  24634. static ParticleImpostor: number;
  24635. static HeightmapImpostor: number;
  24636. }
  24637. }
  24638. declare module BABYLON {
  24639. interface PhysicsJointData {
  24640. mainPivot?: Vector3;
  24641. connectedPivot?: Vector3;
  24642. mainAxis?: Vector3;
  24643. connectedAxis?: Vector3;
  24644. collision?: boolean;
  24645. nativeParams?: any;
  24646. }
  24647. /**
  24648. * This is a holder class for the physics joint created by the physics plugin.
  24649. * It holds a set of functions to control the underlying joint.
  24650. */
  24651. class PhysicsJoint {
  24652. type: number;
  24653. jointData: PhysicsJointData;
  24654. private _physicsJoint;
  24655. protected _physicsPlugin: IPhysicsEnginePlugin;
  24656. constructor(type: number, jointData: PhysicsJointData);
  24657. physicsJoint: any;
  24658. physicsPlugin: IPhysicsEnginePlugin;
  24659. /**
  24660. * Execute a function that is physics-plugin specific.
  24661. * @param {Function} func the function that will be executed.
  24662. * It accepts two parameters: the physics world and the physics joint.
  24663. */
  24664. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24665. static DistanceJoint: number;
  24666. static HingeJoint: number;
  24667. static BallAndSocketJoint: number;
  24668. static WheelJoint: number;
  24669. static SliderJoint: number;
  24670. static PrismaticJoint: number;
  24671. static UniversalJoint: number;
  24672. static Hinge2Joint: number;
  24673. static PointToPointJoint: number;
  24674. static SpringJoint: number;
  24675. static LockJoint: number;
  24676. }
  24677. /**
  24678. * A class representing a physics distance joint.
  24679. */
  24680. class DistanceJoint extends PhysicsJoint {
  24681. constructor(jointData: DistanceJointData);
  24682. /**
  24683. * Update the predefined distance.
  24684. */
  24685. updateDistance(maxDistance: number, minDistance?: number): void;
  24686. }
  24687. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24688. constructor(type: number, jointData: PhysicsJointData);
  24689. /**
  24690. * Set the motor values.
  24691. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24692. * @param {number} force the force to apply
  24693. * @param {number} maxForce max force for this motor.
  24694. */
  24695. setMotor(force?: number, maxForce?: number): void;
  24696. /**
  24697. * Set the motor's limits.
  24698. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24699. */
  24700. setLimit(upperLimit: number, lowerLimit?: number): void;
  24701. }
  24702. /**
  24703. * This class represents a single hinge physics joint
  24704. */
  24705. class HingeJoint extends MotorEnabledJoint {
  24706. constructor(jointData: PhysicsJointData);
  24707. /**
  24708. * Set the motor values.
  24709. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24710. * @param {number} force the force to apply
  24711. * @param {number} maxForce max force for this motor.
  24712. */
  24713. setMotor(force?: number, maxForce?: number): void;
  24714. /**
  24715. * Set the motor's limits.
  24716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24717. */
  24718. setLimit(upperLimit: number, lowerLimit?: number): void;
  24719. }
  24720. /**
  24721. * This class represents a dual hinge physics joint (same as wheel joint)
  24722. */
  24723. class Hinge2Joint extends MotorEnabledJoint {
  24724. constructor(jointData: PhysicsJointData);
  24725. /**
  24726. * Set the motor values.
  24727. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24728. * @param {number} force the force to apply
  24729. * @param {number} maxForce max force for this motor.
  24730. * @param {motorIndex} the motor's index, 0 or 1.
  24731. */
  24732. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24733. /**
  24734. * Set the motor limits.
  24735. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24736. * @param {number} upperLimit the upper limit
  24737. * @param {number} lowerLimit lower limit
  24738. * @param {motorIndex} the motor's index, 0 or 1.
  24739. */
  24740. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24741. }
  24742. interface IMotorEnabledJoint {
  24743. physicsJoint: any;
  24744. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24745. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24746. }
  24747. interface DistanceJointData extends PhysicsJointData {
  24748. maxDistance: number;
  24749. }
  24750. interface SpringJointData extends PhysicsJointData {
  24751. length: number;
  24752. stiffness: number;
  24753. damping: number;
  24754. /** this callback will be called when applying the force to the impostors. */
  24755. forceApplicationCallback: () => void;
  24756. }
  24757. }
  24758. declare module BABYLON {
  24759. /**
  24760. * This represents the base class for particle system in Babylon.
  24761. * 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.
  24762. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24763. * @example https://doc.babylonjs.com/babylon101/particles
  24764. */
  24765. class BaseParticleSystem {
  24766. /**
  24767. * Source color is added to the destination color without alpha affecting the result.
  24768. */
  24769. static BLENDMODE_ONEONE: number;
  24770. /**
  24771. * Blend current color and particle color using particle’s alpha.
  24772. */
  24773. static BLENDMODE_STANDARD: number;
  24774. /**
  24775. * Add current color and particle color multiplied by particle’s alpha.
  24776. */
  24777. static BLENDMODE_ADD: number;
  24778. /**
  24779. * Multiply current color with particle color
  24780. */
  24781. static BLENDMODE_MULTIPLY: number;
  24782. /**
  24783. * List of animations used by the particle system.
  24784. */
  24785. animations: Animation[];
  24786. /**
  24787. * The id of the Particle system.
  24788. */
  24789. id: string;
  24790. /**
  24791. * The friendly name of the Particle system.
  24792. */
  24793. name: string;
  24794. /**
  24795. * The rendering group used by the Particle system to chose when to render.
  24796. */
  24797. renderingGroupId: number;
  24798. /**
  24799. * The emitter represents the Mesh or position we are attaching the particle system to.
  24800. */
  24801. emitter: Nullable<AbstractMesh | Vector3>;
  24802. /**
  24803. * The maximum number of particles to emit per frame
  24804. */
  24805. emitRate: number;
  24806. /**
  24807. * If you want to launch only a few particles at once, that can be done, as well.
  24808. */
  24809. manualEmitCount: number;
  24810. /**
  24811. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24812. */
  24813. updateSpeed: number;
  24814. /**
  24815. * The amount of time the particle system is running (depends of the overall update speed).
  24816. */
  24817. targetStopDuration: number;
  24818. /**
  24819. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24820. */
  24821. disposeOnStop: boolean;
  24822. /**
  24823. * Minimum power of emitting particles.
  24824. */
  24825. minEmitPower: number;
  24826. /**
  24827. * Maximum power of emitting particles.
  24828. */
  24829. maxEmitPower: number;
  24830. /**
  24831. * Minimum life time of emitting particles.
  24832. */
  24833. minLifeTime: number;
  24834. /**
  24835. * Maximum life time of emitting particles.
  24836. */
  24837. maxLifeTime: number;
  24838. /**
  24839. * Minimum Size of emitting particles.
  24840. */
  24841. minSize: number;
  24842. /**
  24843. * Maximum Size of emitting particles.
  24844. */
  24845. maxSize: number;
  24846. /**
  24847. * Minimum scale of emitting particles on X axis.
  24848. */
  24849. minScaleX: number;
  24850. /**
  24851. * Maximum scale of emitting particles on X axis.
  24852. */
  24853. maxScaleX: number;
  24854. /**
  24855. * Minimum scale of emitting particles on Y axis.
  24856. */
  24857. minScaleY: number;
  24858. /**
  24859. * Maximum scale of emitting particles on Y axis.
  24860. */
  24861. maxScaleY: number;
  24862. /**
  24863. * Gets or sets the minimal initial rotation in radians.
  24864. */
  24865. minInitialRotation: number;
  24866. /**
  24867. * Gets or sets the maximal initial rotation in radians.
  24868. */
  24869. maxInitialRotation: number;
  24870. /**
  24871. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24872. */
  24873. minAngularSpeed: number;
  24874. /**
  24875. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24876. */
  24877. maxAngularSpeed: number;
  24878. /**
  24879. * The texture used to render each particle. (this can be a spritesheet)
  24880. */
  24881. particleTexture: Nullable<Texture>;
  24882. /**
  24883. * The layer mask we are rendering the particles through.
  24884. */
  24885. layerMask: number;
  24886. /**
  24887. * This can help using your own shader to render the particle system.
  24888. * The according effect will be created
  24889. */
  24890. customShader: any;
  24891. /**
  24892. * By default particle system starts as soon as they are created. This prevents the
  24893. * automatic start to happen and let you decide when to start emitting particles.
  24894. */
  24895. preventAutoStart: boolean;
  24896. /**
  24897. * Gets or sets a texture used to add random noise to particle positions
  24898. */
  24899. noiseTexture: Nullable<BaseTexture>;
  24900. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24901. noiseStrength: Vector3;
  24902. /**
  24903. * Callback triggered when the particle animation is ending.
  24904. */
  24905. onAnimationEnd: Nullable<() => void>;
  24906. /**
  24907. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24908. */
  24909. blendMode: number;
  24910. /**
  24911. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24912. * to override the particles.
  24913. */
  24914. forceDepthWrite: boolean;
  24915. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24916. preWarmCycles: number;
  24917. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24918. preWarmStepOffset: number;
  24919. /**
  24920. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24921. */
  24922. spriteCellChangeSpeed: number;
  24923. /**
  24924. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24925. */
  24926. startSpriteCellID: number;
  24927. /**
  24928. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24929. */
  24930. endSpriteCellID: number;
  24931. /**
  24932. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24933. */
  24934. spriteCellWidth: number;
  24935. /**
  24936. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24937. */
  24938. spriteCellHeight: number;
  24939. /**
  24940. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  24941. */
  24942. spriteRandomStartCell: boolean;
  24943. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24944. translationPivot: Vector2;
  24945. /** @hidden */
  24946. protected _isAnimationSheetEnabled: boolean;
  24947. /**
  24948. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24949. */
  24950. isAnimationSheetEnabled: boolean;
  24951. /**
  24952. * Get hosting scene
  24953. * @returns the scene
  24954. */
  24955. getScene(): Scene;
  24956. /**
  24957. * You can use gravity if you want to give an orientation to your particles.
  24958. */
  24959. gravity: Vector3;
  24960. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24961. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24962. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24963. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24964. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24965. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24966. protected _dragGradients: Nullable<Array<FactorGradient>>;
  24967. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  24968. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  24969. /**
  24970. * Gets the current list of drag gradients.
  24971. * You must use addDragGradient and removeDragGradient to udpate this list
  24972. * @returns the list of drag gradients
  24973. */
  24974. getDragGradients(): Nullable<Array<FactorGradient>>;
  24975. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24976. limitVelocityDamping: number;
  24977. /**
  24978. * Gets the current list of limit velocity gradients.
  24979. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24980. * @returns the list of limit velocity gradients
  24981. */
  24982. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24983. /**
  24984. * Gets the current list of color gradients.
  24985. * You must use addColorGradient and removeColorGradient to udpate this list
  24986. * @returns the list of color gradients
  24987. */
  24988. getColorGradients(): Nullable<Array<ColorGradient>>;
  24989. /**
  24990. * Gets the current list of size gradients.
  24991. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24992. * @returns the list of size gradients
  24993. */
  24994. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24995. /**
  24996. * Gets the current list of life time gradients.
  24997. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24998. * @returns the list of life time gradients
  24999. */
  25000. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  25001. /**
  25002. * Gets the current list of angular speed gradients.
  25003. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25004. * @returns the list of angular speed gradients
  25005. */
  25006. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25007. /**
  25008. * Gets the current list of velocity gradients.
  25009. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25010. * @returns the list of velocity gradients
  25011. */
  25012. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25013. /**
  25014. * Gets the current list of start size gradients.
  25015. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  25016. * @returns the list of start size gradients
  25017. */
  25018. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  25019. /**
  25020. * Gets the current list of emit rate gradients.
  25021. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25022. * @returns the list of emit rate gradients
  25023. */
  25024. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25025. /**
  25026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25027. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25028. */
  25029. direction1: Vector3;
  25030. /**
  25031. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25032. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25033. */
  25034. direction2: Vector3;
  25035. /**
  25036. * 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.
  25037. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25038. */
  25039. minEmitBox: Vector3;
  25040. /**
  25041. * 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.
  25042. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25043. */
  25044. maxEmitBox: Vector3;
  25045. /**
  25046. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25047. */
  25048. color1: Color4;
  25049. /**
  25050. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25051. */
  25052. color2: Color4;
  25053. /**
  25054. * Color the particle will have at the end of its lifetime
  25055. */
  25056. colorDead: Color4;
  25057. /**
  25058. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  25059. */
  25060. textureMask: Color4;
  25061. /**
  25062. * The particle emitter type defines the emitter used by the particle system.
  25063. * It can be for example box, sphere, or cone...
  25064. */
  25065. particleEmitterType: IParticleEmitterType;
  25066. /**
  25067. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25068. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25069. */
  25070. billboardMode: number;
  25071. protected _isBillboardBased: boolean;
  25072. /**
  25073. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25074. */
  25075. isBillboardBased: boolean;
  25076. /**
  25077. * The scene the particle system belongs to.
  25078. */
  25079. protected _scene: Scene;
  25080. /**
  25081. * Local cache of defines for image processing.
  25082. */
  25083. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  25084. /**
  25085. * Default configuration related to image processing available in the standard Material.
  25086. */
  25087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25088. /**
  25089. * Gets the image processing configuration used either in this material.
  25090. */
  25091. /**
  25092. * Sets the Default image processing configuration used either in the this material.
  25093. *
  25094. * If sets to null, the scene one is in use.
  25095. */
  25096. imageProcessingConfiguration: ImageProcessingConfiguration;
  25097. /**
  25098. * Attaches a new image processing configuration to the Standard Material.
  25099. * @param configuration
  25100. */
  25101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25102. /** @hidden */
  25103. protected _reset(): void;
  25104. /**
  25105. * Instantiates a particle system.
  25106. * 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.
  25107. * @param name The name of the particle system
  25108. */
  25109. constructor(name: string);
  25110. /**
  25111. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25112. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25113. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25114. * @returns the emitter
  25115. */
  25116. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25117. /**
  25118. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25119. * @param radius The radius of the hemisphere to emit from
  25120. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25121. * @returns the emitter
  25122. */
  25123. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  25124. /**
  25125. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25126. * @param radius The radius of the sphere to emit from
  25127. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25128. * @returns the emitter
  25129. */
  25130. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  25131. /**
  25132. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25133. * @param radius The radius of the sphere to emit from
  25134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25136. * @returns the emitter
  25137. */
  25138. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25139. /**
  25140. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25141. * @param radius The radius of the emission cylinder
  25142. * @param height The height of the emission cylinder
  25143. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25144. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25145. * @returns the emitter
  25146. */
  25147. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  25148. /**
  25149. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  25150. * @param radius The radius of the cylinder to emit from
  25151. * @param height The height of the emission cylinder
  25152. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  25153. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  25154. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  25155. * @returns the emitter
  25156. */
  25157. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  25158. /**
  25159. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25160. * @param radius The radius of the cone to emit from
  25161. * @param angle The base angle of the cone
  25162. * @returns the emitter
  25163. */
  25164. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25165. /**
  25166. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25169. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25170. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25171. * @returns the emitter
  25172. */
  25173. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25174. }
  25175. }
  25176. declare module BABYLON {
  25177. /**
  25178. * This represents a GPU particle system in Babylon
  25179. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  25180. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  25181. */
  25182. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  25183. /**
  25184. * The layer mask we are rendering the particles through.
  25185. */
  25186. layerMask: number;
  25187. private _capacity;
  25188. private _activeCount;
  25189. private _currentActiveCount;
  25190. private _accumulatedCount;
  25191. private _renderEffect;
  25192. private _updateEffect;
  25193. private _buffer0;
  25194. private _buffer1;
  25195. private _spriteBuffer;
  25196. private _updateVAO;
  25197. private _renderVAO;
  25198. private _targetIndex;
  25199. private _sourceBuffer;
  25200. private _targetBuffer;
  25201. private _engine;
  25202. private _currentRenderId;
  25203. private _started;
  25204. private _stopped;
  25205. private _timeDelta;
  25206. private _randomTexture;
  25207. private _randomTexture2;
  25208. private _attributesStrideSize;
  25209. private _updateEffectOptions;
  25210. private _randomTextureSize;
  25211. private _actualFrame;
  25212. private readonly _rawTextureWidth;
  25213. /**
  25214. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  25215. */
  25216. static readonly IsSupported: boolean;
  25217. /**
  25218. * An event triggered when the system is disposed.
  25219. */
  25220. onDisposeObservable: Observable<GPUParticleSystem>;
  25221. /**
  25222. * Gets the maximum number of particles active at the same time.
  25223. * @returns The max number of active particles.
  25224. */
  25225. getCapacity(): number;
  25226. /**
  25227. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25228. * to override the particles.
  25229. */
  25230. forceDepthWrite: boolean;
  25231. /**
  25232. * Gets or set the number of active particles
  25233. */
  25234. activeParticleCount: number;
  25235. private _preWarmDone;
  25236. /**
  25237. * Is this system ready to be used/rendered
  25238. * @return true if the system is ready
  25239. */
  25240. isReady(): boolean;
  25241. /**
  25242. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25243. * @returns True if it has been started, otherwise false.
  25244. */
  25245. isStarted(): boolean;
  25246. /**
  25247. * Starts the particle system and begins to emit
  25248. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25249. */
  25250. start(delay?: number): void;
  25251. /**
  25252. * Stops the particle system.
  25253. */
  25254. stop(): void;
  25255. /**
  25256. * Remove all active particles
  25257. */
  25258. reset(): void;
  25259. /**
  25260. * Returns the string "GPUParticleSystem"
  25261. * @returns a string containing the class name
  25262. */
  25263. getClassName(): string;
  25264. private _colorGradientsTexture;
  25265. private _removeGradient;
  25266. /**
  25267. * Adds a new color gradient
  25268. * @param gradient defines the gradient to use (between 0 and 1)
  25269. * @param color defines the color to affect to the specified gradient
  25270. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25271. * @returns the current particle system
  25272. */
  25273. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  25274. /**
  25275. * Remove a specific color gradient
  25276. * @param gradient defines the gradient to remove
  25277. * @returns the current particle system
  25278. */
  25279. removeColorGradient(gradient: number): GPUParticleSystem;
  25280. private _angularSpeedGradientsTexture;
  25281. private _sizeGradientsTexture;
  25282. private _velocityGradientsTexture;
  25283. private _limitVelocityGradientsTexture;
  25284. private _dragGradientsTexture;
  25285. private _addFactorGradient;
  25286. /**
  25287. * Adds a new size gradient
  25288. * @param gradient defines the gradient to use (between 0 and 1)
  25289. * @param factor defines the size factor to affect to the specified gradient
  25290. * @returns the current particle system
  25291. */
  25292. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25293. /**
  25294. * Remove a specific size gradient
  25295. * @param gradient defines the gradient to remove
  25296. * @returns the current particle system
  25297. */
  25298. removeSizeGradient(gradient: number): GPUParticleSystem;
  25299. /**
  25300. * Adds a new angular speed gradient
  25301. * @param gradient defines the gradient to use (between 0 and 1)
  25302. * @param factor defines the angular speed to affect to the specified gradient
  25303. * @returns the current particle system
  25304. */
  25305. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25306. /**
  25307. * Remove a specific angular speed gradient
  25308. * @param gradient defines the gradient to remove
  25309. * @returns the current particle system
  25310. */
  25311. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25312. /**
  25313. * Adds a new velocity gradient
  25314. * @param gradient defines the gradient to use (between 0 and 1)
  25315. * @param factor defines the velocity to affect to the specified gradient
  25316. * @returns the current particle system
  25317. */
  25318. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25319. /**
  25320. * Remove a specific velocity gradient
  25321. * @param gradient defines the gradient to remove
  25322. * @returns the current particle system
  25323. */
  25324. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25325. /**
  25326. * Adds a new limit velocity gradient
  25327. * @param gradient defines the gradient to use (between 0 and 1)
  25328. * @param factor defines the limit velocity value to affect to the specified gradient
  25329. * @returns the current particle system
  25330. */
  25331. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25332. /**
  25333. * Remove a specific limit velocity gradient
  25334. * @param gradient defines the gradient to remove
  25335. * @returns the current particle system
  25336. */
  25337. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25338. /**
  25339. * Adds a new drag gradient
  25340. * @param gradient defines the gradient to use (between 0 and 1)
  25341. * @param factor defines the drag value to affect to the specified gradient
  25342. * @returns the current particle system
  25343. */
  25344. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  25345. /**
  25346. * Remove a specific drag gradient
  25347. * @param gradient defines the gradient to remove
  25348. * @returns the current particle system
  25349. */
  25350. removeDragGradient(gradient: number): GPUParticleSystem;
  25351. /**
  25352. * Not supported by GPUParticleSystem
  25353. * @param gradient defines the gradient to use (between 0 and 1)
  25354. * @param factor defines the emit rate value to affect to the specified gradient
  25355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25356. * @returns the current particle system
  25357. */
  25358. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25359. /**
  25360. * Not supported by GPUParticleSystem
  25361. * @param gradient defines the gradient to remove
  25362. * @returns the current particle system
  25363. */
  25364. removeEmitRateGradient(gradient: number): IParticleSystem;
  25365. /**
  25366. * Not supported by GPUParticleSystem
  25367. * @param gradient defines the gradient to use (between 0 and 1)
  25368. * @param factor defines the start size value to affect to the specified gradient
  25369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25370. * @returns the current particle system
  25371. */
  25372. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25373. /**
  25374. * Not supported by GPUParticleSystem
  25375. * @param gradient defines the gradient to remove
  25376. * @returns the current particle system
  25377. */
  25378. removeStartSizeGradient(gradient: number): IParticleSystem;
  25379. /**
  25380. * Instantiates a GPU particle system.
  25381. * 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.
  25382. * @param name The name of the particle system
  25383. * @param options The options used to create the system
  25384. * @param scene The scene the particle system belongs to
  25385. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25386. */
  25387. constructor(name: string, options: Partial<{
  25388. capacity: number;
  25389. randomTextureSize: number;
  25390. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25391. protected _reset(): void;
  25392. private _createUpdateVAO;
  25393. private _createRenderVAO;
  25394. private _initialize;
  25395. /** @hidden */
  25396. /** @hidden */
  25397. /**
  25398. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25399. * @param preWarm defines if we are in the pre-warmimg phase
  25400. */
  25401. animate(preWarm?: boolean): void;
  25402. private _createFactorGradientTexture;
  25403. private _createSizeGradientTexture;
  25404. private _createAngularSpeedGradientTexture;
  25405. private _createVelocityGradientTexture;
  25406. private _createLimitVelocityGradientTexture;
  25407. private _createDragGradientTexture;
  25408. private _createColorGradientTexture;
  25409. /**
  25410. * Renders the particle system in its current state
  25411. * @param preWarm defines if the system should only update the particles but not render them
  25412. * @returns the current number of particles
  25413. */
  25414. render(preWarm?: boolean): number;
  25415. /**
  25416. * Rebuilds the particle system
  25417. */
  25418. rebuild(): void;
  25419. private _releaseBuffers;
  25420. private _releaseVAOs;
  25421. /**
  25422. * Disposes the particle system and free the associated resources
  25423. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25424. */
  25425. dispose(disposeTexture?: boolean): void;
  25426. /**
  25427. * Clones the particle system.
  25428. * @param name The name of the cloned object
  25429. * @param newEmitter The new emitter to use
  25430. * @returns the cloned particle system
  25431. */
  25432. clone(name: string, newEmitter: any): GPUParticleSystem;
  25433. /**
  25434. * Serializes the particle system to a JSON object.
  25435. * @returns the JSON object
  25436. */
  25437. serialize(): any;
  25438. /**
  25439. * Parses a JSON object to create a GPU particle system.
  25440. * @param parsedParticleSystem The JSON object to parse
  25441. * @param scene The scene to create the particle system in
  25442. * @param rootUrl The root url to use to load external dependencies like texture
  25443. * @returns the parsed GPU particle system
  25444. */
  25445. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25446. }
  25447. }
  25448. declare module BABYLON {
  25449. /**
  25450. * Interface representing a particle system in Babylon.js.
  25451. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25452. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25453. */
  25454. interface IParticleSystem {
  25455. /**
  25456. * List of animations used by the particle system.
  25457. */
  25458. animations: Animation[];
  25459. /**
  25460. * The id of the Particle system.
  25461. */
  25462. id: string;
  25463. /**
  25464. * The name of the Particle system.
  25465. */
  25466. name: string;
  25467. /**
  25468. * The emitter represents the Mesh or position we are attaching the particle system to.
  25469. */
  25470. emitter: Nullable<AbstractMesh | Vector3>;
  25471. /**
  25472. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25473. */
  25474. isBillboardBased: boolean;
  25475. /**
  25476. * The rendering group used by the Particle system to chose when to render.
  25477. */
  25478. renderingGroupId: number;
  25479. /**
  25480. * The layer mask we are rendering the particles through.
  25481. */
  25482. layerMask: number;
  25483. /**
  25484. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25485. */
  25486. updateSpeed: number;
  25487. /**
  25488. * The amount of time the particle system is running (depends of the overall update speed).
  25489. */
  25490. targetStopDuration: number;
  25491. /**
  25492. * The texture used to render each particle. (this can be a spritesheet)
  25493. */
  25494. particleTexture: Nullable<Texture>;
  25495. /**
  25496. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25497. */
  25498. blendMode: number;
  25499. /**
  25500. * Minimum life time of emitting particles.
  25501. */
  25502. minLifeTime: number;
  25503. /**
  25504. * Maximum life time of emitting particles.
  25505. */
  25506. maxLifeTime: number;
  25507. /**
  25508. * Minimum Size of emitting particles.
  25509. */
  25510. minSize: number;
  25511. /**
  25512. * Maximum Size of emitting particles.
  25513. */
  25514. maxSize: number;
  25515. /**
  25516. * Minimum scale of emitting particles on X axis.
  25517. */
  25518. minScaleX: number;
  25519. /**
  25520. * Maximum scale of emitting particles on X axis.
  25521. */
  25522. maxScaleX: number;
  25523. /**
  25524. * Minimum scale of emitting particles on Y axis.
  25525. */
  25526. minScaleY: number;
  25527. /**
  25528. * Maximum scale of emitting particles on Y axis.
  25529. */
  25530. maxScaleY: number;
  25531. /**
  25532. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25533. */
  25534. color1: Color4;
  25535. /**
  25536. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25537. */
  25538. color2: Color4;
  25539. /**
  25540. * Color the particle will have at the end of its lifetime.
  25541. */
  25542. colorDead: Color4;
  25543. /**
  25544. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25545. */
  25546. emitRate: number;
  25547. /**
  25548. * You can use gravity if you want to give an orientation to your particles.
  25549. */
  25550. gravity: Vector3;
  25551. /**
  25552. * Minimum power of emitting particles.
  25553. */
  25554. minEmitPower: number;
  25555. /**
  25556. * Maximum power of emitting particles.
  25557. */
  25558. maxEmitPower: number;
  25559. /**
  25560. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25561. */
  25562. minAngularSpeed: number;
  25563. /**
  25564. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25565. */
  25566. maxAngularSpeed: number;
  25567. /**
  25568. * Gets or sets the minimal initial rotation in radians.
  25569. */
  25570. minInitialRotation: number;
  25571. /**
  25572. * Gets or sets the maximal initial rotation in radians.
  25573. */
  25574. maxInitialRotation: number;
  25575. /**
  25576. * The particle emitter type defines the emitter used by the particle system.
  25577. * It can be for example box, sphere, or cone...
  25578. */
  25579. particleEmitterType: Nullable<IParticleEmitterType>;
  25580. /**
  25581. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  25582. */
  25583. preWarmCycles: number;
  25584. /**
  25585. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25586. */
  25587. preWarmStepOffset: number;
  25588. /**
  25589. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  25590. */
  25591. spriteCellChangeSpeed: number;
  25592. /**
  25593. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25594. */
  25595. startSpriteCellID: number;
  25596. /**
  25597. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25598. */
  25599. endSpriteCellID: number;
  25600. /**
  25601. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25602. */
  25603. spriteCellWidth: number;
  25604. /**
  25605. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25606. */
  25607. spriteCellHeight: number;
  25608. /**
  25609. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  25610. */
  25611. spriteRandomStartCell: boolean;
  25612. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25613. translationPivot: Vector2;
  25614. /**
  25615. * Gets or sets a texture used to add random noise to particle positions
  25616. */
  25617. noiseTexture: Nullable<BaseTexture>;
  25618. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25619. noiseStrength: Vector3;
  25620. /**
  25621. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25622. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25623. */
  25624. billboardMode: number;
  25625. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25626. limitVelocityDamping: number;
  25627. /**
  25628. * Gets the maximum number of particles active at the same time.
  25629. * @returns The max number of active particles.
  25630. */
  25631. getCapacity(): number;
  25632. /**
  25633. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25634. * @returns True if it has been started, otherwise false.
  25635. */
  25636. isStarted(): boolean;
  25637. /**
  25638. * Animates the particle system for this frame.
  25639. */
  25640. animate(): void;
  25641. /**
  25642. * Renders the particle system in its current state.
  25643. * @returns the current number of particles
  25644. */
  25645. render(): number;
  25646. /**
  25647. * Dispose the particle system and frees its associated resources.
  25648. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25649. */
  25650. dispose(disposeTexture?: boolean): void;
  25651. /**
  25652. * Clones the particle system.
  25653. * @param name The name of the cloned object
  25654. * @param newEmitter The new emitter to use
  25655. * @returns the cloned particle system
  25656. */
  25657. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25658. /**
  25659. * Serializes the particle system to a JSON object.
  25660. * @returns the JSON object
  25661. */
  25662. serialize(): any;
  25663. /**
  25664. * Rebuild the particle system
  25665. */
  25666. rebuild(): void;
  25667. /**
  25668. * Starts the particle system and begins to emit
  25669. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25670. */
  25671. start(delay?: number): void;
  25672. /**
  25673. * Stops the particle system.
  25674. */
  25675. stop(): void;
  25676. /**
  25677. * Remove all active particles
  25678. */
  25679. reset(): void;
  25680. /**
  25681. * Is this system ready to be used/rendered
  25682. * @return true if the system is ready
  25683. */
  25684. isReady(): boolean;
  25685. /**
  25686. * Adds a new color gradient
  25687. * @param gradient defines the gradient to use (between 0 and 1)
  25688. * @param color defines the color to affect to the specified gradient
  25689. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25690. * @returns the current particle system
  25691. */
  25692. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25693. /**
  25694. * Remove a specific color gradient
  25695. * @param gradient defines the gradient to remove
  25696. * @returns the current particle system
  25697. */
  25698. removeColorGradient(gradient: number): IParticleSystem;
  25699. /**
  25700. * Adds a new size gradient
  25701. * @param gradient defines the gradient to use (between 0 and 1)
  25702. * @param factor defines the size factor to affect to the specified gradient
  25703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25704. * @returns the current particle system
  25705. */
  25706. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25707. /**
  25708. * Remove a specific size gradient
  25709. * @param gradient defines the gradient to remove
  25710. * @returns the current particle system
  25711. */
  25712. removeSizeGradient(gradient: number): IParticleSystem;
  25713. /**
  25714. * Gets the current list of color gradients.
  25715. * You must use addColorGradient and removeColorGradient to udpate this list
  25716. * @returns the list of color gradients
  25717. */
  25718. getColorGradients(): Nullable<Array<ColorGradient>>;
  25719. /**
  25720. * Gets the current list of size gradients.
  25721. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25722. * @returns the list of size gradients
  25723. */
  25724. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25725. /**
  25726. * Gets the current list of angular speed gradients.
  25727. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25728. * @returns the list of angular speed gradients
  25729. */
  25730. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25731. /**
  25732. * Adds a new angular speed gradient
  25733. * @param gradient defines the gradient to use (between 0 and 1)
  25734. * @param factor defines the angular speed to affect to the specified gradient
  25735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25736. * @returns the current particle system
  25737. */
  25738. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25739. /**
  25740. * Remove a specific angular speed gradient
  25741. * @param gradient defines the gradient to remove
  25742. * @returns the current particle system
  25743. */
  25744. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25745. /**
  25746. * Gets the current list of velocity gradients.
  25747. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25748. * @returns the list of velocity gradients
  25749. */
  25750. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25751. /**
  25752. * Adds a new velocity gradient
  25753. * @param gradient defines the gradient to use (between 0 and 1)
  25754. * @param factor defines the velocity to affect to the specified gradient
  25755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25756. * @returns the current particle system
  25757. */
  25758. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25759. /**
  25760. * Remove a specific velocity gradient
  25761. * @param gradient defines the gradient to remove
  25762. * @returns the current particle system
  25763. */
  25764. removeVelocityGradient(gradient: number): IParticleSystem;
  25765. /**
  25766. * Gets the current list of limit velocity gradients.
  25767. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25768. * @returns the list of limit velocity gradients
  25769. */
  25770. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25771. /**
  25772. * Adds a new limit velocity gradient
  25773. * @param gradient defines the gradient to use (between 0 and 1)
  25774. * @param factor defines the limit velocity to affect to the specified gradient
  25775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25776. * @returns the current particle system
  25777. */
  25778. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25779. /**
  25780. * Remove a specific limit velocity gradient
  25781. * @param gradient defines the gradient to remove
  25782. * @returns the current particle system
  25783. */
  25784. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25785. /**
  25786. * Adds a new drag gradient
  25787. * @param gradient defines the gradient to use (between 0 and 1)
  25788. * @param factor defines the drag to affect to the specified gradient
  25789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25790. * @returns the current particle system
  25791. */
  25792. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25793. /**
  25794. * Remove a specific drag gradient
  25795. * @param gradient defines the gradient to remove
  25796. * @returns the current particle system
  25797. */
  25798. removeDragGradient(gradient: number): IParticleSystem;
  25799. /**
  25800. * Gets the current list of drag gradients.
  25801. * You must use addDragGradient and removeDragGradient to udpate this list
  25802. * @returns the list of drag gradients
  25803. */
  25804. getDragGradients(): Nullable<Array<FactorGradient>>;
  25805. /**
  25806. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  25807. * @param gradient defines the gradient to use (between 0 and 1)
  25808. * @param factor defines the emit rate to affect to the specified gradient
  25809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25810. * @returns the current particle system
  25811. */
  25812. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25813. /**
  25814. * Remove a specific emit rate gradient
  25815. * @param gradient defines the gradient to remove
  25816. * @returns the current particle system
  25817. */
  25818. removeEmitRateGradient(gradient: number): IParticleSystem;
  25819. /**
  25820. * Gets the current list of emit rate gradients.
  25821. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25822. * @returns the list of emit rate gradients
  25823. */
  25824. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25825. /**
  25826. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  25827. * @param gradient defines the gradient to use (between 0 and 1)
  25828. * @param factor defines the start size to affect to the specified gradient
  25829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25830. * @returns the current particle system
  25831. */
  25832. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25833. /**
  25834. * Remove a specific start size gradient
  25835. * @param gradient defines the gradient to remove
  25836. * @returns the current particle system
  25837. */
  25838. removeStartSizeGradient(gradient: number): IParticleSystem;
  25839. /**
  25840. * Gets the current list of start size gradients.
  25841. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  25842. * @returns the list of start size gradients
  25843. */
  25844. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  25845. /**
  25846. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25849. * @returns the emitter
  25850. */
  25851. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25852. /**
  25853. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25854. * @param radius The radius of the hemisphere to emit from
  25855. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25856. * @returns the emitter
  25857. */
  25858. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  25859. /**
  25860. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25861. * @param radius The radius of the sphere to emit from
  25862. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25863. * @returns the emitter
  25864. */
  25865. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  25866. /**
  25867. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25868. * @param radius The radius of the sphere to emit from
  25869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25871. * @returns the emitter
  25872. */
  25873. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25874. /**
  25875. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25876. * @param radius The radius of the emission cylinder
  25877. * @param height The height of the emission cylinder
  25878. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25879. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25880. * @returns the emitter
  25881. */
  25882. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  25883. /**
  25884. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  25885. * @param radius The radius of the cylinder to emit from
  25886. * @param height The height of the emission cylinder
  25887. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  25888. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  25889. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  25890. * @returns the emitter
  25891. */
  25892. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25893. /**
  25894. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25895. * @param radius The radius of the cone to emit from
  25896. * @param angle The base angle of the cone
  25897. * @returns the emitter
  25898. */
  25899. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  25900. /**
  25901. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25904. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25905. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25906. * @returns the emitter
  25907. */
  25908. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25909. /**
  25910. * Get hosting scene
  25911. * @returns the scene
  25912. */
  25913. getScene(): Scene;
  25914. }
  25915. }
  25916. declare module BABYLON {
  25917. /**
  25918. * A particle represents one of the element emitted by a particle system.
  25919. * This is mainly define by its coordinates, direction, velocity and age.
  25920. */
  25921. class Particle {
  25922. /**
  25923. * The particle system the particle belongs to.
  25924. */
  25925. particleSystem: ParticleSystem;
  25926. /**
  25927. * The world position of the particle in the scene.
  25928. */
  25929. position: Vector3;
  25930. /**
  25931. * The world direction of the particle in the scene.
  25932. */
  25933. direction: Vector3;
  25934. /**
  25935. * The color of the particle.
  25936. */
  25937. color: Color4;
  25938. /**
  25939. * The color change of the particle per step.
  25940. */
  25941. colorStep: Color4;
  25942. /**
  25943. * Defines how long will the life of the particle be.
  25944. */
  25945. lifeTime: number;
  25946. /**
  25947. * The current age of the particle.
  25948. */
  25949. age: number;
  25950. /**
  25951. * The current size of the particle.
  25952. */
  25953. size: number;
  25954. /**
  25955. * The current scale of the particle.
  25956. */
  25957. scale: Vector2;
  25958. /**
  25959. * The current angle of the particle.
  25960. */
  25961. angle: number;
  25962. /**
  25963. * Defines how fast is the angle changing.
  25964. */
  25965. angularSpeed: number;
  25966. /**
  25967. * Defines the cell index used by the particle to be rendered from a sprite.
  25968. */
  25969. cellIndex: number;
  25970. /** @hidden */
  25971. /** @hidden */
  25972. /** @hidden */
  25973. /** @hidden */
  25974. /** @hidden */
  25975. /** @hidden */
  25976. /** @hidden */
  25977. /** @hidden */
  25978. /** @hidden */
  25979. /** @hidden */
  25980. /** @hidden */
  25981. /** @hidden */
  25982. /** @hidden */
  25983. /** @hidden */
  25984. /** @hidden */
  25985. /** @hidden */
  25986. /** @hidden */
  25987. /** @hidden */
  25988. /** @hidden */
  25989. /** @hidden */
  25990. /** @hidden */
  25991. /**
  25992. * Creates a new instance Particle
  25993. * @param particleSystem the particle system the particle belongs to
  25994. */
  25995. constructor(
  25996. /**
  25997. * The particle system the particle belongs to.
  25998. */
  25999. particleSystem: ParticleSystem);
  26000. private updateCellInfoFromSystem;
  26001. /**
  26002. * Defines how the sprite cell index is updated for the particle
  26003. */
  26004. updateCellIndex(): void;
  26005. /** @hidden */
  26006. /**
  26007. * Copy the properties of particle to another one.
  26008. * @param other the particle to copy the information to.
  26009. */
  26010. copyTo(other: Particle): void;
  26011. }
  26012. }
  26013. declare module BABYLON {
  26014. /**
  26015. * This class is made for on one-liner static method to help creating particle system set.
  26016. */
  26017. class ParticleHelper {
  26018. /**
  26019. * Gets or sets base Assets URL
  26020. */
  26021. static BaseAssetsUrl: string;
  26022. /**
  26023. * Create a default particle system that you can tweak
  26024. * @param emitter defines the emitter to use
  26025. * @param capacity defines the system capacity (default is 500 particles)
  26026. * @param scene defines the hosting scene
  26027. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  26028. * @returns the new Particle system
  26029. */
  26030. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  26031. /**
  26032. * This is the main static method (one-liner) of this helper to create different particle systems
  26033. * @param type This string represents the type to the particle system to create
  26034. * @param scene The scene where the particle system should live
  26035. * @param gpu If the system will use gpu
  26036. * @returns the ParticleSystemSet created
  26037. */
  26038. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  26039. /**
  26040. * Static function used to export a particle system to a ParticleSystemSet variable.
  26041. * Please note that the emitter shape is not exported
  26042. * @param system defines the particle systems to export
  26043. */
  26044. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  26045. }
  26046. }
  26047. declare module BABYLON {
  26048. /**
  26049. * This represents a particle system in Babylon.
  26050. * 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.
  26051. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  26052. * @example https://doc.babylonjs.com/babylon101/particles
  26053. */
  26054. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  26055. /**
  26056. * This function can be defined to provide custom update for active particles.
  26057. * This function will be called instead of regular update (age, position, color, etc.).
  26058. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  26059. */
  26060. updateFunction: (particles: Particle[]) => void;
  26061. private _emitterWorldMatrix;
  26062. /**
  26063. * This function can be defined to specify initial direction for every new particle.
  26064. * It by default use the emitterType defined function
  26065. */
  26066. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  26067. /**
  26068. * This function can be defined to specify initial position for every new particle.
  26069. * It by default use the emitterType defined function
  26070. */
  26071. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  26072. /**
  26073. * An event triggered when the system is disposed
  26074. */
  26075. onDisposeObservable: Observable<ParticleSystem>;
  26076. private _onDisposeObserver;
  26077. /**
  26078. * Sets a callback that will be triggered when the system is disposed
  26079. */
  26080. onDispose: () => void;
  26081. private _particles;
  26082. private _epsilon;
  26083. private _capacity;
  26084. private _stockParticles;
  26085. private _newPartsExcess;
  26086. private _vertexData;
  26087. private _vertexBuffer;
  26088. private _vertexBuffers;
  26089. private _spriteBuffer;
  26090. private _indexBuffer;
  26091. private _effect;
  26092. private _customEffect;
  26093. private _cachedDefines;
  26094. private _scaledColorStep;
  26095. private _colorDiff;
  26096. private _scaledDirection;
  26097. private _scaledGravity;
  26098. private _currentRenderId;
  26099. private _alive;
  26100. private _useInstancing;
  26101. private _started;
  26102. private _stopped;
  26103. private _actualFrame;
  26104. private _scaledUpdateSpeed;
  26105. private _vertexBufferSize;
  26106. /** @hidden */
  26107. /** @hidden */
  26108. /** @hidden */
  26109. /** @hidden */
  26110. /** @hidden */
  26111. /** @hidden */
  26112. /**
  26113. * 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.
  26114. */
  26115. subEmitters: ParticleSystem[];
  26116. /**
  26117. * The current active Sub-systems, this property is used by the root particle system only.
  26118. */
  26119. activeSubSystems: Array<ParticleSystem>;
  26120. private _rootParticleSystem;
  26121. /**
  26122. * Gets the current list of active particles
  26123. */
  26124. readonly particles: Particle[];
  26125. /**
  26126. * Returns the string "ParticleSystem"
  26127. * @returns a string containing the class name
  26128. */
  26129. getClassName(): string;
  26130. /**
  26131. * Instantiates a particle system.
  26132. * 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.
  26133. * @param name The name of the particle system
  26134. * @param capacity The max number of particles alive at the same time
  26135. * @param scene The scene the particle system belongs to
  26136. * @param customEffect a custom effect used to change the way particles are rendered by default
  26137. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  26138. * @param epsilon Offset used to render the particles
  26139. */
  26140. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  26141. private _addFactorGradient;
  26142. private _removeFactorGradient;
  26143. /**
  26144. * Adds a new life time gradient
  26145. * @param gradient defines the gradient to use (between 0 and 1)
  26146. * @param factor defines the life time factor to affect to the specified gradient
  26147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26148. * @returns the current particle system
  26149. */
  26150. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26151. /**
  26152. * Remove a specific life time gradient
  26153. * @param gradient defines the gradient to remove
  26154. * @returns the current particle system
  26155. */
  26156. removeLifeTimeGradient(gradient: number): IParticleSystem;
  26157. /**
  26158. * Adds a new size gradient
  26159. * @param gradient defines the gradient to use (between 0 and 1)
  26160. * @param factor defines the size factor to affect to the specified gradient
  26161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26162. * @returns the current particle system
  26163. */
  26164. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26165. /**
  26166. * Remove a specific size gradient
  26167. * @param gradient defines the gradient to remove
  26168. * @returns the current particle system
  26169. */
  26170. removeSizeGradient(gradient: number): IParticleSystem;
  26171. /**
  26172. * Adds a new angular speed gradient
  26173. * @param gradient defines the gradient to use (between 0 and 1)
  26174. * @param factor defines the angular speed to affect to the specified gradient
  26175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26176. * @returns the current particle system
  26177. */
  26178. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26179. /**
  26180. * Remove a specific angular speed gradient
  26181. * @param gradient defines the gradient to remove
  26182. * @returns the current particle system
  26183. */
  26184. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  26185. /**
  26186. * Adds a new velocity gradient
  26187. * @param gradient defines the gradient to use (between 0 and 1)
  26188. * @param factor defines the velocity to affect to the specified gradient
  26189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26190. * @returns the current particle system
  26191. */
  26192. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26193. /**
  26194. * Remove a specific velocity gradient
  26195. * @param gradient defines the gradient to remove
  26196. * @returns the current particle system
  26197. */
  26198. removeVelocityGradient(gradient: number): IParticleSystem;
  26199. /**
  26200. * Adds a new limit velocity gradient
  26201. * @param gradient defines the gradient to use (between 0 and 1)
  26202. * @param factor defines the limit velocity value to affect to the specified gradient
  26203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26204. * @returns the current particle system
  26205. */
  26206. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26207. /**
  26208. * Remove a specific limit velocity gradient
  26209. * @param gradient defines the gradient to remove
  26210. * @returns the current particle system
  26211. */
  26212. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  26213. /**
  26214. * Adds a new drag gradient
  26215. * @param gradient defines the gradient to use (between 0 and 1)
  26216. * @param factor defines the drag value to affect to the specified gradient
  26217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26218. * @returns the current particle system
  26219. */
  26220. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26221. /**
  26222. * Remove a specific drag gradient
  26223. * @param gradient defines the gradient to remove
  26224. * @returns the current particle system
  26225. */
  26226. removeDragGradient(gradient: number): IParticleSystem;
  26227. /**
  26228. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  26229. * @param gradient defines the gradient to use (between 0 and 1)
  26230. * @param factor defines the emit rate value to affect to the specified gradient
  26231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26232. * @returns the current particle system
  26233. */
  26234. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26235. /**
  26236. * Remove a specific emit rate gradient
  26237. * @param gradient defines the gradient to remove
  26238. * @returns the current particle system
  26239. */
  26240. removeEmitRateGradient(gradient: number): IParticleSystem;
  26241. /**
  26242. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  26243. * @param gradient defines the gradient to use (between 0 and 1)
  26244. * @param factor defines the start size value to affect to the specified gradient
  26245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26246. * @returns the current particle system
  26247. */
  26248. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26249. /**
  26250. * Remove a specific start size gradient
  26251. * @param gradient defines the gradient to remove
  26252. * @returns the current particle system
  26253. */
  26254. removeStartSizeGradient(gradient: number): IParticleSystem;
  26255. /**
  26256. * Adds a new color gradient
  26257. * @param gradient defines the gradient to use (between 0 and 1)
  26258. * @param color defines the color to affect to the specified gradient
  26259. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  26260. */
  26261. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  26262. /**
  26263. * Remove a specific color gradient
  26264. * @param gradient defines the gradient to remove
  26265. */
  26266. removeColorGradient(gradient: number): IParticleSystem;
  26267. private _fetchR;
  26268. protected _reset(): void;
  26269. private _resetEffect;
  26270. private _createVertexBuffers;
  26271. private _createIndexBuffer;
  26272. /**
  26273. * Gets the maximum number of particles active at the same time.
  26274. * @returns The max number of active particles.
  26275. */
  26276. getCapacity(): number;
  26277. /**
  26278. * Gets whether there are still active particles in the system.
  26279. * @returns True if it is alive, otherwise false.
  26280. */
  26281. isAlive(): boolean;
  26282. /**
  26283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  26284. * @returns True if it has been started, otherwise false.
  26285. */
  26286. isStarted(): boolean;
  26287. /**
  26288. * Starts the particle system and begins to emit
  26289. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  26290. */
  26291. start(delay?: number): void;
  26292. /**
  26293. * Stops the particle system.
  26294. * @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.
  26295. */
  26296. stop(stopSubEmitters?: boolean): void;
  26297. /**
  26298. * Remove all active particles
  26299. */
  26300. reset(): void;
  26301. /**
  26302. * @hidden (for internal use only)
  26303. */
  26304. /**
  26305. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  26306. * Its lifetime will start back at 0.
  26307. */
  26308. recycleParticle: (particle: Particle) => void;
  26309. private _stopSubEmitters;
  26310. private _createParticle;
  26311. private _removeFromRoot;
  26312. private _emitFromParticle;
  26313. private _update;
  26314. /** @hidden */
  26315. private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  26316. private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  26317. private _getEffect;
  26318. /**
  26319. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  26320. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  26321. */
  26322. animate(preWarmOnly?: boolean): void;
  26323. private _appendParticleVertices;
  26324. /**
  26325. * Rebuilds the particle system.
  26326. */
  26327. rebuild(): void;
  26328. /**
  26329. * Is this system ready to be used/rendered
  26330. * @return true if the system is ready
  26331. */
  26332. isReady(): boolean;
  26333. /**
  26334. * Renders the particle system in its current state.
  26335. * @returns the current number of particles
  26336. */
  26337. render(): number;
  26338. /**
  26339. * Disposes the particle system and free the associated resources
  26340. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26341. */
  26342. dispose(disposeTexture?: boolean): void;
  26343. /**
  26344. * Clones the particle system.
  26345. * @param name The name of the cloned object
  26346. * @param newEmitter The new emitter to use
  26347. * @returns the cloned particle system
  26348. */
  26349. clone(name: string, newEmitter: any): ParticleSystem;
  26350. /**
  26351. * Serializes the particle system to a JSON object.
  26352. * @returns the JSON object
  26353. */
  26354. serialize(): any;
  26355. /** @hidden */
  26356. private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26357. /** @hidden */
  26358. private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26359. /**
  26360. * Parses a JSON object to create a particle system.
  26361. * @param parsedParticleSystem The JSON object to parse
  26362. * @param scene The scene to create the particle system in
  26363. * @param rootUrl The root url to use to load external dependencies like texture
  26364. * @returns the Parsed particle system
  26365. */
  26366. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26367. }
  26368. }
  26369. declare module BABYLON {
  26370. interface Engine {
  26371. /**
  26372. * Create an effect to use with particle systems.
  26373. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26374. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26375. * @param uniformsNames defines a list of attribute names
  26376. * @param samplers defines an array of string used to represent textures
  26377. * @param defines defines the string containing the defines to use to compile the shaders
  26378. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26379. * @param onCompiled defines a function to call when the effect creation is successful
  26380. * @param onError defines a function to call when the effect creation has failed
  26381. * @returns the new Effect
  26382. */
  26383. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. /**
  26388. * Represents a set of particle systems working together to create a specific effect
  26389. */
  26390. class ParticleSystemSet implements IDisposable {
  26391. private _emitterCreationOptions;
  26392. private _emitterNode;
  26393. /**
  26394. * Gets the particle system list
  26395. */
  26396. systems: IParticleSystem[];
  26397. /**
  26398. * Gets the emitter node used with this set
  26399. */
  26400. readonly emitterNode: Nullable<TransformNode>;
  26401. /**
  26402. * Creates a new emitter mesh as a sphere
  26403. * @param options defines the options used to create the sphere
  26404. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26405. * @param scene defines the hosting scene
  26406. */
  26407. setEmitterAsSphere(options: {
  26408. diameter: number;
  26409. segments: number;
  26410. color: Color3;
  26411. }, renderingGroupId: number, scene: Scene): void;
  26412. /**
  26413. * Starts all particle systems of the set
  26414. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26415. */
  26416. start(emitter?: AbstractMesh): void;
  26417. /**
  26418. * Release all associated resources
  26419. */
  26420. dispose(): void;
  26421. /**
  26422. * Serialize the set into a JSON compatible object
  26423. * @returns a JSON compatible representation of the set
  26424. */
  26425. serialize(): any;
  26426. /**
  26427. * Parse a new ParticleSystemSet from a serialized source
  26428. * @param data defines a JSON compatible representation of the set
  26429. * @param scene defines the hosting scene
  26430. * @param gpu defines if we want GPU particles or CPU particles
  26431. * @returns a new ParticleSystemSet
  26432. */
  26433. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26434. }
  26435. }
  26436. declare module BABYLON {
  26437. /**
  26438. * Represents one particle of a solid particle system.
  26439. */
  26440. class SolidParticle {
  26441. /**
  26442. * particle global index
  26443. */
  26444. idx: number;
  26445. /**
  26446. * The color of the particle
  26447. */
  26448. color: Nullable<Color4>;
  26449. /**
  26450. * The world space position of the particle.
  26451. */
  26452. position: Vector3;
  26453. /**
  26454. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26455. */
  26456. rotation: Vector3;
  26457. /**
  26458. * The world space rotation quaternion of the particle.
  26459. */
  26460. rotationQuaternion: Nullable<Quaternion>;
  26461. /**
  26462. * The scaling of the particle.
  26463. */
  26464. scaling: Vector3;
  26465. /**
  26466. * The uvs of the particle.
  26467. */
  26468. uvs: Vector4;
  26469. /**
  26470. * The current speed of the particle.
  26471. */
  26472. velocity: Vector3;
  26473. /**
  26474. * The pivot point in the particle local space.
  26475. */
  26476. pivot: Vector3;
  26477. /**
  26478. * Must the particle be translated from its pivot point in its local space ?
  26479. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26480. * Default : false
  26481. */
  26482. translateFromPivot: boolean;
  26483. /**
  26484. * Is the particle active or not ?
  26485. */
  26486. alive: boolean;
  26487. /**
  26488. * Is the particle visible or not ?
  26489. */
  26490. isVisible: boolean;
  26491. /**
  26492. * Index of this particle in the global "positions" array (Internal use)
  26493. * @hidden
  26494. */
  26495. /**
  26496. * @hidden Index of this particle in the global "indices" array (Internal use)
  26497. */
  26498. /**
  26499. * @hidden ModelShape of this particle (Internal use)
  26500. */
  26501. /**
  26502. * ModelShape id of this particle
  26503. */
  26504. shapeId: number;
  26505. /**
  26506. * Index of the particle in its shape id (Internal use)
  26507. */
  26508. idxInShape: number;
  26509. /**
  26510. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26511. */
  26512. /**
  26513. * @hidden Particle BoundingInfo object (Internal use)
  26514. */
  26515. /**
  26516. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26517. */
  26518. /**
  26519. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26520. */
  26521. /**
  26522. * @hidden Last computed particle rotation matrix
  26523. */
  26524. /**
  26525. * Parent particle Id, if any.
  26526. * Default null.
  26527. */
  26528. parentId: Nullable<number>;
  26529. /**
  26530. * @hidden Internal global position in the SPS.
  26531. */
  26532. /**
  26533. * Creates a Solid Particle object.
  26534. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26535. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26536. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26537. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26538. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26539. * @param shapeId (integer) is the model shape identifier in the SPS.
  26540. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26541. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26542. */
  26543. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26544. /**
  26545. * Legacy support, changed scale to scaling
  26546. */
  26547. /**
  26548. * Legacy support, changed scale to scaling
  26549. */
  26550. scale: Vector3;
  26551. /**
  26552. * Legacy support, changed quaternion to rotationQuaternion
  26553. */
  26554. /**
  26555. * Legacy support, changed quaternion to rotationQuaternion
  26556. */
  26557. quaternion: Nullable<Quaternion>;
  26558. /**
  26559. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26560. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26561. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26562. * @returns true if it intersects
  26563. */
  26564. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26565. }
  26566. /**
  26567. * Represents the shape of the model used by one particle of a solid particle system.
  26568. * SPS internal tool, don't use it manually.
  26569. */
  26570. class ModelShape {
  26571. /**
  26572. * The shape id
  26573. * @hidden
  26574. */
  26575. shapeID: number;
  26576. /**
  26577. * flat array of model positions (internal use)
  26578. * @hidden
  26579. */
  26580. /**
  26581. * flat array of model UVs (internal use)
  26582. * @hidden
  26583. */
  26584. /**
  26585. * length of the shape in the model indices array (internal use)
  26586. * @hidden
  26587. */
  26588. /**
  26589. * Custom position function (internal use)
  26590. * @hidden
  26591. */
  26592. /**
  26593. * Custom vertex function (internal use)
  26594. * @hidden
  26595. */
  26596. /**
  26597. * 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.
  26598. * SPS internal tool, don't use it manually.
  26599. * @hidden
  26600. */
  26601. 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>);
  26602. }
  26603. /**
  26604. * Represents a Depth Sorted Particle in the solid particle system.
  26605. */
  26606. class DepthSortedParticle {
  26607. /**
  26608. * Index of the particle in the "indices" array
  26609. */
  26610. ind: number;
  26611. /**
  26612. * Length of the particle shape in the "indices" array
  26613. */
  26614. indicesLength: number;
  26615. /**
  26616. * Squared distance from the particle to the camera
  26617. */
  26618. sqDistance: number;
  26619. }
  26620. }
  26621. declare module BABYLON {
  26622. /**
  26623. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26624. *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.
  26625. * The SPS is also a particle system. It provides some methods to manage the particles.
  26626. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26627. *
  26628. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26629. */
  26630. class SolidParticleSystem implements IDisposable {
  26631. /**
  26632. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26633. * Example : var p = SPS.particles[i];
  26634. */
  26635. particles: SolidParticle[];
  26636. /**
  26637. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26638. */
  26639. nbParticles: number;
  26640. /**
  26641. * If the particles must ever face the camera (default false). Useful for planar particles.
  26642. */
  26643. billboard: boolean;
  26644. /**
  26645. * Recompute normals when adding a shape
  26646. */
  26647. recomputeNormals: boolean;
  26648. /**
  26649. * This a counter ofr your own usage. It's not set by any SPS functions.
  26650. */
  26651. counter: number;
  26652. /**
  26653. * The SPS name. This name is also given to the underlying mesh.
  26654. */
  26655. name: string;
  26656. /**
  26657. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26658. */
  26659. mesh: Mesh;
  26660. /**
  26661. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26662. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26663. */
  26664. vars: any;
  26665. /**
  26666. * This array is populated when the SPS is set as 'pickable'.
  26667. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26668. * Each element of this array is an object `{idx: int, faceId: int}`.
  26669. * `idx` is the picked particle index in the `SPS.particles` array
  26670. * `faceId` is the picked face index counted within this particle.
  26671. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26672. */
  26673. pickedParticles: {
  26674. idx: number;
  26675. faceId: number;
  26676. }[];
  26677. /**
  26678. * This array is populated when `enableDepthSort` is set to true.
  26679. * Each element of this array is an instance of the class DepthSortedParticle.
  26680. */
  26681. depthSortedParticles: DepthSortedParticle[];
  26682. /**
  26683. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26684. * @hidden
  26685. */
  26686. /**
  26687. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26688. * @hidden
  26689. */
  26690. private _scene;
  26691. private _positions;
  26692. private _indices;
  26693. private _normals;
  26694. private _colors;
  26695. private _uvs;
  26696. private _indices32;
  26697. private _positions32;
  26698. private _normals32;
  26699. private _fixedNormal32;
  26700. private _colors32;
  26701. private _uvs32;
  26702. private _index;
  26703. private _updatable;
  26704. private _pickable;
  26705. private _isVisibilityBoxLocked;
  26706. private _alwaysVisible;
  26707. private _depthSort;
  26708. private _shapeCounter;
  26709. private _copy;
  26710. private _shape;
  26711. private _shapeUV;
  26712. private _color;
  26713. private _computeParticleColor;
  26714. private _computeParticleTexture;
  26715. private _computeParticleRotation;
  26716. private _computeParticleVertex;
  26717. private _computeBoundingBox;
  26718. private _depthSortParticles;
  26719. private _cam_axisZ;
  26720. private _cam_axisY;
  26721. private _cam_axisX;
  26722. private _axisZ;
  26723. private _camera;
  26724. private _particle;
  26725. private _camDir;
  26726. private _camInvertedPosition;
  26727. private _rotMatrix;
  26728. private _invertMatrix;
  26729. private _rotated;
  26730. private _quaternion;
  26731. private _vertex;
  26732. private _normal;
  26733. private _yaw;
  26734. private _pitch;
  26735. private _roll;
  26736. private _halfroll;
  26737. private _halfpitch;
  26738. private _halfyaw;
  26739. private _sinRoll;
  26740. private _cosRoll;
  26741. private _sinPitch;
  26742. private _cosPitch;
  26743. private _sinYaw;
  26744. private _cosYaw;
  26745. private _mustUnrotateFixedNormals;
  26746. private _minimum;
  26747. private _maximum;
  26748. private _minBbox;
  26749. private _maxBbox;
  26750. private _particlesIntersect;
  26751. private _depthSortFunction;
  26752. private _needs32Bits;
  26753. private _pivotBackTranslation;
  26754. private _scaledPivot;
  26755. private _particleHasParent;
  26756. private _parent;
  26757. /**
  26758. * Creates a SPS (Solid Particle System) object.
  26759. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26760. * @param scene (Scene) is the scene in which the SPS is added.
  26761. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26762. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26763. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26764. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26765. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26766. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26767. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26768. */
  26769. constructor(name: string, scene: Scene, options?: {
  26770. updatable?: boolean;
  26771. isPickable?: boolean;
  26772. enableDepthSort?: boolean;
  26773. particleIntersection?: boolean;
  26774. boundingSphereOnly?: boolean;
  26775. bSphereRadiusFactor?: number;
  26776. });
  26777. /**
  26778. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26779. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26780. * @returns the created mesh
  26781. */
  26782. buildMesh(): Mesh;
  26783. /**
  26784. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26785. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26786. * Thus the particles generated from `digest()` have their property `position` set yet.
  26787. * @param mesh ( Mesh ) is the mesh to be digested
  26788. * @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
  26789. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26790. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26791. * @returns the current SPS
  26792. */
  26793. digest(mesh: Mesh, options?: {
  26794. facetNb?: number;
  26795. number?: number;
  26796. delta?: number;
  26797. }): SolidParticleSystem;
  26798. private _unrotateFixedNormals;
  26799. private _resetCopy;
  26800. private _meshBuilder;
  26801. private _posToShape;
  26802. private _uvsToShapeUV;
  26803. private _addParticle;
  26804. /**
  26805. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26806. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26807. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26808. * @param nb (positive integer) the number of particles to be created from this model
  26809. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26810. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26811. * @returns the number of shapes in the system
  26812. */
  26813. addShape(mesh: Mesh, nb: number, options?: {
  26814. positionFunction?: any;
  26815. vertexFunction?: any;
  26816. }): number;
  26817. private _rebuildParticle;
  26818. /**
  26819. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26820. * @returns the SPS.
  26821. */
  26822. rebuildMesh(): SolidParticleSystem;
  26823. /**
  26824. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26825. * This method calls `updateParticle()` for each particle of the SPS.
  26826. * For an animated SPS, it is usually called within the render loop.
  26827. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26828. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26829. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26830. * @returns the SPS.
  26831. */
  26832. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26833. private _quaternionRotationYPR;
  26834. private _quaternionToRotationMatrix;
  26835. /**
  26836. * Disposes the SPS.
  26837. */
  26838. dispose(): void;
  26839. /**
  26840. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26841. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26842. * @returns the SPS.
  26843. */
  26844. refreshVisibleSize(): SolidParticleSystem;
  26845. /**
  26846. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26847. * @param size the size (float) of the visibility box
  26848. * note : this doesn't lock the SPS mesh bounding box.
  26849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26850. */
  26851. setVisibilityBox(size: number): void;
  26852. /**
  26853. * Gets whether the SPS as always visible or not
  26854. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26855. */
  26856. /**
  26857. * Sets the SPS as always visible or not
  26858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26859. */
  26860. isAlwaysVisible: boolean;
  26861. /**
  26862. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26864. */
  26865. /**
  26866. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26868. */
  26869. isVisibilityBoxLocked: boolean;
  26870. /**
  26871. * Tells to `setParticles()` to compute the particle rotations or not.
  26872. * Default value : true. The SPS is faster when it's set to false.
  26873. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26874. */
  26875. /**
  26876. * Gets if `setParticles()` computes the particle rotations or not.
  26877. * Default value : true. The SPS is faster when it's set to false.
  26878. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26879. */
  26880. computeParticleRotation: boolean;
  26881. /**
  26882. * Tells to `setParticles()` to compute the particle colors or not.
  26883. * Default value : true. The SPS is faster when it's set to false.
  26884. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26885. */
  26886. /**
  26887. * Gets if `setParticles()` computes the particle colors or not.
  26888. * Default value : true. The SPS is faster when it's set to false.
  26889. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26890. */
  26891. computeParticleColor: boolean;
  26892. /**
  26893. * Gets if `setParticles()` computes the particle textures or not.
  26894. * Default value : true. The SPS is faster when it's set to false.
  26895. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26896. */
  26897. computeParticleTexture: boolean;
  26898. /**
  26899. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26900. * Default value : false. The SPS is faster when it's set to false.
  26901. * Note : the particle custom vertex positions aren't stored values.
  26902. */
  26903. /**
  26904. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26905. * Default value : false. The SPS is faster when it's set to false.
  26906. * Note : the particle custom vertex positions aren't stored values.
  26907. */
  26908. computeParticleVertex: boolean;
  26909. /**
  26910. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26911. */
  26912. /**
  26913. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26914. */
  26915. computeBoundingBox: boolean;
  26916. /**
  26917. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26918. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26919. * Default : `true`
  26920. */
  26921. /**
  26922. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26923. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26924. * Default : `true`
  26925. */
  26926. depthSortParticles: boolean;
  26927. /**
  26928. * This function does nothing. It may be overwritten to set all the particle first values.
  26929. * The SPS doesn't call this function, you may have to call it by your own.
  26930. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26931. */
  26932. initParticles(): void;
  26933. /**
  26934. * This function does nothing. It may be overwritten to recycle a particle.
  26935. * The SPS doesn't call this function, you may have to call it by your own.
  26936. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26937. * @param particle The particle to recycle
  26938. * @returns the recycled particle
  26939. */
  26940. recycleParticle(particle: SolidParticle): SolidParticle;
  26941. /**
  26942. * Updates a particle : this function should be overwritten by the user.
  26943. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26945. * @example : just set a particle position or velocity and recycle conditions
  26946. * @param particle The particle to update
  26947. * @returns the updated particle
  26948. */
  26949. updateParticle(particle: SolidParticle): SolidParticle;
  26950. /**
  26951. * Updates a vertex of a particle : it can be overwritten by the user.
  26952. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26953. * @param particle the current particle
  26954. * @param vertex the current index of the current particle
  26955. * @param pt the index of the current vertex in the particle shape
  26956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26957. * @example : just set a vertex particle position
  26958. * @returns the updated vertex
  26959. */
  26960. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26961. /**
  26962. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26963. * This does nothing and may be overwritten by the user.
  26964. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26965. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26966. * @param update the boolean update value actually passed to setParticles()
  26967. */
  26968. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26969. /**
  26970. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26971. * This will be passed three parameters.
  26972. * This does nothing and may be overwritten by the user.
  26973. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26974. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26975. * @param update the boolean update value actually passed to setParticles()
  26976. */
  26977. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26978. }
  26979. }
  26980. declare module BABYLON {
  26981. interface Scene {
  26982. /**
  26983. * The list of reflection probes added to the scene
  26984. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  26985. */
  26986. reflectionProbes: Array<ReflectionProbe>;
  26987. }
  26988. /**
  26989. * Class used to generate realtime reflection / refraction cube textures
  26990. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  26991. */
  26992. class ReflectionProbe {
  26993. /** defines the name of the probe */
  26994. name: string;
  26995. private _scene;
  26996. private _renderTargetTexture;
  26997. private _projectionMatrix;
  26998. private _viewMatrix;
  26999. private _target;
  27000. private _add;
  27001. private _attachedMesh;
  27002. private _invertYAxis;
  27003. /** Gets or sets probe position (center of the cube map) */
  27004. position: Vector3;
  27005. /**
  27006. * Creates a new reflection probe
  27007. * @param name defines the name of the probe
  27008. * @param size defines the texture resolution (for each face)
  27009. * @param scene defines the hosting scene
  27010. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27011. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27012. */
  27013. constructor(
  27014. /** defines the name of the probe */
  27015. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27016. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27017. samples: number;
  27018. /** Gets or sets the refresh rate to use (on every frame by default) */
  27019. refreshRate: number;
  27020. /**
  27021. * Gets the hosting scene
  27022. * @returns a Scene
  27023. */
  27024. getScene(): Scene;
  27025. /** Gets the internal CubeTexture used to render to */
  27026. readonly cubeTexture: RenderTargetTexture;
  27027. /** Gets the list of meshes to render */
  27028. readonly renderList: Nullable<AbstractMesh[]>;
  27029. /**
  27030. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  27031. * @param mesh defines the mesh to attach to
  27032. */
  27033. attachToMesh(mesh: AbstractMesh): void;
  27034. /**
  27035. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  27036. * @param renderingGroupId The rendering group id corresponding to its index
  27037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27038. */
  27039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27040. /**
  27041. * Clean all associated resources
  27042. */
  27043. dispose(): void;
  27044. }
  27045. }
  27046. declare module BABYLON {
  27047. /**
  27048. * Postprocess used to generate anaglyphic rendering
  27049. */
  27050. class AnaglyphPostProcess extends PostProcess {
  27051. private _passedProcess;
  27052. /**
  27053. * Creates a new AnaglyphPostProcess
  27054. * @param name defines postprocess name
  27055. * @param options defines creation options or target ratio scale
  27056. * @param rigCameras defines cameras using this postprocess
  27057. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27058. * @param engine defines hosting engine
  27059. * @param reusable defines if the postprocess will be reused multiple times per frame
  27060. */
  27061. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. class BlackAndWhitePostProcess extends PostProcess {
  27066. degree: number;
  27067. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27068. }
  27069. }
  27070. declare module BABYLON {
  27071. /**
  27072. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27073. */
  27074. class BloomEffect extends PostProcessRenderEffect {
  27075. private bloomScale;
  27076. /**
  27077. * @hidden Internal
  27078. */
  27079. /**
  27080. * @hidden Internal
  27081. */
  27082. private _blurX;
  27083. private _blurY;
  27084. private _merge;
  27085. /**
  27086. * The luminance threshold to find bright areas of the image to bloom.
  27087. */
  27088. threshold: number;
  27089. /**
  27090. * The strength of the bloom.
  27091. */
  27092. weight: number;
  27093. /**
  27094. * Specifies the size of the bloom blur kernel, relative to the final output size
  27095. */
  27096. kernel: number;
  27097. /**
  27098. * Creates a new instance of @see BloomEffect
  27099. * @param scene The scene the effect belongs to.
  27100. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27101. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27102. * @param bloomWeight The the strength of bloom.
  27103. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27104. * @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)
  27105. */
  27106. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27107. /**
  27108. * Disposes each of the internal effects for a given camera.
  27109. * @param camera The camera to dispose the effect on.
  27110. */
  27111. disposeEffects(camera: Camera): void;
  27112. /**
  27113. * @hidden Internal
  27114. */
  27115. /**
  27116. * Internal
  27117. * @returns if all the contained post processes are ready.
  27118. * @hidden
  27119. */
  27120. }
  27121. }
  27122. declare module BABYLON {
  27123. /**
  27124. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27125. */
  27126. class BloomMergePostProcess extends PostProcess {
  27127. /** Weight of the bloom to be added to the original input. */
  27128. weight: number;
  27129. /**
  27130. * Creates a new instance of @see BloomMergePostProcess
  27131. * @param name The name of the effect.
  27132. * @param originalFromInput Post process which's input will be used for the merge.
  27133. * @param blurred Blurred highlights post process which's output will be used.
  27134. * @param weight Weight of the bloom to be added to the original input.
  27135. * @param options The required width/height ratio to downsize to before computing the render pass.
  27136. * @param camera The camera to apply the render pass to.
  27137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27138. * @param engine The engine which the post process will be applied. (default: current engine)
  27139. * @param reusable If the post process can be reused on the same frame. (default: false)
  27140. * @param textureType Type of textures used when performing the post process. (default: 0)
  27141. * @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)
  27142. */
  27143. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27144. /** Weight of the bloom to be added to the original input. */
  27145. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27146. }
  27147. }
  27148. declare module BABYLON {
  27149. /**
  27150. * The Blur Post Process which blurs an image based on a kernel and direction.
  27151. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27152. */
  27153. class BlurPostProcess extends PostProcess {
  27154. /** The direction in which to blur the image. */
  27155. direction: Vector2;
  27156. private blockCompilation;
  27157. protected _kernel: number;
  27158. protected _idealKernel: number;
  27159. protected _packedFloat: boolean;
  27160. private _staticDefines;
  27161. /**
  27162. * Sets the length in pixels of the blur sample region
  27163. */
  27164. /**
  27165. * Gets the length in pixels of the blur sample region
  27166. */
  27167. kernel: number;
  27168. /**
  27169. * Sets wether or not the blur needs to unpack/repack floats
  27170. */
  27171. /**
  27172. * Gets wether or not the blur is unpacking/repacking floats
  27173. */
  27174. packedFloat: boolean;
  27175. /**
  27176. * Creates a new instance BlurPostProcess
  27177. * @param name The name of the effect.
  27178. * @param direction The direction in which to blur the image.
  27179. * @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.
  27180. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27181. * @param camera The camera to apply the render pass to.
  27182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27183. * @param engine The engine which the post process will be applied. (default: current engine)
  27184. * @param reusable If the post process can be reused on the same frame. (default: false)
  27185. * @param textureType Type of textures used when performing the post process. (default: 0)
  27186. * @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)
  27187. */
  27188. constructor(name: string,
  27189. /** The direction in which to blur the image. */
  27190. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27191. /**
  27192. * Updates the effect with the current post process compile time values and recompiles the shader.
  27193. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27194. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27195. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27196. * @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
  27197. * @param onCompiled Called when the shader has been compiled.
  27198. * @param onError Called if there is an error when compiling a shader.
  27199. */
  27200. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27201. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27202. /**
  27203. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27204. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27205. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27206. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27207. * The gaps between physical kernels are compensated for in the weighting of the samples
  27208. * @param idealKernel Ideal blur kernel.
  27209. * @return Nearest best kernel.
  27210. */
  27211. protected _nearestBestKernel(idealKernel: number): number;
  27212. /**
  27213. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27214. * @param x The point on the Gaussian distribution to sample.
  27215. * @return the value of the Gaussian function at x.
  27216. */
  27217. protected _gaussianWeight(x: number): number;
  27218. /**
  27219. * Generates a string that can be used as a floating point number in GLSL.
  27220. * @param x Value to print.
  27221. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27222. * @return GLSL float string.
  27223. */
  27224. protected _glslFloat(x: number, decimalFigures?: number): string;
  27225. }
  27226. }
  27227. declare module BABYLON {
  27228. /**
  27229. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27230. */
  27231. class ChromaticAberrationPostProcess extends PostProcess {
  27232. /**
  27233. * The amount of seperation of rgb channels (default: 30)
  27234. */
  27235. aberrationAmount: number;
  27236. /**
  27237. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27238. */
  27239. radialIntensity: number;
  27240. /**
  27241. * 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))
  27242. */
  27243. direction: Vector2;
  27244. /**
  27245. * 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))
  27246. */
  27247. centerPosition: Vector2;
  27248. /**
  27249. * Creates a new instance ChromaticAberrationPostProcess
  27250. * @param name The name of the effect.
  27251. * @param screenWidth The width of the screen to apply the effect on.
  27252. * @param screenHeight The height of the screen to apply the effect on.
  27253. * @param options The required width/height ratio to downsize to before computing the render pass.
  27254. * @param camera The camera to apply the render pass to.
  27255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27256. * @param engine The engine which the post process will be applied. (default: current engine)
  27257. * @param reusable If the post process can be reused on the same frame. (default: false)
  27258. * @param textureType Type of textures used when performing the post process. (default: 0)
  27259. * @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)
  27260. */
  27261. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27262. }
  27263. }
  27264. declare module BABYLON {
  27265. /**
  27266. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27267. */
  27268. class CircleOfConfusionPostProcess extends PostProcess {
  27269. /**
  27270. * 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.
  27271. */
  27272. lensSize: number;
  27273. /**
  27274. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27275. */
  27276. fStop: number;
  27277. /**
  27278. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27279. */
  27280. focusDistance: number;
  27281. /**
  27282. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27283. */
  27284. focalLength: number;
  27285. private _depthTexture;
  27286. /**
  27287. * Creates a new instance CircleOfConfusionPostProcess
  27288. * @param name The name of the effect.
  27289. * @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.
  27290. * @param options The required width/height ratio to downsize to before computing the render pass.
  27291. * @param camera The camera to apply the render pass to.
  27292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27293. * @param engine The engine which the post process will be applied. (default: current engine)
  27294. * @param reusable If the post process can be reused on the same frame. (default: false)
  27295. * @param textureType Type of textures used when performing the post process. (default: 0)
  27296. * @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)
  27297. */
  27298. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27299. /**
  27300. * 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.
  27301. */
  27302. depthTexture: RenderTargetTexture;
  27303. }
  27304. }
  27305. declare module BABYLON {
  27306. class ColorCorrectionPostProcess extends PostProcess {
  27307. private _colorTableTexture;
  27308. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27309. }
  27310. }
  27311. declare module BABYLON {
  27312. /**
  27313. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27314. * input texture to perform effects such as edge detection or sharpening
  27315. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27316. */
  27317. class ConvolutionPostProcess extends PostProcess {
  27318. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27319. kernel: number[];
  27320. /**
  27321. * Creates a new instance ConvolutionPostProcess
  27322. * @param name The name of the effect.
  27323. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27324. * @param options The required width/height ratio to downsize to before computing the render pass.
  27325. * @param camera The camera to apply the render pass to.
  27326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27327. * @param engine The engine which the post process will be applied. (default: current engine)
  27328. * @param reusable If the post process can be reused on the same frame. (default: false)
  27329. * @param textureType Type of textures used when performing the post process. (default: 0)
  27330. */
  27331. constructor(name: string,
  27332. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27333. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27334. /**
  27335. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27336. */
  27337. static EdgeDetect0Kernel: number[];
  27338. /**
  27339. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27340. */
  27341. static EdgeDetect1Kernel: number[];
  27342. /**
  27343. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27344. */
  27345. static EdgeDetect2Kernel: number[];
  27346. /**
  27347. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27348. */
  27349. static SharpenKernel: number[];
  27350. /**
  27351. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27352. */
  27353. static EmbossKernel: number[];
  27354. /**
  27355. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27356. */
  27357. static GaussianKernel: number[];
  27358. }
  27359. }
  27360. declare module BABYLON {
  27361. /**
  27362. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27363. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27364. * based on samples that have a large difference in distance than the center pixel.
  27365. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27366. */
  27367. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27368. direction: Vector2;
  27369. /**
  27370. * Creates a new instance CircleOfConfusionPostProcess
  27371. * @param name The name of the effect.
  27372. * @param scene The scene the effect belongs to.
  27373. * @param direction The direction the blur should be applied.
  27374. * @param kernel The size of the kernel used to blur.
  27375. * @param options The required width/height ratio to downsize to before computing the render pass.
  27376. * @param camera The camera to apply the render pass to.
  27377. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27378. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27380. * @param engine The engine which the post process will be applied. (default: current engine)
  27381. * @param reusable If the post process can be reused on the same frame. (default: false)
  27382. * @param textureType Type of textures used when performing the post process. (default: 0)
  27383. * @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)
  27384. */
  27385. 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);
  27386. }
  27387. }
  27388. declare module BABYLON {
  27389. /**
  27390. * Specifies the level of max blur that should be applied when using the depth of field effect
  27391. */
  27392. enum DepthOfFieldEffectBlurLevel {
  27393. /**
  27394. * Subtle blur
  27395. */
  27396. Low = 0,
  27397. /**
  27398. * Medium blur
  27399. */
  27400. Medium = 1,
  27401. /**
  27402. * Large blur
  27403. */
  27404. High = 2
  27405. }
  27406. /**
  27407. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27408. */
  27409. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27410. private _circleOfConfusion;
  27411. /**
  27412. * @hidden Internal, blurs from high to low
  27413. */
  27414. private _depthOfFieldBlurY;
  27415. private _dofMerge;
  27416. /**
  27417. * @hidden Internal post processes in depth of field effect
  27418. */
  27419. /**
  27420. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27421. */
  27422. focalLength: number;
  27423. /**
  27424. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27425. */
  27426. fStop: number;
  27427. /**
  27428. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27429. */
  27430. focusDistance: number;
  27431. /**
  27432. * 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.
  27433. */
  27434. lensSize: number;
  27435. /**
  27436. * Creates a new instance DepthOfFieldEffect
  27437. * @param scene The scene the effect belongs to.
  27438. * @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.
  27439. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27440. * @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)
  27441. */
  27442. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27443. /**
  27444. * 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.
  27445. */
  27446. depthTexture: RenderTargetTexture;
  27447. /**
  27448. * Disposes each of the internal effects for a given camera.
  27449. * @param camera The camera to dispose the effect on.
  27450. */
  27451. disposeEffects(camera: Camera): void;
  27452. /**
  27453. * @hidden Internal
  27454. */
  27455. /**
  27456. * Internal
  27457. * @returns if all the contained post processes are ready.
  27458. * @hidden
  27459. */
  27460. }
  27461. }
  27462. declare module BABYLON {
  27463. /**
  27464. * Options to be set when merging outputs from the default pipeline.
  27465. */
  27466. class DepthOfFieldMergePostProcessOptions {
  27467. /**
  27468. * The original image to merge on top of
  27469. */
  27470. originalFromInput: PostProcess;
  27471. /**
  27472. * Parameters to perform the merge of the depth of field effect
  27473. */
  27474. depthOfField?: {
  27475. circleOfConfusion: PostProcess;
  27476. blurSteps: Array<PostProcess>;
  27477. };
  27478. /**
  27479. * Parameters to perform the merge of bloom effect
  27480. */
  27481. bloom?: {
  27482. blurred: PostProcess;
  27483. weight: number;
  27484. };
  27485. }
  27486. /**
  27487. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27488. */
  27489. class DepthOfFieldMergePostProcess extends PostProcess {
  27490. private blurSteps;
  27491. /**
  27492. * Creates a new instance of DepthOfFieldMergePostProcess
  27493. * @param name The name of the effect.
  27494. * @param originalFromInput Post process which's input will be used for the merge.
  27495. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27496. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27497. * @param options The required width/height ratio to downsize to before computing the render pass.
  27498. * @param camera The camera to apply the render pass to.
  27499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27500. * @param engine The engine which the post process will be applied. (default: current engine)
  27501. * @param reusable If the post process can be reused on the same frame. (default: false)
  27502. * @param textureType Type of textures used when performing the post process. (default: 0)
  27503. * @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)
  27504. */
  27505. 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);
  27506. /**
  27507. * Updates the effect with the current post process compile time values and recompiles the shader.
  27508. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27509. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27510. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27511. * @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
  27512. * @param onCompiled Called when the shader has been compiled.
  27513. * @param onError Called if there is an error when compiling a shader.
  27514. */
  27515. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27516. }
  27517. }
  27518. declare module BABYLON {
  27519. class DisplayPassPostProcess extends PostProcess {
  27520. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27521. }
  27522. }
  27523. declare module BABYLON {
  27524. /**
  27525. * 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.
  27526. */
  27527. class ExtractHighlightsPostProcess extends PostProcess {
  27528. /**
  27529. * The luminance threshold, pixels below this value will be set to black.
  27530. */
  27531. threshold: number;
  27532. /** @hidden */
  27533. /**
  27534. * Post process which has the input texture to be used when performing highlight extraction
  27535. * @hidden
  27536. */
  27537. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27538. }
  27539. }
  27540. declare module BABYLON {
  27541. class FilterPostProcess extends PostProcess {
  27542. kernelMatrix: Matrix;
  27543. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27544. }
  27545. }
  27546. declare module BABYLON {
  27547. class FxaaPostProcess extends PostProcess {
  27548. texelWidth: number;
  27549. texelHeight: number;
  27550. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27551. private _getDefines;
  27552. }
  27553. }
  27554. declare module BABYLON {
  27555. /**
  27556. * The GrainPostProcess adds noise to the image at mid luminance levels
  27557. */
  27558. class GrainPostProcess extends PostProcess {
  27559. /**
  27560. * The intensity of the grain added (default: 30)
  27561. */
  27562. intensity: number;
  27563. /**
  27564. * If the grain should be randomized on every frame
  27565. */
  27566. animated: boolean;
  27567. /**
  27568. * Creates a new instance of @see GrainPostProcess
  27569. * @param name The name of the effect.
  27570. * @param options The required width/height ratio to downsize to before computing the render pass.
  27571. * @param camera The camera to apply the render pass to.
  27572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27573. * @param engine The engine which the post process will be applied. (default: current engine)
  27574. * @param reusable If the post process can be reused on the same frame. (default: false)
  27575. * @param textureType Type of textures used when performing the post process. (default: 0)
  27576. * @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)
  27577. */
  27578. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27579. }
  27580. }
  27581. declare module BABYLON {
  27582. class HighlightsPostProcess extends PostProcess {
  27583. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27584. }
  27585. }
  27586. declare module BABYLON {
  27587. class ImageProcessingPostProcess extends PostProcess {
  27588. /**
  27589. * Default configuration related to image processing available in the PBR Material.
  27590. */
  27591. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27592. /**
  27593. * Gets the image processing configuration used either in this material.
  27594. */
  27595. /**
  27596. * Sets the Default image processing configuration used either in the this material.
  27597. *
  27598. * If sets to null, the scene one is in use.
  27599. */
  27600. imageProcessingConfiguration: ImageProcessingConfiguration;
  27601. /**
  27602. * Keep track of the image processing observer to allow dispose and replace.
  27603. */
  27604. private _imageProcessingObserver;
  27605. /**
  27606. * Attaches a new image processing configuration to the PBR Material.
  27607. * @param configuration
  27608. */
  27609. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27610. /**
  27611. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27612. */
  27613. /**
  27614. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27615. */
  27616. colorCurves: Nullable<ColorCurves>;
  27617. /**
  27618. * Gets wether the color curves effect is enabled.
  27619. */
  27620. /**
  27621. * Sets wether the color curves effect is enabled.
  27622. */
  27623. colorCurvesEnabled: boolean;
  27624. /**
  27625. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27626. */
  27627. /**
  27628. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27629. */
  27630. colorGradingTexture: Nullable<BaseTexture>;
  27631. /**
  27632. * Gets wether the color grading effect is enabled.
  27633. */
  27634. /**
  27635. * Gets wether the color grading effect is enabled.
  27636. */
  27637. colorGradingEnabled: boolean;
  27638. /**
  27639. * Gets exposure used in the effect.
  27640. */
  27641. /**
  27642. * Sets exposure used in the effect.
  27643. */
  27644. exposure: number;
  27645. /**
  27646. * Gets wether tonemapping is enabled or not.
  27647. */
  27648. /**
  27649. * Sets wether tonemapping is enabled or not
  27650. */
  27651. toneMappingEnabled: boolean;
  27652. /**
  27653. * Gets contrast used in the effect.
  27654. */
  27655. /**
  27656. * Sets contrast used in the effect.
  27657. */
  27658. contrast: number;
  27659. /**
  27660. * Gets Vignette stretch size.
  27661. */
  27662. /**
  27663. * Sets Vignette stretch size.
  27664. */
  27665. vignetteStretch: number;
  27666. /**
  27667. * Gets Vignette centre X Offset.
  27668. */
  27669. /**
  27670. * Sets Vignette centre X Offset.
  27671. */
  27672. vignetteCentreX: number;
  27673. /**
  27674. * Gets Vignette centre Y Offset.
  27675. */
  27676. /**
  27677. * Sets Vignette centre Y Offset.
  27678. */
  27679. vignetteCentreY: number;
  27680. /**
  27681. * Gets Vignette weight or intensity of the vignette effect.
  27682. */
  27683. /**
  27684. * Sets Vignette weight or intensity of the vignette effect.
  27685. */
  27686. vignetteWeight: number;
  27687. /**
  27688. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27689. * if vignetteEnabled is set to true.
  27690. */
  27691. /**
  27692. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27693. * if vignetteEnabled is set to true.
  27694. */
  27695. vignetteColor: Color4;
  27696. /**
  27697. * Gets Camera field of view used by the Vignette effect.
  27698. */
  27699. /**
  27700. * Sets Camera field of view used by the Vignette effect.
  27701. */
  27702. vignetteCameraFov: number;
  27703. /**
  27704. * Gets the vignette blend mode allowing different kind of effect.
  27705. */
  27706. /**
  27707. * Sets the vignette blend mode allowing different kind of effect.
  27708. */
  27709. vignetteBlendMode: number;
  27710. /**
  27711. * Gets wether the vignette effect is enabled.
  27712. */
  27713. /**
  27714. * Sets wether the vignette effect is enabled.
  27715. */
  27716. vignetteEnabled: boolean;
  27717. private _fromLinearSpace;
  27718. /**
  27719. * Gets wether the input of the processing is in Gamma or Linear Space.
  27720. */
  27721. /**
  27722. * Sets wether the input of the processing is in Gamma or Linear Space.
  27723. */
  27724. fromLinearSpace: boolean;
  27725. /**
  27726. * Defines cache preventing GC.
  27727. */
  27728. private _defines;
  27729. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27730. getClassName(): string;
  27731. protected _updateParameters(): void;
  27732. dispose(camera?: Camera): void;
  27733. }
  27734. }
  27735. declare module BABYLON {
  27736. class PassPostProcess extends PostProcess {
  27737. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27738. }
  27739. }
  27740. declare module BABYLON {
  27741. type PostProcessOptions = {
  27742. width: number;
  27743. height: number;
  27744. };
  27745. /**
  27746. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27748. */
  27749. class PostProcess {
  27750. /** Name of the PostProcess. */
  27751. name: string;
  27752. /**
  27753. * Width of the texture to apply the post process on
  27754. */
  27755. width: number;
  27756. /**
  27757. * Height of the texture to apply the post process on
  27758. */
  27759. height: number;
  27760. /**
  27761. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27762. * @hidden
  27763. */
  27764. /**
  27765. * Sampling mode used by the shader
  27766. * See https://doc.babylonjs.com/classes/3.1/texture
  27767. */
  27768. renderTargetSamplingMode: number;
  27769. /**
  27770. * Clear color to use when screen clearing
  27771. */
  27772. clearColor: Color4;
  27773. /**
  27774. * If the buffer needs to be cleared before applying the post process. (default: true)
  27775. * Should be set to false if shader will overwrite all previous pixels.
  27776. */
  27777. autoClear: boolean;
  27778. /**
  27779. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27780. */
  27781. alphaMode: number;
  27782. /**
  27783. * Sets the setAlphaBlendConstants of the babylon engine
  27784. */
  27785. alphaConstants: Color4;
  27786. /**
  27787. * Animations to be used for the post processing
  27788. */
  27789. animations: Animation[];
  27790. /**
  27791. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27792. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27793. */
  27794. enablePixelPerfectMode: boolean;
  27795. /**
  27796. * Force the postprocess to be applied without taking in account viewport
  27797. */
  27798. forceFullscreenViewport: boolean;
  27799. /**
  27800. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27801. *
  27802. * | Value | Type | Description |
  27803. * | ----- | ----------------------------------- | ----------- |
  27804. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27805. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27806. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27807. *
  27808. */
  27809. scaleMode: number;
  27810. /**
  27811. * Force textures to be a power of two (default: false)
  27812. */
  27813. alwaysForcePOT: boolean;
  27814. private _samples;
  27815. /**
  27816. * Number of sample textures (default: 1)
  27817. */
  27818. samples: number;
  27819. /**
  27820. * Modify the scale of the post process to be the same as the viewport (default: false)
  27821. */
  27822. adaptScaleToCurrentViewport: boolean;
  27823. private _camera;
  27824. private _scene;
  27825. private _engine;
  27826. private _options;
  27827. private _reusable;
  27828. private _textureType;
  27829. /**
  27830. * Smart array of input and output textures for the post process.
  27831. * @hidden
  27832. */
  27833. /**
  27834. * The index in _textures that corresponds to the output texture.
  27835. * @hidden
  27836. */
  27837. private _effect;
  27838. private _samplers;
  27839. private _fragmentUrl;
  27840. private _vertexUrl;
  27841. private _parameters;
  27842. private _scaleRatio;
  27843. protected _indexParameters: any;
  27844. private _shareOutputWithPostProcess;
  27845. private _texelSize;
  27846. private _forcedOutputTexture;
  27847. /**
  27848. * An event triggered when the postprocess is activated.
  27849. */
  27850. onActivateObservable: Observable<Camera>;
  27851. private _onActivateObserver;
  27852. /**
  27853. * A function that is added to the onActivateObservable
  27854. */
  27855. onActivate: Nullable<(camera: Camera) => void>;
  27856. /**
  27857. * An event triggered when the postprocess changes its size.
  27858. */
  27859. onSizeChangedObservable: Observable<PostProcess>;
  27860. private _onSizeChangedObserver;
  27861. /**
  27862. * A function that is added to the onSizeChangedObservable
  27863. */
  27864. onSizeChanged: (postProcess: PostProcess) => void;
  27865. /**
  27866. * An event triggered when the postprocess applies its effect.
  27867. */
  27868. onApplyObservable: Observable<Effect>;
  27869. private _onApplyObserver;
  27870. /**
  27871. * A function that is added to the onApplyObservable
  27872. */
  27873. onApply: (effect: Effect) => void;
  27874. /**
  27875. * An event triggered before rendering the postprocess
  27876. */
  27877. onBeforeRenderObservable: Observable<Effect>;
  27878. private _onBeforeRenderObserver;
  27879. /**
  27880. * A function that is added to the onBeforeRenderObservable
  27881. */
  27882. onBeforeRender: (effect: Effect) => void;
  27883. /**
  27884. * An event triggered after rendering the postprocess
  27885. */
  27886. onAfterRenderObservable: Observable<Effect>;
  27887. private _onAfterRenderObserver;
  27888. /**
  27889. * A function that is added to the onAfterRenderObservable
  27890. */
  27891. onAfterRender: (efect: Effect) => void;
  27892. /**
  27893. * 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
  27894. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27895. */
  27896. inputTexture: InternalTexture;
  27897. /**
  27898. * Gets the camera which post process is applied to.
  27899. * @returns The camera the post process is applied to.
  27900. */
  27901. getCamera(): Camera;
  27902. /**
  27903. * Gets the texel size of the postprocess.
  27904. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27905. */
  27906. readonly texelSize: Vector2;
  27907. /**
  27908. * Creates a new instance PostProcess
  27909. * @param name The name of the PostProcess.
  27910. * @param fragmentUrl The url of the fragment shader to be used.
  27911. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27912. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27913. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27914. * @param camera The camera to apply the render pass to.
  27915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27916. * @param engine The engine which the post process will be applied. (default: current engine)
  27917. * @param reusable If the post process can be reused on the same frame. (default: false)
  27918. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27919. * @param textureType Type of textures used when performing the post process. (default: 0)
  27920. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27921. * @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
  27922. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27923. */
  27924. constructor(
  27925. /** Name of the PostProcess. */
  27926. 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);
  27927. /**
  27928. * Gets the engine which this post process belongs to.
  27929. * @returns The engine the post process was enabled with.
  27930. */
  27931. getEngine(): Engine;
  27932. /**
  27933. * The effect that is created when initializing the post process.
  27934. * @returns The created effect corrisponding the the postprocess.
  27935. */
  27936. getEffect(): Effect;
  27937. /**
  27938. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27939. * @param postProcess The post process to share the output with.
  27940. * @returns This post process.
  27941. */
  27942. shareOutputWith(postProcess: PostProcess): PostProcess;
  27943. /**
  27944. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27945. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27946. */
  27947. useOwnOutput(): void;
  27948. /**
  27949. * Updates the effect with the current post process compile time values and recompiles the shader.
  27950. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27951. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27952. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27953. * @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
  27954. * @param onCompiled Called when the shader has been compiled.
  27955. * @param onError Called if there is an error when compiling a shader.
  27956. */
  27957. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27958. /**
  27959. * The post process is reusable if it can be used multiple times within one frame.
  27960. * @returns If the post process is reusable
  27961. */
  27962. isReusable(): boolean;
  27963. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27964. markTextureDirty(): void;
  27965. /**
  27966. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27967. * 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.
  27968. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27969. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27970. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27971. * @returns The target texture that was bound to be written to.
  27972. */
  27973. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27974. /**
  27975. * If the post process is supported.
  27976. */
  27977. readonly isSupported: boolean;
  27978. /**
  27979. * The aspect ratio of the output texture.
  27980. */
  27981. readonly aspectRatio: number;
  27982. /**
  27983. * Get a value indicating if the post-process is ready to be used
  27984. * @returns true if the post-process is ready (shader is compiled)
  27985. */
  27986. isReady(): boolean;
  27987. /**
  27988. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27989. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27990. */
  27991. apply(): Nullable<Effect>;
  27992. private _disposeTextures;
  27993. /**
  27994. * Disposes the post process.
  27995. * @param camera The camera to dispose the post process on.
  27996. */
  27997. dispose(camera?: Camera): void;
  27998. }
  27999. }
  28000. declare module BABYLON {
  28001. /**
  28002. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28003. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28004. */
  28005. class PostProcessManager {
  28006. private _scene;
  28007. private _indexBuffer;
  28008. private _vertexBuffers;
  28009. /**
  28010. * Creates a new instance PostProcess
  28011. * @param scene The scene that the post process is associated with.
  28012. */
  28013. constructor(scene: Scene);
  28014. private _prepareBuffers;
  28015. private _buildIndexBuffer;
  28016. /**
  28017. * Rebuilds the vertex buffers of the manager.
  28018. * @hidden
  28019. */
  28020. /**
  28021. * Prepares a frame to be run through a post process.
  28022. * @param sourceTexture The input texture to the post procesess. (default: null)
  28023. * @param postProcesses An array of post processes to be run. (default: null)
  28024. * @returns True if the post processes were able to be run.
  28025. * @hidden
  28026. */
  28027. /**
  28028. * Manually render a set of post processes to a texture.
  28029. * @param postProcesses An array of post processes to be run.
  28030. * @param targetTexture The target texture to render to.
  28031. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28032. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28033. * @param lodLevel defines which lod of the texture to render to
  28034. */
  28035. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28036. /**
  28037. * Finalize the result of the output of the postprocesses.
  28038. * @param doNotPresent If true the result will not be displayed to the screen.
  28039. * @param targetTexture The target texture to render to.
  28040. * @param faceIndex The index of the face to bind the target texture to.
  28041. * @param postProcesses The array of post processes to render.
  28042. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28043. * @hidden
  28044. */
  28045. /**
  28046. * Disposes of the post process manager.
  28047. */
  28048. dispose(): void;
  28049. }
  28050. }
  28051. declare module BABYLON {
  28052. class RefractionPostProcess extends PostProcess {
  28053. color: Color3;
  28054. depth: number;
  28055. colorLevel: number;
  28056. private _refTexture;
  28057. private _ownRefractionTexture;
  28058. /**
  28059. * Gets or sets the refraction texture
  28060. * Please note that you are responsible for disposing the texture if you set it manually
  28061. */
  28062. refractionTexture: Texture;
  28063. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28064. dispose(camera: Camera): void;
  28065. }
  28066. }
  28067. declare module BABYLON {
  28068. /**
  28069. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28070. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28071. */
  28072. class SharpenPostProcess extends PostProcess {
  28073. /**
  28074. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28075. */
  28076. colorAmount: number;
  28077. /**
  28078. * How much sharpness should be applied (default: 0.3)
  28079. */
  28080. edgeAmount: number;
  28081. /**
  28082. * Creates a new instance ConvolutionPostProcess
  28083. * @param name The name of the effect.
  28084. * @param options The required width/height ratio to downsize to before computing the render pass.
  28085. * @param camera The camera to apply the render pass to.
  28086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28087. * @param engine The engine which the post process will be applied. (default: current engine)
  28088. * @param reusable If the post process can be reused on the same frame. (default: false)
  28089. * @param textureType Type of textures used when performing the post process. (default: 0)
  28090. * @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)
  28091. */
  28092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28093. }
  28094. }
  28095. declare module BABYLON {
  28096. class StereoscopicInterlacePostProcess extends PostProcess {
  28097. private _stepSize;
  28098. private _passedProcess;
  28099. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28100. }
  28101. }
  28102. declare module BABYLON {
  28103. /** Defines operator used for tonemapping */
  28104. enum TonemappingOperator {
  28105. /** Hable */
  28106. Hable = 0,
  28107. /** Reinhard */
  28108. Reinhard = 1,
  28109. /** HejiDawson */
  28110. HejiDawson = 2,
  28111. /** Photographic */
  28112. Photographic = 3
  28113. }
  28114. /**
  28115. * Defines a post process to apply tone mapping
  28116. */
  28117. class TonemapPostProcess extends PostProcess {
  28118. private _operator;
  28119. /** Defines the required exposure adjustement */
  28120. exposureAdjustment: number;
  28121. /**
  28122. * Creates a new TonemapPostProcess
  28123. * @param name defines the name of the postprocess
  28124. * @param _operator defines the operator to use
  28125. * @param exposureAdjustment defines the required exposure adjustement
  28126. * @param camera defines the camera to use (can be null)
  28127. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28128. * @param engine defines the hosting engine (can be ignore if camera is set)
  28129. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28130. */
  28131. constructor(name: string, _operator: TonemappingOperator,
  28132. /** Defines the required exposure adjustement */
  28133. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28134. }
  28135. }
  28136. declare module BABYLON {
  28137. class VolumetricLightScatteringPostProcess extends PostProcess {
  28138. private _volumetricLightScatteringPass;
  28139. private _volumetricLightScatteringRTT;
  28140. private _viewPort;
  28141. private _screenCoordinates;
  28142. private _cachedDefines;
  28143. /**
  28144. * If not undefined, the mesh position is computed from the attached node position
  28145. */
  28146. attachedNode: {
  28147. position: Vector3;
  28148. };
  28149. /**
  28150. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28151. */
  28152. customMeshPosition: Vector3;
  28153. /**
  28154. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28155. */
  28156. useCustomMeshPosition: boolean;
  28157. /**
  28158. * If the post-process should inverse the light scattering direction
  28159. */
  28160. invert: boolean;
  28161. /**
  28162. * The internal mesh used by the post-process
  28163. */
  28164. mesh: Mesh;
  28165. useDiffuseColor: boolean;
  28166. /**
  28167. * Array containing the excluded meshes not rendered in the internal pass
  28168. */
  28169. excludedMeshes: AbstractMesh[];
  28170. /**
  28171. * Controls the overall intensity of the post-process
  28172. */
  28173. exposure: number;
  28174. /**
  28175. * Dissipates each sample's contribution in range [0, 1]
  28176. */
  28177. decay: number;
  28178. /**
  28179. * Controls the overall intensity of each sample
  28180. */
  28181. weight: number;
  28182. /**
  28183. * Controls the density of each sample
  28184. */
  28185. density: number;
  28186. /**
  28187. * @constructor
  28188. * @param {string} name - The post-process name
  28189. * @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)
  28190. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28191. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28192. * @param {number} samples - The post-process quality, default 100
  28193. * @param {number} samplingMode - The post-process filtering mode
  28194. * @param {BABYLON.Engine} engine - The babylon engine
  28195. * @param {boolean} reusable - If the post-process is reusable
  28196. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28197. */
  28198. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28199. getClassName(): string;
  28200. private _isReady;
  28201. /**
  28202. * Sets the new light position for light scattering effect
  28203. * @param {BABYLON.Vector3} The new custom light position
  28204. */
  28205. setCustomMeshPosition(position: Vector3): void;
  28206. /**
  28207. * Returns the light position for light scattering effect
  28208. * @return {BABYLON.Vector3} The custom light position
  28209. */
  28210. getCustomMeshPosition(): Vector3;
  28211. /**
  28212. * Disposes the internal assets and detaches the post-process from the camera
  28213. */
  28214. dispose(camera: Camera): void;
  28215. /**
  28216. * Returns the render target texture used by the post-process
  28217. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28218. */
  28219. getPass(): RenderTargetTexture;
  28220. private _meshExcluded;
  28221. private _createPass;
  28222. private _updateMeshScreenCoordinates;
  28223. /**
  28224. * Creates a default mesh for the Volumeric Light Scattering post-process
  28225. * @param {string} The mesh name
  28226. * @param {BABYLON.Scene} The scene where to create the mesh
  28227. * @return {BABYLON.Mesh} the default mesh
  28228. */
  28229. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28230. }
  28231. }
  28232. declare module BABYLON {
  28233. class VRDistortionCorrectionPostProcess extends PostProcess {
  28234. private _isRightEye;
  28235. private _distortionFactors;
  28236. private _postProcessScaleFactor;
  28237. private _lensCenterOffset;
  28238. private _scaleIn;
  28239. private _scaleFactor;
  28240. private _lensCenter;
  28241. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28242. }
  28243. }
  28244. declare module BABYLON {
  28245. interface Scene {
  28246. /** @hidden (Backing field) */
  28247. /** @hidden (Backing field) */
  28248. /**
  28249. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28250. */
  28251. forceShowBoundingBoxes: boolean;
  28252. /**
  28253. * Gets the bounding box renderer associated with the scene
  28254. * @returns a BoundingBoxRenderer
  28255. */
  28256. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28257. }
  28258. interface AbstractMesh {
  28259. /** @hidden (Backing field) */
  28260. /**
  28261. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28262. */
  28263. showBoundingBox: boolean;
  28264. }
  28265. class BoundingBoxRenderer implements ISceneComponent {
  28266. /**
  28267. * The component name helpfull to identify the component in the list of scene components.
  28268. */
  28269. readonly name: string;
  28270. /**
  28271. * The scene the component belongs to.
  28272. */
  28273. scene: Scene;
  28274. frontColor: Color3;
  28275. backColor: Color3;
  28276. showBackLines: boolean;
  28277. renderList: SmartArray<BoundingBox>;
  28278. private _colorShader;
  28279. private _vertexBuffers;
  28280. private _indexBuffer;
  28281. constructor(scene: Scene);
  28282. /**
  28283. * Registers the component in a given scene
  28284. */
  28285. register(): void;
  28286. private _evaluateSubMesh;
  28287. private _activeMesh;
  28288. private _prepareRessources;
  28289. private _createIndexBuffer;
  28290. /**
  28291. * Rebuilds the elements related to this component in case of
  28292. * context lost for instance.
  28293. */
  28294. rebuild(): void;
  28295. reset(): void;
  28296. render(): void;
  28297. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28298. dispose(): void;
  28299. }
  28300. }
  28301. declare module BABYLON {
  28302. /**
  28303. * This represents a depth renderer in Babylon.
  28304. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28305. */
  28306. class DepthRenderer {
  28307. private _scene;
  28308. private _depthMap;
  28309. private _effect;
  28310. private _cachedDefines;
  28311. private _camera;
  28312. /**
  28313. * Instantiates a depth renderer
  28314. * @param scene The scene the renderer belongs to
  28315. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28316. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28317. */
  28318. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28319. /**
  28320. * Creates the depth rendering effect and checks if the effect is ready.
  28321. * @param subMesh The submesh to be used to render the depth map of
  28322. * @param useInstances If multiple world instances should be used
  28323. * @returns if the depth renderer is ready to render the depth map
  28324. */
  28325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28326. /**
  28327. * Gets the texture which the depth map will be written to.
  28328. * @returns The depth map texture
  28329. */
  28330. getDepthMap(): RenderTargetTexture;
  28331. /**
  28332. * Disposes of the depth renderer.
  28333. */
  28334. dispose(): void;
  28335. }
  28336. }
  28337. declare module BABYLON {
  28338. interface Scene {
  28339. /** @hidden (Backing field) */
  28340. ;
  28341. /**
  28342. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  28343. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  28344. * @returns the created depth renderer
  28345. */
  28346. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  28347. /**
  28348. * Disables a depth renderer for a given camera
  28349. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  28350. */
  28351. disableDepthRenderer(camera?: Nullable<Camera>): void;
  28352. }
  28353. /**
  28354. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  28355. * in several rendering techniques.
  28356. */
  28357. class DepthRendererSceneComponent implements ISceneComponent {
  28358. /**
  28359. * The component name helpfull to identify the component in the list of scene components.
  28360. */
  28361. readonly name: string;
  28362. /**
  28363. * The scene the component belongs to.
  28364. */
  28365. scene: Scene;
  28366. /**
  28367. * Creates a new instance of the component for the given scene
  28368. * @param scene Defines the scene to register the component in
  28369. */
  28370. constructor(scene: Scene);
  28371. /**
  28372. * Registers the component in a given scene
  28373. */
  28374. register(): void;
  28375. /**
  28376. * Rebuilds the elements related to this component in case of
  28377. * context lost for instance.
  28378. */
  28379. rebuild(): void;
  28380. /**
  28381. * Disposes the component and the associated ressources
  28382. */
  28383. dispose(): void;
  28384. private _gatherRenderTargets;
  28385. }
  28386. }
  28387. declare module BABYLON {
  28388. interface AbstractMesh {
  28389. /**
  28390. * Disables the mesh edge rendering mode
  28391. * @returns the currentAbstractMesh
  28392. */
  28393. disableEdgesRendering(): AbstractMesh;
  28394. /**
  28395. * Enables the edge rendering mode on the mesh.
  28396. * This mode makes the mesh edges visible
  28397. * @param epsilon defines the maximal distance between two angles to detect a face
  28398. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28399. * @returns the currentAbstractMesh
  28400. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28401. */
  28402. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28403. /**
  28404. * Gets the edgesRenderer associated with the mesh
  28405. */
  28406. edgesRenderer: Nullable<EdgesRenderer>;
  28407. }
  28408. interface LinesMesh {
  28409. /**
  28410. * Enables the edge rendering mode on the mesh.
  28411. * This mode makes the mesh edges visible
  28412. * @param epsilon defines the maximal distance between two angles to detect a face
  28413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28414. * @returns the currentAbstractMesh
  28415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28416. */
  28417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28418. }
  28419. /**
  28420. * Defines the minimum contract an Edges renderer should follow.
  28421. */
  28422. interface IEdgesRenderer extends IDisposable {
  28423. /**
  28424. * Gets or sets a boolean indicating if the edgesRenderer is active
  28425. */
  28426. isEnabled: boolean;
  28427. /**
  28428. * Renders the edges of the attached mesh,
  28429. */
  28430. render(): void;
  28431. /**
  28432. * Checks wether or not the edges renderer is ready to render.
  28433. * @return true if ready, otherwise false.
  28434. */
  28435. isReady(): boolean;
  28436. }
  28437. /**
  28438. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28439. */
  28440. class EdgesRenderer implements IEdgesRenderer {
  28441. edgesWidthScalerForOrthographic: number;
  28442. edgesWidthScalerForPerspective: number;
  28443. protected _source: AbstractMesh;
  28444. protected _linesPositions: number[];
  28445. protected _linesNormals: number[];
  28446. protected _linesIndices: number[];
  28447. protected _epsilon: number;
  28448. protected _indicesCount: number;
  28449. protected _lineShader: ShaderMaterial;
  28450. protected _ib: WebGLBuffer;
  28451. protected _buffers: {
  28452. [key: string]: Nullable<VertexBuffer>;
  28453. };
  28454. protected _checkVerticesInsteadOfIndices: boolean;
  28455. private _meshRebuildObserver;
  28456. private _meshDisposeObserver;
  28457. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28458. isEnabled: boolean;
  28459. /**
  28460. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28461. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28462. * @param source Mesh used to create edges
  28463. * @param epsilon sum of angles in adjacency to check for edge
  28464. * @param checkVerticesInsteadOfIndices
  28465. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28466. */
  28467. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  28468. protected _prepareRessources(): void;
  28469. /** @hidden */
  28470. /**
  28471. * Releases the required resources for the edges renderer
  28472. */
  28473. dispose(): void;
  28474. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28475. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28476. /**
  28477. * Checks if the pair of p0 and p1 is en edge
  28478. * @param faceIndex
  28479. * @param edge
  28480. * @param faceNormals
  28481. * @param p0
  28482. * @param p1
  28483. * @private
  28484. */
  28485. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28486. /**
  28487. * Generates lines edges from adjacencjes
  28488. * @private
  28489. */
  28490. /**
  28491. * Checks wether or not the edges renderer is ready to render.
  28492. * @return true if ready, otherwise false.
  28493. */
  28494. isReady(): boolean;
  28495. /**
  28496. * Renders the edges of the attached mesh,
  28497. */
  28498. render(): void;
  28499. }
  28500. }
  28501. declare module BABYLON {
  28502. /**
  28503. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28504. */
  28505. class GeometryBufferRenderer {
  28506. private _scene;
  28507. private _multiRenderTarget;
  28508. private _ratio;
  28509. private _enablePosition;
  28510. protected _effect: Effect;
  28511. protected _cachedDefines: string;
  28512. /**
  28513. * Set the render list (meshes to be rendered) used in the G buffer.
  28514. */
  28515. renderList: Mesh[];
  28516. /**
  28517. * Gets wether or not G buffer are supported by the running hardware.
  28518. * This requires draw buffer supports
  28519. */
  28520. readonly isSupported: boolean;
  28521. /**
  28522. * Gets wether or not position are enabled for the G buffer.
  28523. */
  28524. /**
  28525. * Sets wether or not position are enabled for the G buffer.
  28526. */
  28527. enablePosition: boolean;
  28528. /**
  28529. * Gets the scene associated with the buffer.
  28530. */
  28531. readonly scene: Scene;
  28532. /**
  28533. * Gets the ratio used by the buffer during its creation.
  28534. * How big is the buffer related to the main canvas.
  28535. */
  28536. readonly ratio: number;
  28537. /**
  28538. * Creates a new G Buffer for the scene
  28539. * @param scene The scene the buffer belongs to
  28540. * @param ratio How big is the buffer related to the main canvas.
  28541. */
  28542. constructor(scene: Scene, ratio?: number);
  28543. /**
  28544. * Checks wether everything is ready to render a submesh to the G buffer.
  28545. * @param subMesh the submesh to check readiness for
  28546. * @param useInstances is the mesh drawn using instance or not
  28547. * @returns true if ready otherwise false
  28548. */
  28549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28550. /**
  28551. * Gets the current underlying G Buffer.
  28552. * @returns the buffer
  28553. */
  28554. getGBuffer(): MultiRenderTarget;
  28555. /**
  28556. * Gets the number of samples used to render the buffer (anti aliasing).
  28557. */
  28558. /**
  28559. * Sets the number of samples used to render the buffer (anti aliasing).
  28560. */
  28561. samples: number;
  28562. /**
  28563. * Disposes the renderer and frees up associated resources.
  28564. */
  28565. dispose(): void;
  28566. protected _createRenderTargets(): void;
  28567. }
  28568. }
  28569. declare module BABYLON {
  28570. interface Scene {
  28571. /** @hidden (Backing field) */
  28572. /**
  28573. * Gets or Sets the current geometry buffer associated to the scene.
  28574. */
  28575. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28576. /**
  28577. * Enables a GeometryBufferRender and associates it with the scene
  28578. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  28579. * @returns the GeometryBufferRenderer
  28580. */
  28581. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  28582. /**
  28583. * Disables the GeometryBufferRender associated with the scene
  28584. */
  28585. disableGeometryBufferRenderer(): void;
  28586. }
  28587. /**
  28588. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  28589. * in several rendering techniques.
  28590. */
  28591. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  28592. /**
  28593. * The component name helpfull to identify the component in the list of scene components.
  28594. */
  28595. readonly name: string;
  28596. /**
  28597. * The scene the component belongs to.
  28598. */
  28599. scene: Scene;
  28600. /**
  28601. * Creates a new instance of the component for the given scene
  28602. * @param scene Defines the scene to register the component in
  28603. */
  28604. constructor(scene: Scene);
  28605. /**
  28606. * Registers the component in a given scene
  28607. */
  28608. register(): void;
  28609. /**
  28610. * Rebuilds the elements related to this component in case of
  28611. * context lost for instance.
  28612. */
  28613. rebuild(): void;
  28614. /**
  28615. * Disposes the component and the associated ressources
  28616. */
  28617. dispose(): void;
  28618. private _gatherRenderTargets;
  28619. }
  28620. }
  28621. declare module BABYLON {
  28622. /**
  28623. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28624. */
  28625. class LineEdgesRenderer extends EdgesRenderer {
  28626. /**
  28627. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28628. * @param source LineMesh used to generate edges
  28629. * @param epsilon not important (specified angle for edge detection)
  28630. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28631. */
  28632. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28633. /**
  28634. * Always create the edge since its a line so only important things are p0 and p1
  28635. * @param faceIndex not important for LineMesh
  28636. * @param edge not important for LineMesh
  28637. * @param faceNormals not important for LineMesh
  28638. * @param p0 beginnig of line
  28639. * @param p1 end of line
  28640. */
  28641. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28642. /**
  28643. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28644. */
  28645. }
  28646. }
  28647. declare module BABYLON {
  28648. interface Scene {
  28649. /** @hidden */
  28650. /**
  28651. * Gets the outline renderer associated with the scene
  28652. * @returns a OutlineRenderer
  28653. */
  28654. getOutlineRenderer(): OutlineRenderer;
  28655. }
  28656. interface AbstractMesh {
  28657. /** @hidden (Backing field) */
  28658. /**
  28659. * Gets or sets a boolean indicating if the outline must be rendered as well
  28660. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  28661. */
  28662. renderOutline: boolean;
  28663. /** @hidden (Backing field) */
  28664. /**
  28665. * Gets or sets a boolean indicating if the overlay must be rendered as well
  28666. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  28667. */
  28668. renderOverlay: boolean;
  28669. }
  28670. /**
  28671. * This class is responsible to draw bothe outline/overlay of meshes.
  28672. * It should not be used directly but through the available method on mesh.
  28673. */
  28674. class OutlineRenderer implements ISceneComponent {
  28675. /**
  28676. * The name of the component. Each component must have a unique name.
  28677. */
  28678. name: string;
  28679. /**
  28680. * The scene the component belongs to.
  28681. */
  28682. scene: Scene;
  28683. /**
  28684. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  28685. */
  28686. zOffset: number;
  28687. private _engine;
  28688. private _effect;
  28689. private _cachedDefines;
  28690. private _savedDepthWrite;
  28691. /**
  28692. * Instantiates a new outline renderer. (There could be only one per scene).
  28693. * @param scene Defines the scene it belongs to
  28694. */
  28695. constructor(scene: Scene);
  28696. /**
  28697. * Register the component to one instance of a scene.
  28698. */
  28699. register(): void;
  28700. /**
  28701. * Rebuilds the elements related to this component in case of
  28702. * context lost for instance.
  28703. */
  28704. rebuild(): void;
  28705. /**
  28706. * Disposes the component and the associated ressources.
  28707. */
  28708. dispose(): void;
  28709. /**
  28710. * Renders the outline in the canvas.
  28711. * @param subMesh Defines the sumesh to render
  28712. * @param batch Defines the batch of meshes in case of instances
  28713. * @param useOverlay Defines if the rendering is for the overlay or the outline
  28714. */
  28715. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  28716. /**
  28717. * Returns whether or not the outline renderer is ready for a given submesh.
  28718. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  28719. * @param subMesh Defines the submesh to check readyness for
  28720. * @param useInstances Defines wheter wee are trying to render instances or not
  28721. * @returns true if ready otherwise false
  28722. */
  28723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28724. private _beforeRenderingMesh;
  28725. private _afterRenderingMesh;
  28726. }
  28727. }
  28728. declare module BABYLON {
  28729. class RenderingGroup {
  28730. index: number;
  28731. private _scene;
  28732. private _opaqueSubMeshes;
  28733. private _transparentSubMeshes;
  28734. private _alphaTestSubMeshes;
  28735. private _depthOnlySubMeshes;
  28736. private _particleSystems;
  28737. private _spriteManagers;
  28738. private _opaqueSortCompareFn;
  28739. private _alphaTestSortCompareFn;
  28740. private _transparentSortCompareFn;
  28741. private _renderOpaque;
  28742. private _renderAlphaTest;
  28743. private _renderTransparent;
  28744. private _edgesRenderers;
  28745. onBeforeTransparentRendering: () => void;
  28746. /**
  28747. * Set the opaque sort comparison function.
  28748. * If null the sub meshes will be render in the order they were created
  28749. */
  28750. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28751. /**
  28752. * Set the alpha test sort comparison function.
  28753. * If null the sub meshes will be render in the order they were created
  28754. */
  28755. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28756. /**
  28757. * Set the transparent sort comparison function.
  28758. * If null the sub meshes will be render in the order they were created
  28759. */
  28760. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28761. /**
  28762. * Creates a new rendering group.
  28763. * @param index The rendering group index
  28764. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28765. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28766. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28767. */
  28768. 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>);
  28769. /**
  28770. * Render all the sub meshes contained in the group.
  28771. * @param customRenderFunction Used to override the default render behaviour of the group.
  28772. * @returns true if rendered some submeshes.
  28773. */
  28774. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28775. /**
  28776. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28777. * @param subMeshes The submeshes to render
  28778. */
  28779. private renderOpaqueSorted;
  28780. /**
  28781. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28782. * @param subMeshes The submeshes to render
  28783. */
  28784. private renderAlphaTestSorted;
  28785. /**
  28786. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28787. * @param subMeshes The submeshes to render
  28788. */
  28789. private renderTransparentSorted;
  28790. /**
  28791. * Renders the submeshes in a specified order.
  28792. * @param subMeshes The submeshes to sort before render
  28793. * @param sortCompareFn The comparison function use to sort
  28794. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28795. * @param transparent Specifies to activate blending if true
  28796. */
  28797. private static renderSorted;
  28798. /**
  28799. * Renders the submeshes in the order they were dispatched (no sort applied).
  28800. * @param subMeshes The submeshes to render
  28801. */
  28802. private static renderUnsorted;
  28803. /**
  28804. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28805. * are rendered back to front if in the same alpha index.
  28806. *
  28807. * @param a The first submesh
  28808. * @param b The second submesh
  28809. * @returns The result of the comparison
  28810. */
  28811. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28812. /**
  28813. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28814. * are rendered back to front.
  28815. *
  28816. * @param a The first submesh
  28817. * @param b The second submesh
  28818. * @returns The result of the comparison
  28819. */
  28820. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28821. /**
  28822. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28823. * are rendered front to back (prevent overdraw).
  28824. *
  28825. * @param a The first submesh
  28826. * @param b The second submesh
  28827. * @returns The result of the comparison
  28828. */
  28829. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28830. /**
  28831. * Resets the different lists of submeshes to prepare a new frame.
  28832. */
  28833. prepare(): void;
  28834. dispose(): void;
  28835. /**
  28836. * Inserts the submesh in its correct queue depending on its material.
  28837. * @param subMesh The submesh to dispatch
  28838. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28839. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28840. */
  28841. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28842. dispatchSprites(spriteManager: ISpriteManager): void;
  28843. dispatchParticles(particleSystem: IParticleSystem): void;
  28844. private _renderParticles;
  28845. private _renderSprites;
  28846. }
  28847. }
  28848. declare module BABYLON {
  28849. /**
  28850. * Interface describing the different options available in the rendering manager
  28851. * regarding Auto Clear between groups.
  28852. */
  28853. interface IRenderingManagerAutoClearSetup {
  28854. /**
  28855. * Defines whether or not autoclear is enable.
  28856. */
  28857. autoClear: boolean;
  28858. /**
  28859. * Defines whether or not to autoclear the depth buffer.
  28860. */
  28861. depth: boolean;
  28862. /**
  28863. * Defines whether or not to autoclear the stencil buffer.
  28864. */
  28865. stencil: boolean;
  28866. }
  28867. class RenderingManager {
  28868. /**
  28869. * The max id used for rendering groups (not included)
  28870. */
  28871. static MAX_RENDERINGGROUPS: number;
  28872. /**
  28873. * The min id used for rendering groups (included)
  28874. */
  28875. static MIN_RENDERINGGROUPS: number;
  28876. /**
  28877. * Used to globally prevent autoclearing scenes.
  28878. */
  28879. static AUTOCLEAR: boolean;
  28880. /**
  28881. * @hidden
  28882. */
  28883. private _scene;
  28884. private _renderingGroups;
  28885. private _depthStencilBufferAlreadyCleaned;
  28886. private _autoClearDepthStencil;
  28887. private _customOpaqueSortCompareFn;
  28888. private _customAlphaTestSortCompareFn;
  28889. private _customTransparentSortCompareFn;
  28890. private _renderingGroupInfo;
  28891. constructor(scene: Scene);
  28892. private _clearDepthStencilBuffer;
  28893. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28894. reset(): void;
  28895. dispose(): void;
  28896. /**
  28897. * Clear the info related to rendering groups preventing retention points during dispose.
  28898. */
  28899. freeRenderingGroups(): void;
  28900. private _prepareRenderingGroup;
  28901. dispatchSprites(spriteManager: ISpriteManager): void;
  28902. dispatchParticles(particleSystem: IParticleSystem): void;
  28903. /**
  28904. * @param subMesh The submesh to dispatch
  28905. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28906. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28907. */
  28908. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28909. /**
  28910. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28911. * This allowed control for front to back rendering or reversly depending of the special needs.
  28912. *
  28913. * @param renderingGroupId The rendering group id corresponding to its index
  28914. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28915. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28916. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28917. */
  28918. 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;
  28919. /**
  28920. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28921. *
  28922. * @param renderingGroupId The rendering group id corresponding to its index
  28923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28924. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28925. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28926. */
  28927. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28928. /**
  28929. * Gets the current auto clear configuration for one rendering group of the rendering
  28930. * manager.
  28931. * @param index the rendering group index to get the information for
  28932. * @returns The auto clear setup for the requested rendering group
  28933. */
  28934. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28935. }
  28936. }
  28937. declare module BABYLON {
  28938. /**
  28939. * Renders a layer on top of an existing scene
  28940. */
  28941. class UtilityLayerRenderer implements IDisposable {
  28942. /** the original scene that will be rendered on top of */
  28943. originalScene: Scene;
  28944. private _pointerCaptures;
  28945. private _lastPointerEvents;
  28946. private static _DefaultUtilityLayer;
  28947. private static _DefaultKeepDepthUtilityLayer;
  28948. /**
  28949. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  28950. */
  28951. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  28952. /**
  28953. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  28954. */
  28955. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  28956. /**
  28957. * The scene that is rendered on top of the original scene
  28958. */
  28959. utilityLayerScene: Scene;
  28960. /**
  28961. * If the utility layer should automatically be rendered on top of existing scene
  28962. */
  28963. shouldRender: boolean;
  28964. /**
  28965. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  28966. */
  28967. onlyCheckPointerDownEvents: boolean;
  28968. /**
  28969. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  28970. */
  28971. processAllEvents: boolean;
  28972. /**
  28973. * Observable raised when the pointer move from the utility layer scene to the main scene
  28974. */
  28975. onPointerOutObservable: Observable<number>;
  28976. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  28977. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  28978. private _afterRenderObserver;
  28979. private _sceneDisposeObserver;
  28980. private _originalPointerObserver;
  28981. /**
  28982. * Instantiates a UtilityLayerRenderer
  28983. * @param originalScene the original scene that will be rendered on top of
  28984. */
  28985. constructor(
  28986. /** the original scene that will be rendered on top of */
  28987. originalScene: Scene);
  28988. private _notifyObservers;
  28989. /**
  28990. * Renders the utility layers scene on top of the original scene
  28991. */
  28992. render(): void;
  28993. /**
  28994. * Disposes of the renderer
  28995. */
  28996. dispose(): void;
  28997. private _updateCamera;
  28998. }
  28999. }
  29000. declare module BABYLON {
  29001. class Sprite {
  29002. name: string;
  29003. position: Vector3;
  29004. color: Color4;
  29005. width: number;
  29006. height: number;
  29007. angle: number;
  29008. cellIndex: number;
  29009. invertU: number;
  29010. invertV: number;
  29011. disposeWhenFinishedAnimating: boolean;
  29012. animations: Animation[];
  29013. isPickable: boolean;
  29014. actionManager: ActionManager;
  29015. private _animationStarted;
  29016. private _loopAnimation;
  29017. private _fromIndex;
  29018. private _toIndex;
  29019. private _delay;
  29020. private _direction;
  29021. private _manager;
  29022. private _time;
  29023. private _onAnimationEnd;
  29024. /**
  29025. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29026. */
  29027. isVisible: boolean;
  29028. size: number;
  29029. constructor(name: string, manager: ISpriteManager);
  29030. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29031. stopAnimation(): void;
  29032. /** @hidden */
  29033. dispose(): void;
  29034. }
  29035. }
  29036. declare module BABYLON {
  29037. /**
  29038. * Defines the minimum interface to fullfil in order to be a sprite manager.
  29039. */
  29040. interface ISpriteManager extends IDisposable {
  29041. /**
  29042. * Restricts the camera to viewing objects with the same layerMask.
  29043. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  29044. */
  29045. layerMask: number;
  29046. /**
  29047. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29048. */
  29049. isPickable: boolean;
  29050. /**
  29051. * Specifies the rendering group id for this mesh (0 by default)
  29052. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29053. */
  29054. renderingGroupId: number;
  29055. /**
  29056. * Defines the list of sprites managed by the manager.
  29057. */
  29058. sprites: Array<Sprite>;
  29059. /**
  29060. * Tests the intersection of a sprite with a specific ray.
  29061. * @param ray The ray we are sending to test the collision
  29062. * @param camera The camera space we are sending rays in
  29063. * @param predicate A predicate allowing excluding sprites from the list of object to test
  29064. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  29065. * @returns picking info or null.
  29066. */
  29067. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29068. /**
  29069. * Renders the list of sprites on screen.
  29070. */
  29071. render(): void;
  29072. }
  29073. class SpriteManager implements ISpriteManager {
  29074. name: string;
  29075. sprites: Sprite[];
  29076. renderingGroupId: number;
  29077. layerMask: number;
  29078. fogEnabled: boolean;
  29079. isPickable: boolean;
  29080. cellWidth: number;
  29081. cellHeight: number;
  29082. /**
  29083. * An event triggered when the manager is disposed.
  29084. */
  29085. onDisposeObservable: Observable<SpriteManager>;
  29086. private _onDisposeObserver;
  29087. onDispose: () => void;
  29088. private _capacity;
  29089. private _spriteTexture;
  29090. private _epsilon;
  29091. private _scene;
  29092. private _vertexData;
  29093. private _buffer;
  29094. private _vertexBuffers;
  29095. private _indexBuffer;
  29096. private _effectBase;
  29097. private _effectFog;
  29098. texture: Texture;
  29099. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29100. private _appendSpriteVertex;
  29101. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29102. render(): void;
  29103. dispose(): void;
  29104. }
  29105. }
  29106. declare module BABYLON {
  29107. interface Scene {
  29108. /** @hidden */
  29109. /** @hidden */
  29110. /** @hidden */
  29111. /**
  29112. * All of the sprite managers added to this scene
  29113. * @see http://doc.babylonjs.com/babylon101/sprites
  29114. */
  29115. spriteManagers: Array<ISpriteManager>;
  29116. /**
  29117. * An event triggered when sprites rendering is about to start
  29118. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29119. */
  29120. onBeforeSpritesRenderingObservable: Observable<Scene>;
  29121. /**
  29122. * An event triggered when sprites rendering is done
  29123. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29124. */
  29125. onAfterSpritesRenderingObservable: Observable<Scene>;
  29126. /** @hidden */
  29127. /** Launch a ray to try to pick a sprite in the scene
  29128. * @param x position on screen
  29129. * @param y position on screen
  29130. * @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
  29131. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29132. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  29133. * @returns a PickingInfo
  29134. */
  29135. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29136. /** Use the given ray to pick a sprite in the scene
  29137. * @param ray The ray (in world space) to use to pick meshes
  29138. * @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
  29139. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29140. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  29141. * @returns a PickingInfo
  29142. */
  29143. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29144. /**
  29145. * Force the sprite under the pointer
  29146. * @param sprite defines the sprite to use
  29147. */
  29148. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  29149. /**
  29150. * Gets the sprite under the pointer
  29151. * @returns a Sprite or null if no sprite is under the pointer
  29152. */
  29153. getPointerOverSprite(): Nullable<Sprite>;
  29154. }
  29155. /**
  29156. * Defines the sprite scene component responsible to manage sprites
  29157. * in a given scene.
  29158. */
  29159. class SpriteSceneComponent implements ISceneComponent {
  29160. /**
  29161. * The component name helpfull to identify the component in the list of scene components.
  29162. */
  29163. readonly name: string;
  29164. /**
  29165. * The scene the component belongs to.
  29166. */
  29167. scene: Scene;
  29168. /** @hidden */
  29169. private _spritePredicate;
  29170. /**
  29171. * Creates a new instance of the component for the given scene
  29172. * @param scene Defines the scene to register the component in
  29173. */
  29174. constructor(scene: Scene);
  29175. /**
  29176. * Registers the component in a given scene
  29177. */
  29178. register(): void;
  29179. /**
  29180. * Rebuilds the elements related to this component in case of
  29181. * context lost for instance.
  29182. */
  29183. rebuild(): void;
  29184. /**
  29185. * Disposes the component and the associated ressources.
  29186. */
  29187. dispose(): void;
  29188. private _pickSpriteButKeepRay;
  29189. private _pointerMove;
  29190. private _pointerDown;
  29191. private _pointerUp;
  29192. }
  29193. }
  29194. declare module BABYLON {
  29195. /**
  29196. * @hidden
  29197. **/
  29198. class _AlphaState {
  29199. private _isAlphaBlendDirty;
  29200. private _isBlendFunctionParametersDirty;
  29201. private _isBlendEquationParametersDirty;
  29202. private _isBlendConstantsDirty;
  29203. private _alphaBlend;
  29204. private _blendFunctionParameters;
  29205. private _blendEquationParameters;
  29206. private _blendConstants;
  29207. /**
  29208. * Initializes the state.
  29209. */
  29210. constructor();
  29211. readonly isDirty: boolean;
  29212. alphaBlend: boolean;
  29213. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29214. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29215. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29216. reset(): void;
  29217. apply(gl: WebGLRenderingContext): void;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /**
  29222. * @hidden
  29223. **/
  29224. class _DepthCullingState {
  29225. private _isDepthTestDirty;
  29226. private _isDepthMaskDirty;
  29227. private _isDepthFuncDirty;
  29228. private _isCullFaceDirty;
  29229. private _isCullDirty;
  29230. private _isZOffsetDirty;
  29231. private _isFrontFaceDirty;
  29232. private _depthTest;
  29233. private _depthMask;
  29234. private _depthFunc;
  29235. private _cull;
  29236. private _cullFace;
  29237. private _zOffset;
  29238. private _frontFace;
  29239. /**
  29240. * Initializes the state.
  29241. */
  29242. constructor();
  29243. readonly isDirty: boolean;
  29244. zOffset: number;
  29245. cullFace: Nullable<number>;
  29246. cull: Nullable<boolean>;
  29247. depthFunc: Nullable<number>;
  29248. depthMask: boolean;
  29249. depthTest: boolean;
  29250. frontFace: Nullable<number>;
  29251. reset(): void;
  29252. apply(gl: WebGLRenderingContext): void;
  29253. }
  29254. }
  29255. declare module BABYLON {
  29256. /**
  29257. * @hidden
  29258. **/
  29259. class _StencilState {
  29260. private _isStencilTestDirty;
  29261. private _isStencilMaskDirty;
  29262. private _isStencilFuncDirty;
  29263. private _isStencilOpDirty;
  29264. private _stencilTest;
  29265. private _stencilMask;
  29266. private _stencilFunc;
  29267. private _stencilFuncRef;
  29268. private _stencilFuncMask;
  29269. private _stencilOpStencilFail;
  29270. private _stencilOpDepthFail;
  29271. private _stencilOpStencilDepthPass;
  29272. readonly isDirty: boolean;
  29273. stencilFunc: number;
  29274. stencilFuncRef: number;
  29275. stencilFuncMask: number;
  29276. stencilOpStencilFail: number;
  29277. stencilOpDepthFail: number;
  29278. stencilOpStencilDepthPass: number;
  29279. stencilMask: number;
  29280. stencilTest: boolean;
  29281. constructor();
  29282. reset(): void;
  29283. apply(gl: WebGLRenderingContext): void;
  29284. }
  29285. }
  29286. declare module BABYLON {
  29287. /**
  29288. * Class used to evalaute queries containing `and` and `or` operators
  29289. */
  29290. class AndOrNotEvaluator {
  29291. /**
  29292. * Evaluate a query
  29293. * @param query defines the query to evaluate
  29294. * @param evaluateCallback defines the callback used to filter result
  29295. * @returns true if the query matches
  29296. */
  29297. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29298. private static _HandleParenthesisContent;
  29299. private static _SimplifyNegation;
  29300. }
  29301. }
  29302. declare module BABYLON {
  29303. /**
  29304. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29305. */
  29306. enum AssetTaskState {
  29307. /**
  29308. * Initialization
  29309. */
  29310. INIT = 0,
  29311. /**
  29312. * Running
  29313. */
  29314. RUNNING = 1,
  29315. /**
  29316. * Done
  29317. */
  29318. DONE = 2,
  29319. /**
  29320. * Error
  29321. */
  29322. ERROR = 3
  29323. }
  29324. /**
  29325. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29326. */
  29327. abstract class AbstractAssetTask {
  29328. /**
  29329. * Task name
  29330. */ name: string;
  29331. /**
  29332. * Callback called when the task is successful
  29333. */
  29334. onSuccess: (task: any) => void;
  29335. /**
  29336. * Callback called when the task is not successful
  29337. */
  29338. onError: (task: any, message?: string, exception?: any) => void;
  29339. /**
  29340. * Creates a new {BABYLON.AssetsManager}
  29341. * @param name defines the name of the task
  29342. */
  29343. constructor(
  29344. /**
  29345. * Task name
  29346. */ name: string);
  29347. private _isCompleted;
  29348. private _taskState;
  29349. private _errorObject;
  29350. /**
  29351. * Get if the task is completed
  29352. */
  29353. readonly isCompleted: boolean;
  29354. /**
  29355. * Gets the current state of the task
  29356. */
  29357. readonly taskState: AssetTaskState;
  29358. /**
  29359. * Gets the current error object (if task is in error)
  29360. */
  29361. readonly errorObject: {
  29362. message?: string;
  29363. exception?: any;
  29364. };
  29365. /**
  29366. * Internal only
  29367. * @hidden
  29368. */
  29369. /**
  29370. * Execute the current task
  29371. * @param scene defines the scene where you want your assets to be loaded
  29372. * @param onSuccess is a callback called when the task is successfully executed
  29373. * @param onError is a callback called if an error occurs
  29374. */
  29375. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29376. /**
  29377. * Execute the current task
  29378. * @param scene defines the scene where you want your assets to be loaded
  29379. * @param onSuccess is a callback called when the task is successfully executed
  29380. * @param onError is a callback called if an error occurs
  29381. */
  29382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29383. /**
  29384. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29385. * This can be used with failed tasks that have the reason for failure fixed.
  29386. */
  29387. reset(): void;
  29388. private onErrorCallback;
  29389. private onDoneCallback;
  29390. }
  29391. /**
  29392. * Define the interface used by progress events raised during assets loading
  29393. */
  29394. interface IAssetsProgressEvent {
  29395. /**
  29396. * Defines the number of remaining tasks to process
  29397. */
  29398. remainingCount: number;
  29399. /**
  29400. * Defines the total number of tasks
  29401. */
  29402. totalCount: number;
  29403. /**
  29404. * Defines the task that was just processed
  29405. */
  29406. task: AbstractAssetTask;
  29407. }
  29408. /**
  29409. * Class used to share progress information about assets loading
  29410. */
  29411. class AssetsProgressEvent implements IAssetsProgressEvent {
  29412. /**
  29413. * Defines the number of remaining tasks to process
  29414. */
  29415. remainingCount: number;
  29416. /**
  29417. * Defines the total number of tasks
  29418. */
  29419. totalCount: number;
  29420. /**
  29421. * Defines the task that was just processed
  29422. */
  29423. task: AbstractAssetTask;
  29424. /**
  29425. * Creates a {BABYLON.AssetsProgressEvent}
  29426. * @param remainingCount defines the number of remaining tasks to process
  29427. * @param totalCount defines the total number of tasks
  29428. * @param task defines the task that was just processed
  29429. */
  29430. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29431. }
  29432. /**
  29433. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29434. */
  29435. class MeshAssetTask extends AbstractAssetTask {
  29436. /**
  29437. * Defines the name of the task
  29438. */
  29439. name: string;
  29440. /**
  29441. * Defines the list of mesh's names you want to load
  29442. */
  29443. meshesNames: any;
  29444. /**
  29445. * Defines the root url to use as a base to load your meshes and associated resources
  29446. */
  29447. rootUrl: string;
  29448. /**
  29449. * Defines the filename of the scene to load from
  29450. */
  29451. sceneFilename: string;
  29452. /**
  29453. * Gets the list of loaded meshes
  29454. */
  29455. loadedMeshes: Array<AbstractMesh>;
  29456. /**
  29457. * Gets the list of loaded particle systems
  29458. */
  29459. loadedParticleSystems: Array<IParticleSystem>;
  29460. /**
  29461. * Gets the list of loaded skeletons
  29462. */
  29463. loadedSkeletons: Array<Skeleton>;
  29464. /**
  29465. * Callback called when the task is successful
  29466. */
  29467. onSuccess: (task: MeshAssetTask) => void;
  29468. /**
  29469. * Callback called when the task is successful
  29470. */
  29471. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29472. /**
  29473. * Creates a new {BABYLON.MeshAssetTask}
  29474. * @param name defines the name of the task
  29475. * @param meshesNames defines the list of mesh's names you want to load
  29476. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29477. * @param sceneFilename defines the filename of the scene to load from
  29478. */
  29479. constructor(
  29480. /**
  29481. * Defines the name of the task
  29482. */
  29483. name: string,
  29484. /**
  29485. * Defines the list of mesh's names you want to load
  29486. */
  29487. meshesNames: any,
  29488. /**
  29489. * Defines the root url to use as a base to load your meshes and associated resources
  29490. */
  29491. rootUrl: string,
  29492. /**
  29493. * Defines the filename of the scene to load from
  29494. */
  29495. sceneFilename: string);
  29496. /**
  29497. * Execute the current task
  29498. * @param scene defines the scene where you want your assets to be loaded
  29499. * @param onSuccess is a callback called when the task is successfully executed
  29500. * @param onError is a callback called if an error occurs
  29501. */
  29502. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29503. }
  29504. /**
  29505. * Define a task used by {BABYLON.AssetsManager} to load text content
  29506. */
  29507. class TextFileAssetTask extends AbstractAssetTask {
  29508. /**
  29509. * Defines the name of the task
  29510. */
  29511. name: string;
  29512. /**
  29513. * Defines the location of the file to load
  29514. */
  29515. url: string;
  29516. /**
  29517. * Gets the loaded text string
  29518. */
  29519. text: string;
  29520. /**
  29521. * Callback called when the task is successful
  29522. */
  29523. onSuccess: (task: TextFileAssetTask) => void;
  29524. /**
  29525. * Callback called when the task is successful
  29526. */
  29527. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  29528. /**
  29529. * Creates a new TextFileAssetTask object
  29530. * @param name defines the name of the task
  29531. * @param url defines the location of the file to load
  29532. */
  29533. constructor(
  29534. /**
  29535. * Defines the name of the task
  29536. */
  29537. name: string,
  29538. /**
  29539. * Defines the location of the file to load
  29540. */
  29541. url: string);
  29542. /**
  29543. * Execute the current task
  29544. * @param scene defines the scene where you want your assets to be loaded
  29545. * @param onSuccess is a callback called when the task is successfully executed
  29546. * @param onError is a callback called if an error occurs
  29547. */
  29548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29549. }
  29550. /**
  29551. * Define a task used by {BABYLON.AssetsManager} to load binary data
  29552. */
  29553. class BinaryFileAssetTask extends AbstractAssetTask {
  29554. /**
  29555. * Defines the name of the task
  29556. */
  29557. name: string;
  29558. /**
  29559. * Defines the location of the file to load
  29560. */
  29561. url: string;
  29562. /**
  29563. * Gets the lodaded data (as an array buffer)
  29564. */
  29565. data: ArrayBuffer;
  29566. /**
  29567. * Callback called when the task is successful
  29568. */
  29569. onSuccess: (task: BinaryFileAssetTask) => void;
  29570. /**
  29571. * Callback called when the task is successful
  29572. */
  29573. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  29574. /**
  29575. * Creates a new BinaryFileAssetTask object
  29576. * @param name defines the name of the new task
  29577. * @param url defines the location of the file to load
  29578. */
  29579. constructor(
  29580. /**
  29581. * Defines the name of the task
  29582. */
  29583. name: string,
  29584. /**
  29585. * Defines the location of the file to load
  29586. */
  29587. url: string);
  29588. /**
  29589. * Execute the current task
  29590. * @param scene defines the scene where you want your assets to be loaded
  29591. * @param onSuccess is a callback called when the task is successfully executed
  29592. * @param onError is a callback called if an error occurs
  29593. */
  29594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29595. }
  29596. /**
  29597. * Define a task used by {BABYLON.AssetsManager} to load images
  29598. */
  29599. class ImageAssetTask extends AbstractAssetTask {
  29600. /**
  29601. * Defines the name of the task
  29602. */
  29603. name: string;
  29604. /**
  29605. * Defines the location of the image to load
  29606. */
  29607. url: string;
  29608. /**
  29609. * Gets the loaded images
  29610. */
  29611. image: HTMLImageElement;
  29612. /**
  29613. * Callback called when the task is successful
  29614. */
  29615. onSuccess: (task: ImageAssetTask) => void;
  29616. /**
  29617. * Callback called when the task is successful
  29618. */
  29619. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  29620. /**
  29621. * Creates a new ImageAssetTask
  29622. * @param name defines the name of the task
  29623. * @param url defines the location of the image to load
  29624. */
  29625. constructor(
  29626. /**
  29627. * Defines the name of the task
  29628. */
  29629. name: string,
  29630. /**
  29631. * Defines the location of the image to load
  29632. */
  29633. url: string);
  29634. /**
  29635. * Execute the current task
  29636. * @param scene defines the scene where you want your assets to be loaded
  29637. * @param onSuccess is a callback called when the task is successfully executed
  29638. * @param onError is a callback called if an error occurs
  29639. */
  29640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29641. }
  29642. /**
  29643. * Defines the interface used by texture loading tasks
  29644. */
  29645. interface ITextureAssetTask<TEX extends BaseTexture> {
  29646. /**
  29647. * Gets the loaded texture
  29648. */
  29649. texture: TEX;
  29650. }
  29651. /**
  29652. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  29653. */
  29654. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  29655. /**
  29656. * Defines the name of the task
  29657. */
  29658. name: string;
  29659. /**
  29660. * Defines the location of the file to load
  29661. */
  29662. url: string;
  29663. /**
  29664. * Defines if mipmap should not be generated (default is false)
  29665. */
  29666. noMipmap?: boolean | undefined;
  29667. /**
  29668. * Defines if texture must be inverted on Y axis (default is false)
  29669. */
  29670. invertY?: boolean | undefined;
  29671. /**
  29672. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29673. */
  29674. samplingMode: number;
  29675. /**
  29676. * Gets the loaded texture
  29677. */
  29678. texture: Texture;
  29679. /**
  29680. * Callback called when the task is successful
  29681. */
  29682. onSuccess: (task: TextureAssetTask) => void;
  29683. /**
  29684. * Callback called when the task is successful
  29685. */
  29686. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  29687. /**
  29688. * Creates a new TextureAssetTask object
  29689. * @param name defines the name of the task
  29690. * @param url defines the location of the file to load
  29691. * @param noMipmap defines if mipmap should not be generated (default is false)
  29692. * @param invertY defines if texture must be inverted on Y axis (default is false)
  29693. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29694. */
  29695. constructor(
  29696. /**
  29697. * Defines the name of the task
  29698. */
  29699. name: string,
  29700. /**
  29701. * Defines the location of the file to load
  29702. */
  29703. url: string,
  29704. /**
  29705. * Defines if mipmap should not be generated (default is false)
  29706. */
  29707. noMipmap?: boolean | undefined,
  29708. /**
  29709. * Defines if texture must be inverted on Y axis (default is false)
  29710. */
  29711. invertY?: boolean | undefined,
  29712. /**
  29713. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29714. */
  29715. samplingMode?: number);
  29716. /**
  29717. * Execute the current task
  29718. * @param scene defines the scene where you want your assets to be loaded
  29719. * @param onSuccess is a callback called when the task is successfully executed
  29720. * @param onError is a callback called if an error occurs
  29721. */
  29722. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29723. }
  29724. /**
  29725. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  29726. */
  29727. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  29728. /**
  29729. * Defines the name of the task
  29730. */
  29731. name: string;
  29732. /**
  29733. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29734. */
  29735. url: string;
  29736. /**
  29737. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29738. */
  29739. extensions?: string[] | undefined;
  29740. /**
  29741. * Defines if mipmaps should not be generated (default is false)
  29742. */
  29743. noMipmap?: boolean | undefined;
  29744. /**
  29745. * Defines the explicit list of files (undefined by default)
  29746. */
  29747. files?: string[] | undefined;
  29748. /**
  29749. * Gets the loaded texture
  29750. */
  29751. texture: CubeTexture;
  29752. /**
  29753. * Callback called when the task is successful
  29754. */
  29755. onSuccess: (task: CubeTextureAssetTask) => void;
  29756. /**
  29757. * Callback called when the task is successful
  29758. */
  29759. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  29760. /**
  29761. * Creates a new CubeTextureAssetTask
  29762. * @param name defines the name of the task
  29763. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29764. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29765. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29766. * @param files defines the explicit list of files (undefined by default)
  29767. */
  29768. constructor(
  29769. /**
  29770. * Defines the name of the task
  29771. */
  29772. name: string,
  29773. /**
  29774. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29775. */
  29776. url: string,
  29777. /**
  29778. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29779. */
  29780. extensions?: string[] | undefined,
  29781. /**
  29782. * Defines if mipmaps should not be generated (default is false)
  29783. */
  29784. noMipmap?: boolean | undefined,
  29785. /**
  29786. * Defines the explicit list of files (undefined by default)
  29787. */
  29788. files?: string[] | undefined);
  29789. /**
  29790. * Execute the current task
  29791. * @param scene defines the scene where you want your assets to be loaded
  29792. * @param onSuccess is a callback called when the task is successfully executed
  29793. * @param onError is a callback called if an error occurs
  29794. */
  29795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29796. }
  29797. /**
  29798. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  29799. */
  29800. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  29801. /**
  29802. * Defines the name of the task
  29803. */
  29804. name: string;
  29805. /**
  29806. * Defines the location of the file to load
  29807. */
  29808. url: string;
  29809. /**
  29810. * Defines the desired size (the more it increases the longer the generation will be)
  29811. */
  29812. size: number;
  29813. /**
  29814. * Defines if mipmaps should not be generated (default is false)
  29815. */
  29816. noMipmap: boolean;
  29817. /**
  29818. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29819. */
  29820. generateHarmonics: boolean;
  29821. /**
  29822. * 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)
  29823. */
  29824. gammaSpace: boolean;
  29825. /**
  29826. * Internal Use Only
  29827. */
  29828. reserved: boolean;
  29829. /**
  29830. * Gets the loaded texture
  29831. */
  29832. texture: HDRCubeTexture;
  29833. /**
  29834. * Callback called when the task is successful
  29835. */
  29836. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  29837. /**
  29838. * Callback called when the task is successful
  29839. */
  29840. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  29841. /**
  29842. * Creates a new HDRCubeTextureAssetTask object
  29843. * @param name defines the name of the task
  29844. * @param url defines the location of the file to load
  29845. * @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.
  29846. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29847. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29848. * @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)
  29849. * @param reserved Internal use only
  29850. */
  29851. constructor(
  29852. /**
  29853. * Defines the name of the task
  29854. */
  29855. name: string,
  29856. /**
  29857. * Defines the location of the file to load
  29858. */
  29859. url: string,
  29860. /**
  29861. * Defines the desired size (the more it increases the longer the generation will be)
  29862. */
  29863. size: number,
  29864. /**
  29865. * Defines if mipmaps should not be generated (default is false)
  29866. */
  29867. noMipmap?: boolean,
  29868. /**
  29869. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29870. */
  29871. generateHarmonics?: boolean,
  29872. /**
  29873. * 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)
  29874. */
  29875. gammaSpace?: boolean,
  29876. /**
  29877. * Internal Use Only
  29878. */
  29879. reserved?: boolean);
  29880. /**
  29881. * Execute the current task
  29882. * @param scene defines the scene where you want your assets to be loaded
  29883. * @param onSuccess is a callback called when the task is successfully executed
  29884. * @param onError is a callback called if an error occurs
  29885. */
  29886. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29887. }
  29888. /**
  29889. * This class can be used to easily import assets into a scene
  29890. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  29891. */
  29892. class AssetsManager {
  29893. private _scene;
  29894. private _isLoading;
  29895. protected _tasks: AbstractAssetTask[];
  29896. protected _waitingTasksCount: number;
  29897. protected _totalTasksCount: number;
  29898. /**
  29899. * Callback called when all tasks are processed
  29900. */
  29901. onFinish: (tasks: AbstractAssetTask[]) => void;
  29902. /**
  29903. * Callback called when a task is successful
  29904. */
  29905. onTaskSuccess: (task: AbstractAssetTask) => void;
  29906. /**
  29907. * Callback called when a task had an error
  29908. */
  29909. onTaskError: (task: AbstractAssetTask) => void;
  29910. /**
  29911. * Callback called when a task is done (whatever the result is)
  29912. */
  29913. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  29914. /**
  29915. * Observable called when all tasks are processed
  29916. */
  29917. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  29918. /**
  29919. * Observable called when a task had an error
  29920. */
  29921. onTaskErrorObservable: Observable<AbstractAssetTask>;
  29922. /**
  29923. * Observable called when a task is successful
  29924. */
  29925. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  29926. /**
  29927. * Observable called when a task is done (whatever the result is)
  29928. */
  29929. onProgressObservable: Observable<IAssetsProgressEvent>;
  29930. /**
  29931. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  29932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29933. */
  29934. useDefaultLoadingScreen: boolean;
  29935. /**
  29936. * Creates a new AssetsManager
  29937. * @param scene defines the scene to work on
  29938. */
  29939. constructor(scene: Scene);
  29940. /**
  29941. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  29942. * @param taskName defines the name of the new task
  29943. * @param meshesNames defines the name of meshes to load
  29944. * @param rootUrl defines the root url to use to locate files
  29945. * @param sceneFilename defines the filename of the scene file
  29946. * @returns a new {BABYLON.MeshAssetTask} object
  29947. */
  29948. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  29949. /**
  29950. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  29951. * @param taskName defines the name of the new task
  29952. * @param url defines the url of the file to load
  29953. * @returns a new {BABYLON.TextFileAssetTask} object
  29954. */
  29955. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  29956. /**
  29957. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  29958. * @param taskName defines the name of the new task
  29959. * @param url defines the url of the file to load
  29960. * @returns a new {BABYLON.BinaryFileAssetTask} object
  29961. */
  29962. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  29963. /**
  29964. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  29965. * @param taskName defines the name of the new task
  29966. * @param url defines the url of the file to load
  29967. * @returns a new {BABYLON.ImageAssetTask} object
  29968. */
  29969. addImageTask(taskName: string, url: string): ImageAssetTask;
  29970. /**
  29971. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29972. * @param taskName defines the name of the new task
  29973. * @param url defines the url of the file to load
  29974. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29975. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29976. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29977. * @returns a new {BABYLON.TextureAssetTask} object
  29978. */
  29979. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29980. /**
  29981. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29982. * @param taskName defines the name of the new task
  29983. * @param url defines the url of the file to load
  29984. * @param extensions defines the extension to use to load the cube map (can be null)
  29985. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29986. * @param files defines the list of files to load (can be null)
  29987. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29988. */
  29989. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29990. /**
  29991. *
  29992. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29993. * @param taskName defines the name of the new task
  29994. * @param url defines the url of the file to load
  29995. * @param size defines the size you want for the cubemap (can be null)
  29996. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29997. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29998. * @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)
  29999. * @param reserved Internal use only
  30000. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30001. */
  30002. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30003. /**
  30004. * Remove a task from the assets manager.
  30005. * @param task the task to remove
  30006. */
  30007. removeTask(task: AbstractAssetTask): void;
  30008. private _decreaseWaitingTasksCount;
  30009. private _runTask;
  30010. /**
  30011. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30012. * @return the current instance of the {BABYLON.AssetsManager}
  30013. */
  30014. reset(): AssetsManager;
  30015. /**
  30016. * Start the loading process
  30017. * @return the current instance of the {BABYLON.AssetsManager}
  30018. */
  30019. load(): AssetsManager;
  30020. }
  30021. }
  30022. declare module BABYLON {
  30023. /**
  30024. * Class used to enable access to IndexedDB
  30025. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30026. */
  30027. class Database {
  30028. private callbackManifestChecked;
  30029. private currentSceneUrl;
  30030. private db;
  30031. private _enableSceneOffline;
  30032. private _enableTexturesOffline;
  30033. private manifestVersionFound;
  30034. private mustUpdateRessources;
  30035. private hasReachedQuota;
  30036. private isSupported;
  30037. private idbFactory;
  30038. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30039. static IsUASupportingBlobStorage: boolean;
  30040. /** Gets a boolean indicating if Database storate is enabled */
  30041. static IDBStorageEnabled: boolean;
  30042. /**
  30043. * Gets a boolean indicating if scene must be saved in the database
  30044. */
  30045. readonly enableSceneOffline: boolean;
  30046. /**
  30047. * Gets a boolean indicating if textures must be saved in the database
  30048. */
  30049. readonly enableTexturesOffline: boolean;
  30050. /**
  30051. * Creates a new Database
  30052. * @param urlToScene defines the url to load the scene
  30053. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30054. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30055. */
  30056. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30057. private static _ParseURL;
  30058. private static _ReturnFullUrlLocation;
  30059. private _checkManifestFile;
  30060. /**
  30061. * Open the database and make it available
  30062. * @param successCallback defines the callback to call on success
  30063. * @param errorCallback defines the callback to call on error
  30064. */
  30065. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30066. /**
  30067. * Loads an image from the database
  30068. * @param url defines the url to load from
  30069. * @param image defines the target DOM image
  30070. */
  30071. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30072. private _loadImageFromDBAsync;
  30073. private _saveImageIntoDBAsync;
  30074. private _checkVersionFromDB;
  30075. private _loadVersionFromDBAsync;
  30076. private _saveVersionIntoDBAsync;
  30077. /**
  30078. * Loads a file from database
  30079. * @param url defines the URL to load from
  30080. * @param sceneLoaded defines a callback to call on success
  30081. * @param progressCallBack defines a callback to call when progress changed
  30082. * @param errorCallback defines a callback to call on error
  30083. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30084. */
  30085. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30086. private _loadFileFromDBAsync;
  30087. private _saveFileIntoDBAsync;
  30088. }
  30089. }
  30090. declare module BABYLON {
  30091. interface DDSInfo {
  30092. width: number;
  30093. height: number;
  30094. mipmapCount: number;
  30095. isFourCC: boolean;
  30096. isRGB: boolean;
  30097. isLuminance: boolean;
  30098. isCube: boolean;
  30099. isCompressed: boolean;
  30100. dxgiFormat: number;
  30101. textureType: number;
  30102. /** Sphericle polynomial created for the dds texture */
  30103. sphericalPolynomial?: SphericalPolynomial;
  30104. }
  30105. class DDSTools {
  30106. static StoreLODInAlphaChannel: boolean;
  30107. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30108. private static _FloatView;
  30109. private static _Int32View;
  30110. private static _ToHalfFloat;
  30111. private static _FromHalfFloat;
  30112. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30113. private static _GetHalfFloatRGBAArrayBuffer;
  30114. private static _GetFloatRGBAArrayBuffer;
  30115. private static _GetFloatAsUIntRGBAArrayBuffer;
  30116. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30117. private static _GetRGBAArrayBuffer;
  30118. private static _ExtractLongWordOrder;
  30119. private static _GetRGBArrayBuffer;
  30120. private static _GetLuminanceArrayBuffer;
  30121. /**
  30122. * Uploads DDS Levels to a Babylon Texture
  30123. * @hidden
  30124. */
  30125. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30126. }
  30127. }
  30128. declare module BABYLON {
  30129. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30130. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30131. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30132. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30133. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30134. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30135. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30136. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30137. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30138. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30139. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30140. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30141. /**
  30142. * Decorator used to define property that can be serialized as reference to a camera
  30143. * @param sourceName defines the name of the property to decorate
  30144. */
  30145. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30146. class SerializationHelper {
  30147. static Serialize<T>(entity: T, serializationObject?: any): any;
  30148. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30149. static Clone<T>(creationFunction: () => T, source: T): T;
  30150. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30151. }
  30152. }
  30153. declare module BABYLON {
  30154. /**
  30155. * Wrapper class for promise with external resolve and reject.
  30156. */
  30157. class Deferred<T> {
  30158. /**
  30159. * The promise associated with this deferred object.
  30160. */
  30161. readonly promise: Promise<T>;
  30162. private _resolve;
  30163. private _reject;
  30164. /**
  30165. * The resolve method of the promise associated with this deferred object.
  30166. */
  30167. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30168. /**
  30169. * The reject method of the promise associated with this deferred object.
  30170. */
  30171. readonly reject: (reason?: any) => void;
  30172. /**
  30173. * Constructor for this deferred object.
  30174. */
  30175. constructor();
  30176. }
  30177. }
  30178. declare module BABYLON {
  30179. /**
  30180. * Raw texture data and descriptor sufficient for WebGL texture upload
  30181. */
  30182. interface EnvironmentTextureInfo {
  30183. /**
  30184. * Version of the environment map
  30185. */
  30186. version: number;
  30187. /**
  30188. * Width of image
  30189. */
  30190. width: number;
  30191. /**
  30192. * Irradiance information stored in the file.
  30193. */
  30194. irradiance: any;
  30195. /**
  30196. * Specular information stored in the file.
  30197. */
  30198. specular: any;
  30199. }
  30200. /**
  30201. * Sets of helpers addressing the serialization and deserialization of environment texture
  30202. * stored in a BabylonJS env file.
  30203. * Those files are usually stored as .env files.
  30204. */
  30205. class EnvironmentTextureTools {
  30206. /**
  30207. * Magic number identifying the env file.
  30208. */
  30209. private static _MagicBytes;
  30210. /**
  30211. * Gets the environment info from an env file.
  30212. * @param data The array buffer containing the .env bytes.
  30213. * @returns the environment file info (the json header) if successfully parsed.
  30214. */
  30215. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30216. /**
  30217. * Creates an environment texture from a loaded cube texture.
  30218. * @param texture defines the cube texture to convert in env file
  30219. * @return a promise containing the environment data if succesfull.
  30220. */
  30221. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30222. /**
  30223. * Creates a JSON representation of the spherical data.
  30224. * @param texture defines the texture containing the polynomials
  30225. * @return the JSON representation of the spherical info
  30226. */
  30227. private static _CreateEnvTextureIrradiance;
  30228. /**
  30229. * Uploads the texture info contained in the env file to the GPU.
  30230. * @param texture defines the internal texture to upload to
  30231. * @param arrayBuffer defines the buffer cotaining the data to load
  30232. * @param info defines the texture info retrieved through the GetEnvInfo method
  30233. * @returns a promise
  30234. */
  30235. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30236. /**
  30237. * Uploads the levels of image data to the GPU.
  30238. * @param texture defines the internal texture to upload to
  30239. * @param imageData defines the array buffer views of image data [mipmap][face]
  30240. * @returns a promise
  30241. */
  30242. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30243. /**
  30244. * Uploads spherical polynomials information to the texture.
  30245. * @param texture defines the texture we are trying to upload the information to
  30246. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30247. */
  30248. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30249. }
  30250. }
  30251. declare module BABYLON {
  30252. class FilesInput {
  30253. static FilesToLoad: {
  30254. [key: string]: File;
  30255. };
  30256. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30257. private _engine;
  30258. private _currentScene;
  30259. private _sceneLoadedCallback;
  30260. private _progressCallback;
  30261. private _additionalRenderLoopLogicCallback;
  30262. private _textureLoadingCallback;
  30263. private _startingProcessingFilesCallback;
  30264. private _onReloadCallback;
  30265. private _errorCallback;
  30266. private _elementToMonitor;
  30267. private _sceneFileToLoad;
  30268. private _filesToLoad;
  30269. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  30270. private _dragEnterHandler;
  30271. private _dragOverHandler;
  30272. private _dropHandler;
  30273. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30274. dispose(): void;
  30275. private renderFunction;
  30276. private drag;
  30277. private drop;
  30278. private _traverseFolder;
  30279. private _processFiles;
  30280. loadFiles(event: any): void;
  30281. private _processReload;
  30282. reload(): void;
  30283. }
  30284. }
  30285. declare module BABYLON {
  30286. /**
  30287. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30288. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30289. */
  30290. class KhronosTextureContainer {
  30291. arrayBuffer: any;
  30292. static HEADER_LEN: number;
  30293. static COMPRESSED_2D: number;
  30294. static COMPRESSED_3D: number;
  30295. static TEX_2D: number;
  30296. static TEX_3D: number;
  30297. glType: number;
  30298. glTypeSize: number;
  30299. glFormat: number;
  30300. glInternalFormat: number;
  30301. glBaseInternalFormat: number;
  30302. pixelWidth: number;
  30303. pixelHeight: number;
  30304. pixelDepth: number;
  30305. numberOfArrayElements: number;
  30306. numberOfFaces: number;
  30307. numberOfMipmapLevels: number;
  30308. bytesOfKeyValueData: number;
  30309. loadType: number;
  30310. /**
  30311. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30312. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30313. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30314. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30315. */
  30316. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30317. switchEndainness(val: number): number;
  30318. /**
  30319. * Uploads KTX content to a Babylon Texture.
  30320. * It is assumed that the texture has already been created & is currently bound
  30321. * @hidden
  30322. */
  30323. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30324. private _upload2DCompressedLevels;
  30325. }
  30326. }
  30327. declare module BABYLON {
  30328. /**
  30329. * A class serves as a medium between the observable and its observers
  30330. */
  30331. class EventState {
  30332. /**
  30333. * Create a new EventState
  30334. * @param mask defines the mask associated with this state
  30335. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30336. * @param target defines the original target of the state
  30337. * @param currentTarget defines the current target of the state
  30338. */
  30339. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30340. /**
  30341. * Initialize the current event state
  30342. * @param mask defines the mask associated with this state
  30343. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30344. * @param target defines the original target of the state
  30345. * @param currentTarget defines the current target of the state
  30346. * @returns the current event state
  30347. */
  30348. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30349. /**
  30350. * An Observer can set this property to true to prevent subsequent observers of being notified
  30351. */
  30352. skipNextObservers: boolean;
  30353. /**
  30354. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30355. */
  30356. mask: number;
  30357. /**
  30358. * The object that originally notified the event
  30359. */
  30360. target?: any;
  30361. /**
  30362. * The current object in the bubbling phase
  30363. */
  30364. currentTarget?: any;
  30365. /**
  30366. * This will be populated with the return value of the last function that was executed.
  30367. * If it is the first function in the callback chain it will be the event data.
  30368. */
  30369. lastReturnValue?: any;
  30370. }
  30371. /**
  30372. * Represent an Observer registered to a given Observable object.
  30373. */
  30374. class Observer<T> {
  30375. /**
  30376. * Defines the callback to call when the observer is notified
  30377. */
  30378. callback: (eventData: T, eventState: EventState) => void;
  30379. /**
  30380. * Defines the mask of the observer (used to filter notifications)
  30381. */
  30382. mask: number;
  30383. /**
  30384. * Defines the current scope used to restore the JS context
  30385. */
  30386. scope: any;
  30387. /** @hidden */
  30388. /**
  30389. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30390. */
  30391. unregisterOnNextCall: boolean;
  30392. /**
  30393. * Creates a new observer
  30394. * @param callback defines the callback to call when the observer is notified
  30395. * @param mask defines the mask of the observer (used to filter notifications)
  30396. * @param scope defines the current scope used to restore the JS context
  30397. */
  30398. constructor(
  30399. /**
  30400. * Defines the callback to call when the observer is notified
  30401. */
  30402. callback: (eventData: T, eventState: EventState) => void,
  30403. /**
  30404. * Defines the mask of the observer (used to filter notifications)
  30405. */
  30406. mask: number,
  30407. /**
  30408. * Defines the current scope used to restore the JS context
  30409. */
  30410. scope?: any);
  30411. }
  30412. /**
  30413. * Represent a list of observers registered to multiple Observables object.
  30414. */
  30415. class MultiObserver<T> {
  30416. private _observers;
  30417. private _observables;
  30418. /**
  30419. * Release associated resources
  30420. */
  30421. dispose(): void;
  30422. /**
  30423. * Raise a callback when one of the observable will notify
  30424. * @param observables defines a list of observables to watch
  30425. * @param callback defines the callback to call on notification
  30426. * @param mask defines the mask used to filter notifications
  30427. * @param scope defines the current scope used to restore the JS context
  30428. * @returns the new MultiObserver
  30429. */
  30430. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30431. }
  30432. /**
  30433. * The Observable class is a simple implementation of the Observable pattern.
  30434. *
  30435. * 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.
  30436. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30437. * 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).
  30438. * 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.
  30439. */
  30440. class Observable<T> {
  30441. private _observers;
  30442. private _eventState;
  30443. private _onObserverAdded;
  30444. /**
  30445. * Creates a new observable
  30446. * @param onObserverAdded defines a callback to call when a new observer is added
  30447. */
  30448. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30449. /**
  30450. * Create a new Observer with the specified callback
  30451. * @param callback the callback that will be executed for that Observer
  30452. * @param mask the mask used to filter observers
  30453. * @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.
  30454. * @param scope optional scope for the callback to be called from
  30455. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30456. * @returns the new observer created for the callback
  30457. */
  30458. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30459. /**
  30460. * Create a new Observer with the specified callback and unregisters after the next notification
  30461. * @param callback the callback that will be executed for that Observer
  30462. * @returns the new observer created for the callback
  30463. */
  30464. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30465. /**
  30466. * Remove an Observer from the Observable object
  30467. * @param observer the instance of the Observer to remove
  30468. * @returns false if it doesn't belong to this Observable
  30469. */
  30470. remove(observer: Nullable<Observer<T>>): boolean;
  30471. /**
  30472. * Remove a callback from the Observable object
  30473. * @param callback the callback to remove
  30474. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30475. * @returns false if it doesn't belong to this Observable
  30476. */
  30477. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30478. private _deferUnregister;
  30479. private _remove;
  30480. /**
  30481. * Notify all Observers by calling their respective callback with the given data
  30482. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30483. * @param eventData defines the data to send to all observers
  30484. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30485. * @param target defines the original target of the state
  30486. * @param currentTarget defines the current target of the state
  30487. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30488. */
  30489. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30490. /**
  30491. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30492. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30493. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30494. * and it is crucial that all callbacks will be executed.
  30495. * The order of the callbacks is kept, callbacks are not executed parallel.
  30496. *
  30497. * @param eventData The data to be sent to each callback
  30498. * @param mask is used to filter observers defaults to -1
  30499. * @param target defines the callback target (see EventState)
  30500. * @param currentTarget defines he current object in the bubbling phase
  30501. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30502. */
  30503. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30504. /**
  30505. * Notify a specific observer
  30506. * @param observer defines the observer to notify
  30507. * @param eventData defines the data to be sent to each callback
  30508. * @param mask is used to filter observers defaults to -1
  30509. */
  30510. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30511. /**
  30512. * Gets a boolean indicating if the observable has at least one observer
  30513. * @returns true is the Observable has at least one Observer registered
  30514. */
  30515. hasObservers(): boolean;
  30516. /**
  30517. * Clear the list of observers
  30518. */
  30519. clear(): void;
  30520. /**
  30521. * Clone the current observable
  30522. * @returns a new observable
  30523. */
  30524. clone(): Observable<T>;
  30525. /**
  30526. * Does this observable handles observer registered with a given mask
  30527. * @param mask defines the mask to be tested
  30528. * @return whether or not one observer registered with the given mask is handeled
  30529. **/
  30530. hasSpecificMask(mask?: number): boolean;
  30531. }
  30532. }
  30533. declare module BABYLON {
  30534. /**
  30535. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30536. */
  30537. class PerformanceMonitor {
  30538. private _enabled;
  30539. private _rollingFrameTime;
  30540. private _lastFrameTimeMs;
  30541. /**
  30542. * constructor
  30543. * @param frameSampleSize The number of samples required to saturate the sliding window
  30544. */
  30545. constructor(frameSampleSize?: number);
  30546. /**
  30547. * Samples current frame
  30548. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30549. */
  30550. sampleFrame(timeMs?: number): void;
  30551. /**
  30552. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30553. * @return Average frame time in milliseconds
  30554. */
  30555. readonly averageFrameTime: number;
  30556. /**
  30557. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30558. * @return Frame time variance in milliseconds squared
  30559. */
  30560. readonly averageFrameTimeVariance: number;
  30561. /**
  30562. * Returns the frame time of the most recent frame
  30563. * @return Frame time in milliseconds
  30564. */
  30565. readonly instantaneousFrameTime: number;
  30566. /**
  30567. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30568. * @return Framerate in frames per second
  30569. */
  30570. readonly averageFPS: number;
  30571. /**
  30572. * Returns the average framerate in frames per second using the most recent frame time
  30573. * @return Framerate in frames per second
  30574. */
  30575. readonly instantaneousFPS: number;
  30576. /**
  30577. * Returns true if enough samples have been taken to completely fill the sliding window
  30578. * @return true if saturated
  30579. */
  30580. readonly isSaturated: boolean;
  30581. /**
  30582. * Enables contributions to the sliding window sample set
  30583. */
  30584. enable(): void;
  30585. /**
  30586. * Disables contributions to the sliding window sample set
  30587. * Samples will not be interpolated over the disabled period
  30588. */
  30589. disable(): void;
  30590. /**
  30591. * Returns true if sampling is enabled
  30592. * @return true if enabled
  30593. */
  30594. readonly isEnabled: boolean;
  30595. /**
  30596. * Resets performance monitor
  30597. */
  30598. reset(): void;
  30599. }
  30600. /**
  30601. * RollingAverage
  30602. *
  30603. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30604. */
  30605. class RollingAverage {
  30606. /**
  30607. * Current average
  30608. */
  30609. average: number;
  30610. /**
  30611. * Current variance
  30612. */
  30613. variance: number;
  30614. protected _samples: Array<number>;
  30615. protected _sampleCount: number;
  30616. protected _pos: number;
  30617. protected _m2: number;
  30618. /**
  30619. * constructor
  30620. * @param length The number of samples required to saturate the sliding window
  30621. */
  30622. constructor(length: number);
  30623. /**
  30624. * Adds a sample to the sample set
  30625. * @param v The sample value
  30626. */
  30627. add(v: number): void;
  30628. /**
  30629. * Returns previously added values or null if outside of history or outside the sliding window domain
  30630. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30631. * @return Value previously recorded with add() or null if outside of range
  30632. */
  30633. history(i: number): number;
  30634. /**
  30635. * Returns true if enough samples have been taken to completely fill the sliding window
  30636. * @return true if sample-set saturated
  30637. */
  30638. isSaturated(): boolean;
  30639. /**
  30640. * Resets the rolling average (equivalent to 0 samples taken so far)
  30641. */
  30642. reset(): void;
  30643. /**
  30644. * Wraps a value around the sample range boundaries
  30645. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30646. * @return Wrapped position in sample range
  30647. */
  30648. protected _wrapPosition(i: number): number;
  30649. }
  30650. }
  30651. declare module BABYLON {
  30652. /**
  30653. * Helper class that provides a small promise polyfill
  30654. */
  30655. class PromisePolyfill {
  30656. /**
  30657. * Static function used to check if the polyfill is required
  30658. * If this is the case then the function will inject the polyfill to window.Promise
  30659. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30660. */
  30661. static Apply(force?: boolean): void;
  30662. }
  30663. }
  30664. declare module BABYLON {
  30665. /**
  30666. * Defines the root class used to create scene optimization to use with SceneOptimizer
  30667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30668. */
  30669. class SceneOptimization {
  30670. /**
  30671. * Defines the priority of this optimization (0 by default which means first in the list)
  30672. */
  30673. priority: number;
  30674. /**
  30675. * Gets a string describing the action executed by the current optimization
  30676. * @returns description string
  30677. */
  30678. getDescription(): string;
  30679. /**
  30680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30681. * @param scene defines the current scene where to apply this optimization
  30682. * @param optimizer defines the current optimizer
  30683. * @returns true if everything that can be done was applied
  30684. */
  30685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30686. /**
  30687. * Creates the SceneOptimization object
  30688. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30689. * @param desc defines the description associated with the optimization
  30690. */
  30691. constructor(
  30692. /**
  30693. * Defines the priority of this optimization (0 by default which means first in the list)
  30694. */
  30695. priority?: number);
  30696. }
  30697. /**
  30698. * Defines an optimization used to reduce the size of render target textures
  30699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30700. */
  30701. class TextureOptimization extends SceneOptimization {
  30702. /**
  30703. * Defines the priority of this optimization (0 by default which means first in the list)
  30704. */
  30705. priority: number;
  30706. /**
  30707. * 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
  30708. */
  30709. maximumSize: number;
  30710. /**
  30711. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30712. */
  30713. step: number;
  30714. /**
  30715. * Gets a string describing the action executed by the current optimization
  30716. * @returns description string
  30717. */
  30718. getDescription(): string;
  30719. /**
  30720. * Creates the TextureOptimization object
  30721. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30722. * @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
  30723. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30724. */
  30725. constructor(
  30726. /**
  30727. * Defines the priority of this optimization (0 by default which means first in the list)
  30728. */
  30729. priority?: number,
  30730. /**
  30731. * 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
  30732. */
  30733. maximumSize?: number,
  30734. /**
  30735. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30736. */
  30737. step?: number);
  30738. /**
  30739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30740. * @param scene defines the current scene where to apply this optimization
  30741. * @param optimizer defines the current optimizer
  30742. * @returns true if everything that can be done was applied
  30743. */
  30744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30745. }
  30746. /**
  30747. * Defines an optimization used to increase or decrease the rendering resolution
  30748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30749. */
  30750. class HardwareScalingOptimization extends SceneOptimization {
  30751. /**
  30752. * Defines the priority of this optimization (0 by default which means first in the list)
  30753. */
  30754. priority: number;
  30755. /**
  30756. * Defines the maximum scale to use (2 by default)
  30757. */
  30758. maximumScale: number;
  30759. /**
  30760. * Defines the step to use between two passes (0.5 by default)
  30761. */
  30762. step: number;
  30763. private _currentScale;
  30764. private _directionOffset;
  30765. /**
  30766. * Gets a string describing the action executed by the current optimization
  30767. * @return description string
  30768. */
  30769. getDescription(): string;
  30770. /**
  30771. * Creates the HardwareScalingOptimization object
  30772. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30773. * @param maximumScale defines the maximum scale to use (2 by default)
  30774. * @param step defines the step to use between two passes (0.5 by default)
  30775. */
  30776. constructor(
  30777. /**
  30778. * Defines the priority of this optimization (0 by default which means first in the list)
  30779. */
  30780. priority?: number,
  30781. /**
  30782. * Defines the maximum scale to use (2 by default)
  30783. */
  30784. maximumScale?: number,
  30785. /**
  30786. * Defines the step to use between two passes (0.5 by default)
  30787. */
  30788. step?: number);
  30789. /**
  30790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30791. * @param scene defines the current scene where to apply this optimization
  30792. * @param optimizer defines the current optimizer
  30793. * @returns true if everything that can be done was applied
  30794. */
  30795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30796. }
  30797. /**
  30798. * Defines an optimization used to remove shadows
  30799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30800. */
  30801. class ShadowsOptimization extends SceneOptimization {
  30802. /**
  30803. * Gets a string describing the action executed by the current optimization
  30804. * @return description string
  30805. */
  30806. getDescription(): string;
  30807. /**
  30808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30809. * @param scene defines the current scene where to apply this optimization
  30810. * @param optimizer defines the current optimizer
  30811. * @returns true if everything that can be done was applied
  30812. */
  30813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30814. }
  30815. /**
  30816. * Defines an optimization used to turn post-processes off
  30817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30818. */
  30819. class PostProcessesOptimization extends SceneOptimization {
  30820. /**
  30821. * Gets a string describing the action executed by the current optimization
  30822. * @return description string
  30823. */
  30824. getDescription(): string;
  30825. /**
  30826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30827. * @param scene defines the current scene where to apply this optimization
  30828. * @param optimizer defines the current optimizer
  30829. * @returns true if everything that can be done was applied
  30830. */
  30831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30832. }
  30833. /**
  30834. * Defines an optimization used to turn lens flares off
  30835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30836. */
  30837. class LensFlaresOptimization extends SceneOptimization {
  30838. /**
  30839. * Gets a string describing the action executed by the current optimization
  30840. * @return description string
  30841. */
  30842. getDescription(): string;
  30843. /**
  30844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30845. * @param scene defines the current scene where to apply this optimization
  30846. * @param optimizer defines the current optimizer
  30847. * @returns true if everything that can be done was applied
  30848. */
  30849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30850. }
  30851. /**
  30852. * Defines an optimization based on user defined callback.
  30853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30854. */
  30855. class CustomOptimization extends SceneOptimization {
  30856. /**
  30857. * Callback called to apply the custom optimization.
  30858. */
  30859. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  30860. /**
  30861. * Callback called to get custom description
  30862. */
  30863. onGetDescription: () => string;
  30864. /**
  30865. * Gets a string describing the action executed by the current optimization
  30866. * @returns description string
  30867. */
  30868. getDescription(): string;
  30869. /**
  30870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30871. * @param scene defines the current scene where to apply this optimization
  30872. * @param optimizer defines the current optimizer
  30873. * @returns true if everything that can be done was applied
  30874. */
  30875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30876. }
  30877. /**
  30878. * Defines an optimization used to turn particles off
  30879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30880. */
  30881. class ParticlesOptimization extends SceneOptimization {
  30882. /**
  30883. * Gets a string describing the action executed by the current optimization
  30884. * @return description string
  30885. */
  30886. getDescription(): string;
  30887. /**
  30888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30889. * @param scene defines the current scene where to apply this optimization
  30890. * @param optimizer defines the current optimizer
  30891. * @returns true if everything that can be done was applied
  30892. */
  30893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30894. }
  30895. /**
  30896. * Defines an optimization used to turn render targets off
  30897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30898. */
  30899. class RenderTargetsOptimization extends SceneOptimization {
  30900. /**
  30901. * Gets a string describing the action executed by the current optimization
  30902. * @return description string
  30903. */
  30904. getDescription(): string;
  30905. /**
  30906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30907. * @param scene defines the current scene where to apply this optimization
  30908. * @param optimizer defines the current optimizer
  30909. * @returns true if everything that can be done was applied
  30910. */
  30911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30912. }
  30913. /**
  30914. * Defines an optimization used to merge meshes with compatible materials
  30915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30916. */
  30917. class MergeMeshesOptimization extends SceneOptimization {
  30918. private static _UpdateSelectionTree;
  30919. /**
  30920. * Gets or sets a boolean which defines if optimization octree has to be updated
  30921. */
  30922. /**
  30923. * Gets or sets a boolean which defines if optimization octree has to be updated
  30924. */
  30925. static UpdateSelectionTree: boolean;
  30926. /**
  30927. * Gets a string describing the action executed by the current optimization
  30928. * @return description string
  30929. */
  30930. getDescription(): string;
  30931. private _canBeMerged;
  30932. /**
  30933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30934. * @param scene defines the current scene where to apply this optimization
  30935. * @param optimizer defines the current optimizer
  30936. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  30937. * @returns true if everything that can be done was applied
  30938. */
  30939. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  30940. }
  30941. /**
  30942. * Defines a list of options used by SceneOptimizer
  30943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30944. */
  30945. class SceneOptimizerOptions {
  30946. /**
  30947. * Defines the target frame rate to reach (60 by default)
  30948. */
  30949. targetFrameRate: number;
  30950. /**
  30951. * Defines the interval between two checkes (2000ms by default)
  30952. */
  30953. trackerDuration: number;
  30954. /**
  30955. * Gets the list of optimizations to apply
  30956. */
  30957. optimizations: SceneOptimization[];
  30958. /**
  30959. * Creates a new list of options used by SceneOptimizer
  30960. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  30961. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  30962. */
  30963. constructor(
  30964. /**
  30965. * Defines the target frame rate to reach (60 by default)
  30966. */
  30967. targetFrameRate?: number,
  30968. /**
  30969. * Defines the interval between two checkes (2000ms by default)
  30970. */
  30971. trackerDuration?: number);
  30972. /**
  30973. * Add a new optimization
  30974. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30975. * @returns the current SceneOptimizerOptions
  30976. */
  30977. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30978. /**
  30979. * Add a new custom optimization
  30980. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30981. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30983. * @returns the current SceneOptimizerOptions
  30984. */
  30985. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30986. /**
  30987. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30988. * @param targetFrameRate defines the target frame rate (60 by default)
  30989. * @returns a SceneOptimizerOptions object
  30990. */
  30991. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30992. /**
  30993. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30994. * @param targetFrameRate defines the target frame rate (60 by default)
  30995. * @returns a SceneOptimizerOptions object
  30996. */
  30997. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30998. /**
  30999. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31000. * @param targetFrameRate defines the target frame rate (60 by default)
  31001. * @returns a SceneOptimizerOptions object
  31002. */
  31003. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31004. }
  31005. /**
  31006. * Class used to run optimizations in order to reach a target frame rate
  31007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31008. */
  31009. class SceneOptimizer implements IDisposable {
  31010. private _isRunning;
  31011. private _options;
  31012. private _scene;
  31013. private _currentPriorityLevel;
  31014. private _targetFrameRate;
  31015. private _trackerDuration;
  31016. private _currentFrameRate;
  31017. private _sceneDisposeObserver;
  31018. private _improvementMode;
  31019. /**
  31020. * Defines an observable called when the optimizer reaches the target frame rate
  31021. */
  31022. onSuccessObservable: Observable<SceneOptimizer>;
  31023. /**
  31024. * Defines an observable called when the optimizer enables an optimization
  31025. */
  31026. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31027. /**
  31028. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31029. */
  31030. onFailureObservable: Observable<SceneOptimizer>;
  31031. /**
  31032. * Gets a boolean indicating if the optimizer is in improvement mode
  31033. */
  31034. readonly isInImprovementMode: boolean;
  31035. /**
  31036. * Gets the current priority level (0 at start)
  31037. */
  31038. readonly currentPriorityLevel: number;
  31039. /**
  31040. * Gets the current frame rate checked by the SceneOptimizer
  31041. */
  31042. readonly currentFrameRate: number;
  31043. /**
  31044. * Gets or sets the current target frame rate (60 by default)
  31045. */
  31046. /**
  31047. * Gets or sets the current target frame rate (60 by default)
  31048. */
  31049. targetFrameRate: number;
  31050. /**
  31051. * Gets or sets the current interval between two checks (every 2000ms by default)
  31052. */
  31053. /**
  31054. * Gets or sets the current interval between two checks (every 2000ms by default)
  31055. */
  31056. trackerDuration: number;
  31057. /**
  31058. * Gets the list of active optimizations
  31059. */
  31060. readonly optimizations: SceneOptimization[];
  31061. /**
  31062. * Creates a new SceneOptimizer
  31063. * @param scene defines the scene to work on
  31064. * @param options defines the options to use with the SceneOptimizer
  31065. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31066. * @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)
  31067. */
  31068. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31069. /**
  31070. * Stops the current optimizer
  31071. */
  31072. stop(): void;
  31073. /**
  31074. * Reset the optimizer to initial step (current priority level = 0)
  31075. */
  31076. reset(): void;
  31077. /**
  31078. * Start the optimizer. By default it will try to reach a specific framerate
  31079. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31080. */
  31081. start(): void;
  31082. private _checkCurrentState;
  31083. /**
  31084. * Release all resources
  31085. */
  31086. dispose(): void;
  31087. /**
  31088. * Helper function to create a SceneOptimizer with one single line of code
  31089. * @param scene defines the scene to work on
  31090. * @param options defines the options to use with the SceneOptimizer
  31091. * @param onSuccess defines a callback to call on success
  31092. * @param onFailure defines a callback to call on failure
  31093. * @returns the new SceneOptimizer object
  31094. */
  31095. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31096. }
  31097. }
  31098. declare module BABYLON {
  31099. class SceneSerializer {
  31100. static ClearCache(): void;
  31101. static Serialize(scene: Scene): any;
  31102. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31103. }
  31104. }
  31105. declare module BABYLON {
  31106. /**
  31107. * Defines an array and its length.
  31108. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  31109. */
  31110. interface ISmartArrayLike<T> {
  31111. /**
  31112. * The data of the array.
  31113. */
  31114. data: Array<T>;
  31115. /**
  31116. * The active length of the array.
  31117. */
  31118. length: number;
  31119. }
  31120. /**
  31121. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31122. */
  31123. class SmartArray<T> implements ISmartArrayLike<T> {
  31124. /**
  31125. * The full set of data from the array.
  31126. */
  31127. data: Array<T>;
  31128. /**
  31129. * The active length of the array.
  31130. */
  31131. length: number;
  31132. protected _id: number;
  31133. /**
  31134. * Instantiates a Smart Array.
  31135. * @param capacity defines the default capacity of the array.
  31136. */
  31137. constructor(capacity: number);
  31138. /**
  31139. * Pushes a value at the end of the active data.
  31140. * @param value defines the object to push in the array.
  31141. */
  31142. push(value: T): void;
  31143. /**
  31144. * Iterates over the active data and apply the lambda to them.
  31145. * @param func defines the action to apply on each value.
  31146. */
  31147. forEach(func: (content: T) => void): void;
  31148. /**
  31149. * Sorts the full sets of data.
  31150. * @param compareFn defines the comparison function to apply.
  31151. */
  31152. sort(compareFn: (a: T, b: T) => number): void;
  31153. /**
  31154. * Resets the active data to an empty array.
  31155. */
  31156. reset(): void;
  31157. /**
  31158. * Releases all the data from the array as well as the array.
  31159. */
  31160. dispose(): void;
  31161. /**
  31162. * Concats the active data with a given array.
  31163. * @param array defines the data to concatenate with.
  31164. */
  31165. concat(array: any): void;
  31166. /**
  31167. * Returns the position of a value in the active data.
  31168. * @param value defines the value to find the index for
  31169. * @returns the index if found in the active data otherwise -1
  31170. */
  31171. indexOf(value: T): number;
  31172. /**
  31173. * Returns whether an element is part of the active data.
  31174. * @param value defines the value to look for
  31175. * @returns true if found in the active data otherwise false
  31176. */
  31177. contains(value: T): boolean;
  31178. private static _GlobalId;
  31179. }
  31180. /**
  31181. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31182. * The data in this array can only be present once
  31183. */
  31184. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31185. private _duplicateId;
  31186. /**
  31187. * Pushes a value at the end of the active data.
  31188. * THIS DOES NOT PREVENT DUPPLICATE DATA
  31189. * @param value defines the object to push in the array.
  31190. */
  31191. push(value: T): void;
  31192. /**
  31193. * Pushes a value at the end of the active data.
  31194. * If the data is already present, it won t be added again
  31195. * @param value defines the object to push in the array.
  31196. * @returns true if added false if it was already present
  31197. */
  31198. pushNoDuplicate(value: T): boolean;
  31199. /**
  31200. * Resets the active data to an empty array.
  31201. */
  31202. reset(): void;
  31203. /**
  31204. * Concats the active data with a given array.
  31205. * This ensures no dupplicate will be present in the result.
  31206. * @param array defines the data to concatenate with.
  31207. */
  31208. concatWithNoDuplicate(array: any): void;
  31209. }
  31210. }
  31211. declare module BABYLON {
  31212. /**
  31213. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31214. * The underlying implementation relies on an associative array to ensure the best performances.
  31215. * The value can be anything including 'null' but except 'undefined'
  31216. */
  31217. class StringDictionary<T> {
  31218. /**
  31219. * This will clear this dictionary and copy the content from the 'source' one.
  31220. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31221. * @param source the dictionary to take the content from and copy to this dictionary
  31222. */
  31223. copyFrom(source: StringDictionary<T>): void;
  31224. /**
  31225. * Get a value based from its key
  31226. * @param key the given key to get the matching value from
  31227. * @return the value if found, otherwise undefined is returned
  31228. */
  31229. get(key: string): T | undefined;
  31230. /**
  31231. * Get a value from its key or add it if it doesn't exist.
  31232. * This method will ensure you that a given key/data will be present in the dictionary.
  31233. * @param key the given key to get the matching value from
  31234. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31235. * The factory will only be invoked if there's no data for the given key.
  31236. * @return the value corresponding to the key.
  31237. */
  31238. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31239. /**
  31240. * Get a value from its key if present in the dictionary otherwise add it
  31241. * @param key the key to get the value from
  31242. * @param val if there's no such key/value pair in the dictionary add it with this value
  31243. * @return the value corresponding to the key
  31244. */
  31245. getOrAdd(key: string, val: T): T;
  31246. /**
  31247. * Check if there's a given key in the dictionary
  31248. * @param key the key to check for
  31249. * @return true if the key is present, false otherwise
  31250. */
  31251. contains(key: string): boolean;
  31252. /**
  31253. * Add a new key and its corresponding value
  31254. * @param key the key to add
  31255. * @param value the value corresponding to the key
  31256. * @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
  31257. */
  31258. add(key: string, value: T): boolean;
  31259. set(key: string, value: T): boolean;
  31260. /**
  31261. * Get the element of the given key and remove it from the dictionary
  31262. * @param key
  31263. */
  31264. getAndRemove(key: string): Nullable<T>;
  31265. /**
  31266. * Remove a key/value from the dictionary.
  31267. * @param key the key to remove
  31268. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31269. */
  31270. remove(key: string): boolean;
  31271. /**
  31272. * Clear the whole content of the dictionary
  31273. */
  31274. clear(): void;
  31275. readonly count: number;
  31276. /**
  31277. * Execute a callback on each key/val of the dictionary.
  31278. * Note that you can remove any element in this dictionary in the callback implementation
  31279. * @param callback the callback to execute on a given key/value pair
  31280. */
  31281. forEach(callback: (key: string, val: T) => void): void;
  31282. /**
  31283. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31284. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31285. * Note that you can remove any element in this dictionary in the callback implementation
  31286. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31287. */
  31288. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31289. private _count;
  31290. private _data;
  31291. }
  31292. }
  31293. declare module BABYLON {
  31294. class Tags {
  31295. static EnableFor(obj: any): void;
  31296. static DisableFor(obj: any): void;
  31297. static HasTags(obj: any): boolean;
  31298. static GetTags(obj: any, asString?: boolean): any;
  31299. static AddTagsTo(obj: any, tagsString: string): void;
  31300. private static _AddTagTo(obj: any, tag: string): void;
  31301. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31302. private static _RemoveTagFrom(obj: any, tag: string): void;
  31303. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31304. }
  31305. }
  31306. declare module BABYLON {
  31307. class TextureTools {
  31308. /**
  31309. * Uses the GPU to create a copy texture rescaled at a given size
  31310. * @param texture Texture to copy from
  31311. * @param width Desired width
  31312. * @param height Desired height
  31313. * @return Generated texture
  31314. */
  31315. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31316. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31317. private static _environmentBRDFBase64Texture;
  31318. }
  31319. }
  31320. declare module BABYLON {
  31321. class TGATools {
  31322. private static _TYPE_INDEXED;
  31323. private static _TYPE_RGB;
  31324. private static _TYPE_GREY;
  31325. private static _TYPE_RLE_INDEXED;
  31326. private static _TYPE_RLE_RGB;
  31327. private static _TYPE_RLE_GREY;
  31328. private static _ORIGIN_MASK;
  31329. private static _ORIGIN_SHIFT;
  31330. private static _ORIGIN_BL;
  31331. private static _ORIGIN_BR;
  31332. private static _ORIGIN_UL;
  31333. private static _ORIGIN_UR;
  31334. static GetTGAHeader(data: Uint8Array): any;
  31335. /**
  31336. * Uploads TGA content to a Babylon Texture
  31337. * @hidden
  31338. */
  31339. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31340. 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;
  31341. 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;
  31342. 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;
  31343. 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;
  31344. 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;
  31345. 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;
  31346. }
  31347. }
  31348. declare module BABYLON {
  31349. interface IAnimatable {
  31350. animations: Array<Animation>;
  31351. }
  31352. /** Interface used by value gradients (color, factor, ...) */
  31353. interface IValueGradient {
  31354. /**
  31355. * Gets or sets the gradient value (between 0 and 1)
  31356. */
  31357. gradient: number;
  31358. }
  31359. /** Class used to store color gradient */
  31360. class ColorGradient implements IValueGradient {
  31361. /**
  31362. * Gets or sets the gradient value (between 0 and 1)
  31363. */
  31364. gradient: number;
  31365. /**
  31366. * Gets or sets first associated color
  31367. */
  31368. color1: Color4;
  31369. /**
  31370. * Gets or sets second associated color
  31371. */
  31372. color2?: Color4;
  31373. /**
  31374. * Will get a color picked randomly between color1 and color2.
  31375. * If color2 is undefined then color1 will be used
  31376. * @param result defines the target Color4 to store the result in
  31377. */
  31378. getColorToRef(result: Color4): void;
  31379. }
  31380. /** Class used to store factor gradient */
  31381. class FactorGradient implements IValueGradient {
  31382. /**
  31383. * Gets or sets the gradient value (between 0 and 1)
  31384. */
  31385. gradient: number;
  31386. /**
  31387. * Gets or sets first associated factor
  31388. */
  31389. factor1: number;
  31390. /**
  31391. * Gets or sets second associated factor
  31392. */
  31393. factor2?: number;
  31394. /**
  31395. * Will get a number picked randomly between factor1 and factor2.
  31396. * If factor2 is undefined then factor1 will be used
  31397. * @returns the picked number
  31398. */
  31399. getFactor(): number;
  31400. }
  31401. class LoadFileError extends Error {
  31402. request?: XMLHttpRequest | undefined;
  31403. private static _setPrototypeOf;
  31404. constructor(message: string, request?: XMLHttpRequest | undefined);
  31405. }
  31406. class RetryStrategy {
  31407. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31408. }
  31409. interface IFileRequest {
  31410. /**
  31411. * Raised when the request is complete (success or error).
  31412. */
  31413. onCompleteObservable: Observable<IFileRequest>;
  31414. /**
  31415. * Aborts the request for a file.
  31416. */
  31417. abort: () => void;
  31418. }
  31419. class Tools {
  31420. static BaseUrl: string;
  31421. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31422. /**
  31423. * Default behaviour for cors in the application.
  31424. * It can be a string if the expected behavior is identical in the entire app.
  31425. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31426. */
  31427. static CorsBehavior: string | ((url: string | string[]) => string);
  31428. static UseFallbackTexture: boolean;
  31429. /**
  31430. * Use this object to register external classes like custom textures or material
  31431. * to allow the laoders to instantiate them
  31432. */
  31433. static RegisteredExternalClasses: {
  31434. [key: string]: Object;
  31435. };
  31436. static fallbackTexture: string;
  31437. /**
  31438. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31439. * @param u defines the coordinate on X axis
  31440. * @param v defines the coordinate on Y axis
  31441. * @param width defines the width of the source data
  31442. * @param height defines the height of the source data
  31443. * @param pixels defines the source byte array
  31444. * @param color defines the output color
  31445. */
  31446. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31447. /**
  31448. * Interpolates between a and b via alpha
  31449. * @param a The lower value (returned when alpha = 0)
  31450. * @param b The upper value (returned when alpha = 1)
  31451. * @param alpha The interpolation-factor
  31452. * @return The mixed value
  31453. */
  31454. static Mix(a: number, b: number, alpha: number): number;
  31455. static Instantiate(className: string): any;
  31456. /**
  31457. * Provides a slice function that will work even on IE
  31458. * @param data defines the array to slice
  31459. * @param start defines the start of the data (optional)
  31460. * @param end defines the end of the data (optional)
  31461. * @returns the new sliced array
  31462. */
  31463. static Slice<T>(data: T, start?: number, end?: number): T;
  31464. static SetImmediate(action: () => void): void;
  31465. static IsExponentOfTwo(value: number): boolean;
  31466. private static _tmpFloatArray;
  31467. /**
  31468. * Returns the nearest 32-bit single precision float representation of a Number
  31469. * @param value A Number. If the parameter is of a different type, it will get converted
  31470. * to a number or to NaN if it cannot be converted
  31471. * @returns number
  31472. */
  31473. static FloatRound(value: number): number;
  31474. /**
  31475. * Find the next highest power of two.
  31476. * @param x Number to start search from.
  31477. * @return Next highest power of two.
  31478. */
  31479. static CeilingPOT(x: number): number;
  31480. /**
  31481. * Find the next lowest power of two.
  31482. * @param x Number to start search from.
  31483. * @return Next lowest power of two.
  31484. */
  31485. static FloorPOT(x: number): number;
  31486. /**
  31487. * Find the nearest power of two.
  31488. * @param x Number to start search from.
  31489. * @return Next nearest power of two.
  31490. */
  31491. static NearestPOT(x: number): number;
  31492. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31493. static GetFilename(path: string): string;
  31494. /**
  31495. * Extracts the "folder" part of a path (everything before the filename).
  31496. * @param uri The URI to extract the info from
  31497. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31498. * @returns The "folder" part of the path
  31499. */
  31500. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31501. static GetDOMTextContent(element: HTMLElement): string;
  31502. static ToDegrees(angle: number): number;
  31503. static ToRadians(angle: number): number;
  31504. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31505. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31506. minimum: Vector3;
  31507. maximum: Vector3;
  31508. };
  31509. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31510. minimum: Vector3;
  31511. maximum: Vector3;
  31512. };
  31513. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31514. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31515. minimum: Vector2;
  31516. maximum: Vector2;
  31517. };
  31518. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31519. static GetPointerPrefix(): string;
  31520. /**
  31521. * @param func - the function to be called
  31522. * @param requester - the object that will request the next frame. Falls back to window.
  31523. */
  31524. static QueueNewFrame(func: () => void, requester?: any): number;
  31525. static RequestFullscreen(element: HTMLElement): void;
  31526. static ExitFullscreen(): void;
  31527. static SetCorsBehavior(url: string | string[], element: {
  31528. crossOrigin: string | null;
  31529. }): void;
  31530. static CleanUrl(url: string): string;
  31531. static PreprocessUrl: (url: string) => string;
  31532. /**
  31533. * Loads an image as an HTMLImageElement.
  31534. * @param input url string, ArrayBuffer, or Blob to load
  31535. * @param onLoad callback called when the image successfully loads
  31536. * @param onError callback called when the image fails to load
  31537. * @param database database for caching
  31538. * @returns the HTMLImageElement of the loaded image
  31539. */
  31540. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31541. 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;
  31542. /**
  31543. * Load a script (identified by an url). When the url returns, the
  31544. * content of this file is added into a new script element, attached to the DOM (body element)
  31545. */
  31546. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31547. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31548. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31549. static FileAsURL(content: string): string;
  31550. static Format(value: number, decimals?: number): string;
  31551. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31552. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31553. static IsEmpty(obj: any): boolean;
  31554. static RegisterTopRootEvents(events: {
  31555. name: string;
  31556. handler: Nullable<(e: FocusEvent) => any>;
  31557. }[]): void;
  31558. static UnregisterTopRootEvents(events: {
  31559. name: string;
  31560. handler: Nullable<(e: FocusEvent) => any>;
  31561. }[]): void;
  31562. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31563. /**
  31564. * Converts the canvas data to blob.
  31565. * This acts as a polyfill for browsers not supporting the to blob function.
  31566. * @param canvas Defines the canvas to extract the data from
  31567. * @param successCallback Defines the callback triggered once the data are available
  31568. * @param mimeType Defines the mime type of the result
  31569. */
  31570. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31571. /**
  31572. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31573. * @param successCallback Defines the callback triggered once the data are available
  31574. * @param mimeType Defines the mime type of the result
  31575. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31576. */
  31577. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31578. /**
  31579. * Downloads a blob in the browser
  31580. * @param blob defines the blob to download
  31581. * @param fileName defines the name of the downloaded file
  31582. */
  31583. static Download(blob: Blob, fileName: string): void;
  31584. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31585. /**
  31586. * Generates an image screenshot from the specified camera.
  31587. *
  31588. * @param engine The engine to use for rendering
  31589. * @param camera The camera to use for rendering
  31590. * @param size This parameter can be set to a single number or to an object with the
  31591. * following (optional) properties: precision, width, height. If a single number is passed,
  31592. * it will be used for both width and height. If an object is passed, the screenshot size
  31593. * will be derived from the parameters. The precision property is a multiplier allowing
  31594. * rendering at a higher or lower resolution.
  31595. * @param successCallback The callback receives a single parameter which contains the
  31596. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31597. * src parameter of an <img> to display it.
  31598. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31599. * Check your browser for supported MIME types.
  31600. * @param samples Texture samples (default: 1)
  31601. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31602. * @param fileName A name for for the downloaded file.
  31603. * @constructor
  31604. */
  31605. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31606. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  31607. /**
  31608. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31609. * Be aware Math.random() could cause collisions, but:
  31610. * "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"
  31611. */
  31612. static RandomId(): string;
  31613. /**
  31614. * Test if the given uri is a base64 string.
  31615. * @param uri The uri to test
  31616. * @return True if the uri is a base64 string or false otherwise.
  31617. */
  31618. static IsBase64(uri: string): boolean;
  31619. /**
  31620. * Decode the given base64 uri.
  31621. * @param uri The uri to decode
  31622. * @return The decoded base64 data.
  31623. */
  31624. static DecodeBase64(uri: string): ArrayBuffer;
  31625. private static _NoneLogLevel;
  31626. private static _MessageLogLevel;
  31627. private static _WarningLogLevel;
  31628. private static _ErrorLogLevel;
  31629. private static _LogCache;
  31630. static errorsCount: number;
  31631. static OnNewCacheEntry: (entry: string) => void;
  31632. static readonly NoneLogLevel: number;
  31633. static readonly MessageLogLevel: number;
  31634. static readonly WarningLogLevel: number;
  31635. static readonly ErrorLogLevel: number;
  31636. static readonly AllLogLevel: number;
  31637. private static _AddLogEntry;
  31638. private static _FormatMessage;
  31639. private static _LogDisabled;
  31640. private static _LogEnabled;
  31641. private static _WarnDisabled;
  31642. private static _WarnEnabled;
  31643. private static _ErrorDisabled;
  31644. private static _ErrorEnabled;
  31645. static Log: (message: string) => void;
  31646. static Warn: (message: string) => void;
  31647. static Error: (message: string) => void;
  31648. static readonly LogCache: string;
  31649. static ClearLogCache(): void;
  31650. static LogLevels: number;
  31651. /**
  31652. * Check if the loaded document was accessed via `file:`-Protocol.
  31653. * @returns boolean
  31654. */
  31655. static IsFileURL(): boolean;
  31656. static IsWindowObjectExist(): boolean;
  31657. private static _PerformanceNoneLogLevel;
  31658. private static _PerformanceUserMarkLogLevel;
  31659. private static _PerformanceConsoleLogLevel;
  31660. private static _performance;
  31661. static readonly PerformanceNoneLogLevel: number;
  31662. static readonly PerformanceUserMarkLogLevel: number;
  31663. static readonly PerformanceConsoleLogLevel: number;
  31664. static PerformanceLogLevel: number;
  31665. private static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31666. private static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31667. private static _StartUserMark(counterName: string, condition?: boolean): void;
  31668. private static _EndUserMark(counterName: string, condition?: boolean): void;
  31669. private static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  31670. private static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  31671. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31672. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31673. static readonly Now: number;
  31674. /**
  31675. * This method will return the name of the class used to create the instance of the given object.
  31676. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31677. * @param object the object to get the class name from
  31678. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  31679. */
  31680. static GetClassName(object: any, isType?: boolean): string;
  31681. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31682. /**
  31683. * This method will return the name of the full name of the class, including its owning module (if any).
  31684. * 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).
  31685. * @param object the object to get the class name from
  31686. * @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.
  31687. */
  31688. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31689. /**
  31690. * 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.
  31691. * @param array
  31692. */
  31693. static arrayOrStringFeeder(array: any): (i: number) => number;
  31694. /**
  31695. * Compute the hashCode of a stream of number
  31696. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  31697. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  31698. * @return the hash code computed
  31699. */
  31700. static hashCodeFromStream(feeder: (index: number) => number): number;
  31701. /**
  31702. * Returns a promise that resolves after the given amount of time.
  31703. * @param delay Number of milliseconds to delay
  31704. * @returns Promise that resolves after the given amount of time
  31705. */
  31706. static DelayAsync(delay: number): Promise<void>;
  31707. /**
  31708. * Gets the current gradient from an array of IValueGradient
  31709. * @param ratio defines the current ratio to get
  31710. * @param gradients defines the array of IValueGradient
  31711. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31712. */
  31713. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31714. }
  31715. /**
  31716. * This class is used to track a performance counter which is number based.
  31717. * The user has access to many properties which give statistics of different nature
  31718. *
  31719. * The implementer can track two kinds of Performance Counter: time and count
  31720. * 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.
  31721. * 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.
  31722. */
  31723. class PerfCounter {
  31724. static Enabled: boolean;
  31725. /**
  31726. * Returns the smallest value ever
  31727. */
  31728. readonly min: number;
  31729. /**
  31730. * Returns the biggest value ever
  31731. */
  31732. readonly max: number;
  31733. /**
  31734. * Returns the average value since the performance counter is running
  31735. */
  31736. readonly average: number;
  31737. /**
  31738. * Returns the average value of the last second the counter was monitored
  31739. */
  31740. readonly lastSecAverage: number;
  31741. /**
  31742. * Returns the current value
  31743. */
  31744. readonly current: number;
  31745. readonly total: number;
  31746. readonly count: number;
  31747. constructor();
  31748. /**
  31749. * Call this method to start monitoring a new frame.
  31750. * 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.
  31751. */
  31752. fetchNewFrame(): void;
  31753. /**
  31754. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31755. * @param newCount the count value to add to the monitored count
  31756. * @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.
  31757. */
  31758. addCount(newCount: number, fetchResult: boolean): void;
  31759. /**
  31760. * Start monitoring this performance counter
  31761. */
  31762. beginMonitoring(): void;
  31763. /**
  31764. * Compute the time lapsed since the previous beginMonitoring() call.
  31765. * @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
  31766. */
  31767. endMonitoring(newFrame?: boolean): void;
  31768. private _fetchResult;
  31769. private _startMonitoringTime;
  31770. private _min;
  31771. private _max;
  31772. private _average;
  31773. private _current;
  31774. private _totalValueCount;
  31775. private _totalAccumulated;
  31776. private _lastSecAverage;
  31777. private _lastSecAccumulated;
  31778. private _lastSecTime;
  31779. private _lastSecValueCount;
  31780. }
  31781. /**
  31782. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31783. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31784. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31785. * @param name The name of the class, case should be preserved
  31786. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31787. */
  31788. function className(name: string, module?: string): (target: Object) => void;
  31789. /**
  31790. * An implementation of a loop for asynchronous functions.
  31791. */
  31792. class AsyncLoop {
  31793. iterations: number;
  31794. private _fn;
  31795. private _successCallback;
  31796. index: number;
  31797. private _done;
  31798. /**
  31799. * Constroctor.
  31800. * @param iterations the number of iterations.
  31801. * @param _fn the function to run each iteration
  31802. * @param _successCallback the callback that will be called upon succesful execution
  31803. * @param offset starting offset.
  31804. */
  31805. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  31806. /**
  31807. * Execute the next iteration. Must be called after the last iteration was finished.
  31808. */
  31809. executeNext(): void;
  31810. /**
  31811. * Break the loop and run the success callback.
  31812. */
  31813. breakLoop(): void;
  31814. /**
  31815. * Helper function
  31816. */
  31817. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  31818. /**
  31819. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31820. * @param iterations total number of iterations
  31821. * @param syncedIterations number of synchronous iterations in each async iteration.
  31822. * @param fn the function to call each iteration.
  31823. * @param callback a success call back that will be called when iterating stops.
  31824. * @param breakFunction a break condition (optional)
  31825. * @param timeout timeout settings for the setTimeout function. default - 0.
  31826. * @constructor
  31827. */
  31828. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  31829. }
  31830. }
  31831. interface HTMLCanvasElement {
  31832. /** Track wether a record is in progress */
  31833. isRecording: boolean;
  31834. /** Capture Stream method defined by some browsers */
  31835. captureStream(fps?: number): MediaStream;
  31836. }
  31837. interface MediaRecorder {
  31838. /** Starts recording */
  31839. start(timeSlice: number): void;
  31840. /** Stops recording */
  31841. stop(): void;
  31842. /** Event raised when an error arised. */
  31843. onerror: (event: ErrorEvent) => void;
  31844. /** Event raised when the recording stops. */
  31845. onstop: (event: Event) => void;
  31846. /** Event raised when a new chunk of data is available and should be tracked. */
  31847. ondataavailable: (event: Event) => void;
  31848. }
  31849. interface MediaRecorderOptions {
  31850. /** The mime type you want to use as the recording container for the new MediaRecorder */
  31851. mimeType?: string;
  31852. /** The chosen bitrate for the audio component of the media. */
  31853. audioBitsPerSecond?: number;
  31854. /** The chosen bitrate for the video component of the media. */
  31855. videoBitsPerSecond?: number;
  31856. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  31857. bitsPerSecond?: number;
  31858. }
  31859. interface MediaRecorderConstructor {
  31860. /**
  31861. * A reference to the prototype.
  31862. */
  31863. readonly prototype: MediaRecorder;
  31864. /**
  31865. * Creates a new MediaRecorder.
  31866. * @param stream Defines the stream to record.
  31867. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  31868. */
  31869. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  31870. }
  31871. /**
  31872. * MediaRecoreder object available in some browsers.
  31873. */
  31874. declare var MediaRecorder: MediaRecorderConstructor;
  31875. declare module BABYLON {
  31876. /**
  31877. * This represents the different options avilable for the video capture.
  31878. */
  31879. interface VideoRecorderOptions {
  31880. /** Defines the mime type of the video */
  31881. mimeType: string;
  31882. /** Defines the video the video should be recorded at */
  31883. fps: number;
  31884. /** Defines the chunk size for the recording data */
  31885. recordChunckSize: number;
  31886. }
  31887. /**
  31888. * This can helps recording videos from BabylonJS.
  31889. * This is based on the available WebRTC functionalities of the browser.
  31890. *
  31891. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  31892. */
  31893. class VideoRecorder {
  31894. private static readonly _defaultOptions;
  31895. /**
  31896. * Returns wehther or not the VideoRecorder is available in your browser.
  31897. * @param engine Defines the Babylon Engine to check the support for
  31898. * @returns true if supported otherwise false
  31899. */
  31900. static IsSupported(engine: Engine): boolean;
  31901. private readonly _options;
  31902. private _canvas;
  31903. private _mediaRecorder;
  31904. private _recordedChunks;
  31905. private _fileName;
  31906. private _resolve;
  31907. private _reject;
  31908. /**
  31909. * True wether a recording is already in progress.
  31910. */
  31911. readonly isRecording: boolean;
  31912. /**
  31913. * Create a new VideoCapture object which can help converting what you see in Babylon to
  31914. * a video file.
  31915. * @param engine Defines the BabylonJS Engine you wish to record
  31916. * @param options Defines options that can be used to customized the capture
  31917. */
  31918. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  31919. /**
  31920. * Stops the current recording before the default capture timeout passed in the startRecording
  31921. * functions.
  31922. */
  31923. stopRecording(): void;
  31924. /**
  31925. * Starts recording the canvas for a max duration specified in parameters.
  31926. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  31927. * @param maxDuration Defines the maximum recording time in seconds.
  31928. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  31929. * @return a promise callback at the end of the recording with the video data in Blob.
  31930. */
  31931. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  31932. /**
  31933. * Releases internal resources used during the recording.
  31934. */
  31935. dispose(): void;
  31936. private _handleDataAvailable;
  31937. private _handleError;
  31938. private _handleStop;
  31939. }
  31940. }
  31941. declare module BABYLON {
  31942. /**
  31943. * Defines the potential axis of a Joystick
  31944. */
  31945. enum JoystickAxis {
  31946. /** X axis */
  31947. X = 0,
  31948. /** Y axis */
  31949. Y = 1,
  31950. /** Z axis */
  31951. Z = 2
  31952. }
  31953. /**
  31954. * Class used to define virtual joystick (used in touch mode)
  31955. */
  31956. class VirtualJoystick {
  31957. /**
  31958. * Gets or sets a boolean indicating that left and right values must be inverted
  31959. */
  31960. reverseLeftRight: boolean;
  31961. /**
  31962. * Gets or sets a boolean indicating that up and down values must be inverted
  31963. */
  31964. reverseUpDown: boolean;
  31965. /**
  31966. * Gets the offset value for the position (ie. the change of the position value)
  31967. */
  31968. deltaPosition: Vector3;
  31969. /**
  31970. * Gets a boolean indicating if the virtual joystick was pressed
  31971. */
  31972. pressed: boolean;
  31973. private static _globalJoystickIndex;
  31974. private static vjCanvas;
  31975. private static vjCanvasContext;
  31976. private static vjCanvasWidth;
  31977. private static vjCanvasHeight;
  31978. private static halfWidth;
  31979. private _action;
  31980. private _axisTargetedByLeftAndRight;
  31981. private _axisTargetedByUpAndDown;
  31982. private _joystickSensibility;
  31983. private _inversedSensibility;
  31984. private _joystickPointerID;
  31985. private _joystickColor;
  31986. private _joystickPointerPos;
  31987. private _joystickPreviousPointerPos;
  31988. private _joystickPointerStartPos;
  31989. private _deltaJoystickVector;
  31990. private _leftJoystick;
  31991. private _touches;
  31992. private _onPointerDownHandlerRef;
  31993. private _onPointerMoveHandlerRef;
  31994. private _onPointerUpHandlerRef;
  31995. private _onResize;
  31996. /**
  31997. * Creates a new virtual joystick
  31998. * @param leftJoystick defines that the joystick is for left hand (false by default)
  31999. */
  32000. constructor(leftJoystick?: boolean);
  32001. /**
  32002. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32003. * @param newJoystickSensibility defines the new sensibility
  32004. */
  32005. setJoystickSensibility(newJoystickSensibility: number): void;
  32006. private _onPointerDown;
  32007. private _onPointerMove;
  32008. private _onPointerUp;
  32009. /**
  32010. * Change the color of the virtual joystick
  32011. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32012. */
  32013. setJoystickColor(newColor: string): void;
  32014. /**
  32015. * Defines a callback to call when the joystick is touched
  32016. * @param action defines the callback
  32017. */
  32018. setActionOnTouch(action: () => any): void;
  32019. /**
  32020. * Defines which axis you'd like to control for left & right
  32021. * @param axis defines the axis to use
  32022. */
  32023. setAxisForLeftRight(axis: JoystickAxis): void;
  32024. /**
  32025. * Defines which axis you'd like to control for up & down
  32026. * @param axis defines the axis to use
  32027. */
  32028. setAxisForUpDown(axis: JoystickAxis): void;
  32029. private _drawVirtualJoystick;
  32030. /**
  32031. * Release internal HTML canvas
  32032. */
  32033. releaseCanvas(): void;
  32034. }
  32035. }
  32036. declare module BABYLON {
  32037. /**
  32038. * Helper class to push actions to a pool of workers.
  32039. */
  32040. class WorkerPool implements IDisposable {
  32041. private _workerInfos;
  32042. private _pendingActions;
  32043. /**
  32044. * Constructor
  32045. * @param workers Array of workers to use for actions
  32046. */
  32047. constructor(workers: Array<Worker>);
  32048. /**
  32049. * Terminates all workers and clears any pending actions.
  32050. */
  32051. dispose(): void;
  32052. /**
  32053. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32054. * pended until a worker has completed its action.
  32055. * @param action The action to perform. Call onComplete when the action is complete.
  32056. */
  32057. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32058. private _execute;
  32059. }
  32060. }
  32061. declare module BABYLON {
  32062. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32063. readonly name: string;
  32064. private _zoomStopsAnimation;
  32065. private _idleRotationSpeed;
  32066. private _idleRotationWaitTime;
  32067. private _idleRotationSpinupTime;
  32068. /**
  32069. * Sets the flag that indicates if user zooming should stop animation.
  32070. */
  32071. /**
  32072. * Gets the flag that indicates if user zooming should stop animation.
  32073. */
  32074. zoomStopsAnimation: boolean;
  32075. /**
  32076. * Sets the default speed at which the camera rotates around the model.
  32077. */
  32078. /**
  32079. * Gets the default speed at which the camera rotates around the model.
  32080. */
  32081. idleRotationSpeed: number;
  32082. /**
  32083. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32084. */
  32085. /**
  32086. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32087. */
  32088. idleRotationWaitTime: number;
  32089. /**
  32090. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32091. */
  32092. /**
  32093. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32094. */
  32095. idleRotationSpinupTime: number;
  32096. /**
  32097. * Gets a value indicating if the camera is currently rotating because of this behavior
  32098. */
  32099. readonly rotationInProgress: boolean;
  32100. private _onPrePointerObservableObserver;
  32101. private _onAfterCheckInputsObserver;
  32102. private _attachedCamera;
  32103. private _isPointerDown;
  32104. private _lastFrameTime;
  32105. private _lastInteractionTime;
  32106. private _cameraRotationSpeed;
  32107. init(): void;
  32108. attach(camera: ArcRotateCamera): void;
  32109. detach(): void;
  32110. /**
  32111. * Returns true if user is scrolling.
  32112. * @return true if user is scrolling.
  32113. */
  32114. private _userIsZooming;
  32115. private _lastFrameRadius;
  32116. private _shouldAnimationStopForInteraction;
  32117. /**
  32118. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32119. */
  32120. private _applyUserInteraction;
  32121. private _userIsMoving;
  32122. }
  32123. }
  32124. declare module BABYLON {
  32125. /**
  32126. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32127. */
  32128. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32129. readonly name: string;
  32130. /**
  32131. * The easing function used by animations
  32132. */
  32133. static EasingFunction: BackEase;
  32134. /**
  32135. * The easing mode used by animations
  32136. */
  32137. static EasingMode: number;
  32138. /**
  32139. * The duration of the animation, in milliseconds
  32140. */
  32141. transitionDuration: number;
  32142. /**
  32143. * Length of the distance animated by the transition when lower radius is reached
  32144. */
  32145. lowerRadiusTransitionRange: number;
  32146. /**
  32147. * Length of the distance animated by the transition when upper radius is reached
  32148. */
  32149. upperRadiusTransitionRange: number;
  32150. private _autoTransitionRange;
  32151. /**
  32152. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32153. */
  32154. /**
  32155. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32156. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32157. */
  32158. autoTransitionRange: boolean;
  32159. private _attachedCamera;
  32160. private _onAfterCheckInputsObserver;
  32161. private _onMeshTargetChangedObserver;
  32162. init(): void;
  32163. attach(camera: ArcRotateCamera): void;
  32164. detach(): void;
  32165. private _radiusIsAnimating;
  32166. private _radiusBounceTransition;
  32167. private _animatables;
  32168. private _cachedWheelPrecision;
  32169. /**
  32170. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32171. * @param radiusLimit The limit to check against.
  32172. * @return Bool to indicate if at limit.
  32173. */
  32174. private _isRadiusAtLimit;
  32175. /**
  32176. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32177. * @param radiusDelta The delta by which to animate to. Can be negative.
  32178. */
  32179. private _applyBoundRadiusAnimation;
  32180. /**
  32181. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32182. */
  32183. protected _clearAnimationLocks(): void;
  32184. /**
  32185. * Stops and removes all animations that have been applied to the camera
  32186. */
  32187. stopAllAnimations(): void;
  32188. }
  32189. }
  32190. declare module BABYLON {
  32191. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32192. readonly name: string;
  32193. private _mode;
  32194. private _radiusScale;
  32195. private _positionScale;
  32196. private _defaultElevation;
  32197. private _elevationReturnTime;
  32198. private _elevationReturnWaitTime;
  32199. private _zoomStopsAnimation;
  32200. private _framingTime;
  32201. /**
  32202. * The easing function used by animations
  32203. */
  32204. static EasingFunction: ExponentialEase;
  32205. /**
  32206. * The easing mode used by animations
  32207. */
  32208. static EasingMode: number;
  32209. /**
  32210. * Sets the current mode used by the behavior
  32211. */
  32212. /**
  32213. * Gets current mode used by the behavior.
  32214. */
  32215. mode: number;
  32216. /**
  32217. * Sets the scale applied to the radius (1 by default)
  32218. */
  32219. /**
  32220. * Gets the scale applied to the radius
  32221. */
  32222. radiusScale: number;
  32223. /**
  32224. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32225. */
  32226. /**
  32227. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32228. */
  32229. positionScale: number;
  32230. /**
  32231. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32232. * behaviour is triggered, in radians.
  32233. */
  32234. /**
  32235. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32236. * behaviour is triggered, in radians.
  32237. */
  32238. defaultElevation: number;
  32239. /**
  32240. * Sets the time (in milliseconds) taken to return to the default beta position.
  32241. * Negative value indicates camera should not return to default.
  32242. */
  32243. /**
  32244. * Gets the time (in milliseconds) taken to return to the default beta position.
  32245. * Negative value indicates camera should not return to default.
  32246. */
  32247. elevationReturnTime: number;
  32248. /**
  32249. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32250. */
  32251. /**
  32252. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32253. */
  32254. elevationReturnWaitTime: number;
  32255. /**
  32256. * Sets the flag that indicates if user zooming should stop animation.
  32257. */
  32258. /**
  32259. * Gets the flag that indicates if user zooming should stop animation.
  32260. */
  32261. zoomStopsAnimation: boolean;
  32262. /**
  32263. * Sets the transition time when framing the mesh, in milliseconds
  32264. */
  32265. /**
  32266. * Gets the transition time when framing the mesh, in milliseconds
  32267. */
  32268. framingTime: number;
  32269. private _onPrePointerObservableObserver;
  32270. private _onAfterCheckInputsObserver;
  32271. private _onMeshTargetChangedObserver;
  32272. private _attachedCamera;
  32273. private _isPointerDown;
  32274. private _lastInteractionTime;
  32275. init(): void;
  32276. attach(camera: ArcRotateCamera): void;
  32277. detach(): void;
  32278. private _animatables;
  32279. private _betaIsAnimating;
  32280. private _betaTransition;
  32281. private _radiusTransition;
  32282. private _vectorTransition;
  32283. /**
  32284. * Targets the given mesh and updates zoom level accordingly.
  32285. * @param mesh The mesh to target.
  32286. * @param radius Optional. If a cached radius position already exists, overrides default.
  32287. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32288. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32289. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32290. */
  32291. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32292. /**
  32293. * Targets the given mesh with its children and updates zoom level accordingly.
  32294. * @param mesh The mesh to target.
  32295. * @param radius Optional. If a cached radius position already exists, overrides default.
  32296. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32297. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32298. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32299. */
  32300. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32301. /**
  32302. * Targets the given meshes with their children and updates zoom level accordingly.
  32303. * @param meshes The mesh to target.
  32304. * @param radius Optional. If a cached radius position already exists, overrides default.
  32305. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32308. */
  32309. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32310. /**
  32311. * Targets the given mesh and updates zoom level accordingly.
  32312. * @param mesh The mesh to target.
  32313. * @param radius Optional. If a cached radius position already exists, overrides default.
  32314. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32317. */
  32318. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32319. /**
  32320. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32321. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32322. * frustum width.
  32323. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32324. * to fully enclose the mesh in the viewing frustum.
  32325. */
  32326. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32327. /**
  32328. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32329. * is automatically returned to its default position (expected to be above ground plane).
  32330. */
  32331. private _maintainCameraAboveGround;
  32332. /**
  32333. * Returns the frustum slope based on the canvas ratio and camera FOV
  32334. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32335. */
  32336. private _getFrustumSlope;
  32337. /**
  32338. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32339. */
  32340. private _clearAnimationLocks;
  32341. /**
  32342. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32343. */
  32344. private _applyUserInteraction;
  32345. /**
  32346. * Stops and removes all animations that have been applied to the camera
  32347. */
  32348. stopAllAnimations(): void;
  32349. /**
  32350. * Gets a value indicating if the user is moving the camera
  32351. */
  32352. readonly isUserIsMoving: boolean;
  32353. /**
  32354. * The camera can move all the way towards the mesh.
  32355. */
  32356. static IgnoreBoundsSizeMode: number;
  32357. /**
  32358. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32359. */
  32360. static FitFrustumSidesMode: number;
  32361. }
  32362. }
  32363. declare module BABYLON {
  32364. /**
  32365. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32366. */
  32367. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32368. private ui;
  32369. /**
  32370. * The name of the behavior
  32371. */
  32372. name: string;
  32373. /**
  32374. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32375. */
  32376. distanceAwayFromFace: number;
  32377. /**
  32378. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32379. */
  32380. distanceAwayFromBottomOfFace: number;
  32381. private _faceVectors;
  32382. private _target;
  32383. private _scene;
  32384. private _onRenderObserver;
  32385. private _tmpMatrix;
  32386. private _tmpVector;
  32387. /**
  32388. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32389. * @param ui The transform node that should be attched to the mesh
  32390. */
  32391. constructor(ui: BABYLON.TransformNode);
  32392. /**
  32393. * Initializes the behavior
  32394. */
  32395. init(): void;
  32396. private _closestFace;
  32397. private _zeroVector;
  32398. private _lookAtTmpMatrix;
  32399. private _lookAtToRef;
  32400. /**
  32401. * Attaches the AttachToBoxBehavior to the passed in mesh
  32402. * @param target The mesh that the specified node will be attached to
  32403. */
  32404. attach(target: BABYLON.Mesh): void;
  32405. /**
  32406. * Detaches the behavior from the mesh
  32407. */
  32408. detach(): void;
  32409. }
  32410. }
  32411. declare module BABYLON {
  32412. /**
  32413. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32414. */
  32415. class FadeInOutBehavior implements Behavior<Mesh> {
  32416. /**
  32417. * Time in milliseconds to delay before fading in (Default: 0)
  32418. */
  32419. delay: number;
  32420. /**
  32421. * Time in milliseconds for the mesh to fade in (Default: 300)
  32422. */
  32423. fadeInTime: number;
  32424. private _millisecondsPerFrame;
  32425. private _hovered;
  32426. private _hoverValue;
  32427. private _ownerNode;
  32428. /**
  32429. * Instatiates the FadeInOutBehavior
  32430. */
  32431. constructor();
  32432. /**
  32433. * The name of the behavior
  32434. */
  32435. readonly name: string;
  32436. /**
  32437. * Initializes the behavior
  32438. */
  32439. init(): void;
  32440. /**
  32441. * Attaches the fade behavior on the passed in mesh
  32442. * @param ownerNode The mesh that will be faded in/out once attached
  32443. */
  32444. attach(ownerNode: Mesh): void;
  32445. /**
  32446. * Detaches the behavior from the mesh
  32447. */
  32448. detach(): void;
  32449. /**
  32450. * Triggers the mesh to begin fading in or out
  32451. * @param value if the object should fade in or out (true to fade in)
  32452. */
  32453. fadeIn(value: boolean): void;
  32454. private _update;
  32455. private _setAllVisibility;
  32456. }
  32457. }
  32458. declare module BABYLON {
  32459. /**
  32460. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32461. */
  32462. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32463. private _dragBehaviorA;
  32464. private _dragBehaviorB;
  32465. private _startDistance;
  32466. private _initialScale;
  32467. private _targetScale;
  32468. private _ownerNode;
  32469. private _sceneRenderObserver;
  32470. constructor();
  32471. /**
  32472. * The name of the behavior
  32473. */
  32474. readonly name: string;
  32475. /**
  32476. * Initializes the behavior
  32477. */
  32478. init(): void;
  32479. private _getCurrentDistance;
  32480. /**
  32481. * Attaches the scale behavior the passed in mesh
  32482. * @param ownerNode The mesh that will be scaled around once attached
  32483. */
  32484. attach(ownerNode: Mesh): void;
  32485. /**
  32486. * Detaches the behavior from the mesh
  32487. */
  32488. detach(): void;
  32489. }
  32490. }
  32491. declare module BABYLON {
  32492. /**
  32493. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32494. */
  32495. class PointerDragBehavior implements Behavior<Mesh> {
  32496. private _attachedNode;
  32497. private _dragPlane;
  32498. private _scene;
  32499. private _pointerObserver;
  32500. private _beforeRenderObserver;
  32501. private static _planeScene;
  32502. /**
  32503. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  32504. */
  32505. maxDragAngle: number;
  32506. /**
  32507. * @hidden
  32508. */
  32509. /**
  32510. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32511. */
  32512. currentDraggingPointerID: number;
  32513. /**
  32514. * The last position where the pointer hit the drag plane in world space
  32515. */
  32516. lastDragPosition: Vector3;
  32517. /**
  32518. * If the behavior is currently in a dragging state
  32519. */
  32520. dragging: boolean;
  32521. /**
  32522. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32523. */
  32524. dragDeltaRatio: number;
  32525. /**
  32526. * If the drag plane orientation should be updated during the dragging (Default: true)
  32527. */
  32528. updateDragPlane: boolean;
  32529. private _debugMode;
  32530. private _moving;
  32531. /**
  32532. * Fires each time the attached mesh is dragged with the pointer
  32533. * * delta between last drag position and current drag position in world space
  32534. * * dragDistance along the drag axis
  32535. * * dragPlaneNormal normal of the current drag plane used during the drag
  32536. * * dragPlanePoint in world space where the drag intersects the drag plane
  32537. */
  32538. onDragObservable: Observable<{
  32539. delta: Vector3;
  32540. dragPlanePoint: Vector3;
  32541. dragPlaneNormal: Vector3;
  32542. dragDistance: number;
  32543. pointerId: number;
  32544. }>;
  32545. /**
  32546. * Fires each time a drag begins (eg. mouse down on mesh)
  32547. */
  32548. onDragStartObservable: Observable<{
  32549. dragPlanePoint: Vector3;
  32550. pointerId: number;
  32551. }>;
  32552. /**
  32553. * Fires each time a drag ends (eg. mouse release after drag)
  32554. */
  32555. onDragEndObservable: Observable<{
  32556. dragPlanePoint: Vector3;
  32557. pointerId: number;
  32558. }>;
  32559. /**
  32560. * If the attached mesh should be moved when dragged
  32561. */
  32562. moveAttached: boolean;
  32563. /**
  32564. * If the drag behavior will react to drag events (Default: true)
  32565. */
  32566. enabled: boolean;
  32567. /**
  32568. * If camera controls should be detached during the drag
  32569. */
  32570. detachCameraControls: boolean;
  32571. /**
  32572. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32573. */
  32574. useObjectOrienationForDragging: boolean;
  32575. private _options;
  32576. /**
  32577. * Creates a pointer drag behavior that can be attached to a mesh
  32578. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  32579. */
  32580. constructor(options?: {
  32581. dragAxis?: Vector3;
  32582. dragPlaneNormal?: Vector3;
  32583. });
  32584. /**
  32585. * The name of the behavior
  32586. */
  32587. readonly name: string;
  32588. /**
  32589. * Initializes the behavior
  32590. */
  32591. init(): void;
  32592. private _tmpVector;
  32593. private _alternatePickedPoint;
  32594. private _worldDragAxis;
  32595. private _targetPosition;
  32596. private _attachedElement;
  32597. /**
  32598. * Attaches the drag behavior the passed in mesh
  32599. * @param ownerNode The mesh that will be dragged around once attached
  32600. */
  32601. attach(ownerNode: Mesh): void;
  32602. releaseDrag(): void;
  32603. private _startDragRay;
  32604. private _lastPointerRay;
  32605. /**
  32606. * Simulates the start of a pointer drag event on the behavior
  32607. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  32608. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  32609. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  32610. */
  32611. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  32612. private _startDrag;
  32613. private _dragDelta;
  32614. private _moveDrag;
  32615. private _pickWithRayOnDragPlane;
  32616. private _pointA;
  32617. private _pointB;
  32618. private _pointC;
  32619. private _lineA;
  32620. private _lineB;
  32621. private _localAxis;
  32622. private _lookAt;
  32623. private _updateDragPlanePosition;
  32624. /**
  32625. * Detaches the behavior from the mesh
  32626. */
  32627. detach(): void;
  32628. }
  32629. }
  32630. declare module BABYLON {
  32631. /**
  32632. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  32633. */
  32634. class SixDofDragBehavior implements Behavior<Mesh> {
  32635. private static _virtualScene;
  32636. private _ownerNode;
  32637. private _sceneRenderObserver;
  32638. private _scene;
  32639. private _targetPosition;
  32640. private _virtualOriginMesh;
  32641. private _virtualDragMesh;
  32642. private _pointerObserver;
  32643. private _moving;
  32644. private _startingOrientation;
  32645. /**
  32646. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  32647. */
  32648. private zDragFactor;
  32649. /**
  32650. * If the behavior is currently in a dragging state
  32651. */
  32652. dragging: boolean;
  32653. /**
  32654. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  32655. */
  32656. dragDeltaRatio: number;
  32657. /**
  32658. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32659. */
  32660. currentDraggingPointerID: number;
  32661. /**
  32662. * If camera controls should be detached during the drag
  32663. */
  32664. detachCameraControls: boolean;
  32665. constructor();
  32666. /**
  32667. * The name of the behavior
  32668. */
  32669. readonly name: string;
  32670. /**
  32671. * Initializes the behavior
  32672. */
  32673. init(): void;
  32674. /**
  32675. * Attaches the scale behavior the passed in mesh
  32676. * @param ownerNode The mesh that will be scaled around once attached
  32677. */
  32678. attach(ownerNode: Mesh): void;
  32679. /**
  32680. * Detaches the behavior from the mesh
  32681. */
  32682. detach(): void;
  32683. }
  32684. }
  32685. declare module BABYLON {
  32686. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  32687. camera: ArcRotateCamera;
  32688. gamepad: Nullable<Gamepad>;
  32689. private _onGamepadConnectedObserver;
  32690. private _onGamepadDisconnectedObserver;
  32691. gamepadRotationSensibility: number;
  32692. gamepadMoveSensibility: number;
  32693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32694. detachControl(element: Nullable<HTMLElement>): void;
  32695. checkInputs(): void;
  32696. getClassName(): string;
  32697. getSimpleName(): string;
  32698. }
  32699. }
  32700. declare module BABYLON {
  32701. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  32702. camera: ArcRotateCamera;
  32703. private _keys;
  32704. keysUp: number[];
  32705. keysDown: number[];
  32706. keysLeft: number[];
  32707. keysRight: number[];
  32708. keysReset: number[];
  32709. panningSensibility: number;
  32710. zoomingSensibility: number;
  32711. useAltToZoom: boolean;
  32712. private _ctrlPressed;
  32713. private _altPressed;
  32714. private _onCanvasBlurObserver;
  32715. private _onKeyboardObserver;
  32716. private _engine;
  32717. private _scene;
  32718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32719. detachControl(element: Nullable<HTMLElement>): void;
  32720. checkInputs(): void;
  32721. getClassName(): string;
  32722. getSimpleName(): string;
  32723. }
  32724. }
  32725. declare module BABYLON {
  32726. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  32727. camera: ArcRotateCamera;
  32728. private _wheel;
  32729. private _observer;
  32730. wheelPrecision: number;
  32731. /**
  32732. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  32733. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  32734. */
  32735. wheelDeltaPercentage: number;
  32736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32737. detachControl(element: Nullable<HTMLElement>): void;
  32738. getClassName(): string;
  32739. getSimpleName(): string;
  32740. }
  32741. }
  32742. declare module BABYLON {
  32743. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  32744. camera: ArcRotateCamera;
  32745. buttons: number[];
  32746. angularSensibilityX: number;
  32747. angularSensibilityY: number;
  32748. pinchPrecision: number;
  32749. /**
  32750. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  32751. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  32752. */
  32753. pinchDeltaPercentage: number;
  32754. panningSensibility: number;
  32755. multiTouchPanning: boolean;
  32756. multiTouchPanAndZoom: boolean;
  32757. private _isPanClick;
  32758. pinchInwards: boolean;
  32759. private _pointerInput;
  32760. private _observer;
  32761. private _onMouseMove;
  32762. private _onGestureStart;
  32763. private _onGesture;
  32764. private _MSGestureHandler;
  32765. private _onLostFocus;
  32766. private _onContextMenu;
  32767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32768. detachControl(element: Nullable<HTMLElement>): void;
  32769. getClassName(): string;
  32770. getSimpleName(): string;
  32771. }
  32772. }
  32773. declare module BABYLON {
  32774. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32775. camera: ArcRotateCamera;
  32776. alphaCorrection: number;
  32777. betaCorrection: number;
  32778. gammaCorrection: number;
  32779. private _alpha;
  32780. private _gamma;
  32781. private _dirty;
  32782. private _deviceOrientationHandler;
  32783. constructor();
  32784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32785. /** @hidden */
  32786. checkInputs(): void;
  32787. detachControl(element: Nullable<HTMLElement>): void;
  32788. getClassName(): string;
  32789. getSimpleName(): string;
  32790. }
  32791. }
  32792. declare module BABYLON {
  32793. /**
  32794. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32795. * Screen rotation is taken into account.
  32796. */
  32797. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32798. private _camera;
  32799. private _screenOrientationAngle;
  32800. private _constantTranform;
  32801. private _screenQuaternion;
  32802. private _alpha;
  32803. private _beta;
  32804. private _gamma;
  32805. constructor();
  32806. camera: FreeCamera;
  32807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32808. private _orientationChanged;
  32809. private _deviceOrientation;
  32810. detachControl(element: Nullable<HTMLElement>): void;
  32811. checkInputs(): void;
  32812. getClassName(): string;
  32813. getSimpleName(): string;
  32814. }
  32815. }
  32816. declare module BABYLON {
  32817. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32818. camera: FreeCamera;
  32819. gamepad: Nullable<Gamepad>;
  32820. private _onGamepadConnectedObserver;
  32821. private _onGamepadDisconnectedObserver;
  32822. gamepadAngularSensibility: number;
  32823. gamepadMoveSensibility: number;
  32824. private _cameraTransform;
  32825. private _deltaTransform;
  32826. private _vector3;
  32827. private _vector2;
  32828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32829. detachControl(element: Nullable<HTMLElement>): void;
  32830. checkInputs(): void;
  32831. getClassName(): string;
  32832. getSimpleName(): string;
  32833. }
  32834. }
  32835. declare module BABYLON {
  32836. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  32837. camera: FreeCamera;
  32838. private _keys;
  32839. private _onCanvasBlurObserver;
  32840. private _onKeyboardObserver;
  32841. private _engine;
  32842. private _scene;
  32843. keysUp: number[];
  32844. keysDown: number[];
  32845. keysLeft: number[];
  32846. keysRight: number[];
  32847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32848. detachControl(element: Nullable<HTMLElement>): void;
  32849. checkInputs(): void;
  32850. getClassName(): string;
  32851. /** @hidden */
  32852. getSimpleName(): string;
  32853. }
  32854. }
  32855. declare module BABYLON {
  32856. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  32857. touchEnabled: boolean;
  32858. camera: FreeCamera;
  32859. buttons: number[];
  32860. angularSensibility: number;
  32861. private _pointerInput;
  32862. private _onMouseMove;
  32863. private _observer;
  32864. private previousPosition;
  32865. constructor(touchEnabled?: boolean);
  32866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32867. detachControl(element: Nullable<HTMLElement>): void;
  32868. getClassName(): string;
  32869. getSimpleName(): string;
  32870. }
  32871. }
  32872. declare module BABYLON {
  32873. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  32874. camera: FreeCamera;
  32875. private _offsetX;
  32876. private _offsetY;
  32877. private _pointerPressed;
  32878. private _pointerInput;
  32879. private _observer;
  32880. private _onLostFocus;
  32881. touchAngularSensibility: number;
  32882. touchMoveSensibility: number;
  32883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32884. detachControl(element: Nullable<HTMLElement>): void;
  32885. checkInputs(): void;
  32886. getClassName(): string;
  32887. getSimpleName(): string;
  32888. }
  32889. }
  32890. declare module BABYLON {
  32891. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  32892. camera: FreeCamera;
  32893. private _leftjoystick;
  32894. private _rightjoystick;
  32895. getLeftJoystick(): VirtualJoystick;
  32896. getRightJoystick(): VirtualJoystick;
  32897. checkInputs(): void;
  32898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32899. detachControl(element: Nullable<HTMLElement>): void;
  32900. getClassName(): string;
  32901. getSimpleName(): string;
  32902. }
  32903. }
  32904. declare module BABYLON {
  32905. /**
  32906. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  32907. */
  32908. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  32909. /**
  32910. * Creates a new AnaglyphArcRotateCamera
  32911. * @param name defines camera name
  32912. * @param alpha defines alpha angle (in radians)
  32913. * @param beta defines beta angle (in radians)
  32914. * @param radius defines radius
  32915. * @param target defines camera target
  32916. * @param interaxialDistance defines distance between each color axis
  32917. * @param scene defines the hosting scene
  32918. */
  32919. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  32920. /**
  32921. * Gets camera class name
  32922. * @returns AnaglyphArcRotateCamera
  32923. */
  32924. getClassName(): string;
  32925. }
  32926. }
  32927. declare module BABYLON {
  32928. /**
  32929. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  32930. */
  32931. class AnaglyphFreeCamera extends FreeCamera {
  32932. /**
  32933. * Creates a new AnaglyphFreeCamera
  32934. * @param name defines camera name
  32935. * @param position defines initial position
  32936. * @param interaxialDistance defines distance between each color axis
  32937. * @param scene defines the hosting scene
  32938. */
  32939. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32940. /**
  32941. * Gets camera class name
  32942. * @returns AnaglyphFreeCamera
  32943. */
  32944. getClassName(): string;
  32945. }
  32946. }
  32947. declare module BABYLON {
  32948. /**
  32949. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  32950. */
  32951. class AnaglyphGamepadCamera extends GamepadCamera {
  32952. /**
  32953. * Creates a new AnaglyphGamepadCamera
  32954. * @param name defines camera name
  32955. * @param position defines initial position
  32956. * @param interaxialDistance defines distance between each color axis
  32957. * @param scene defines the hosting scene
  32958. */
  32959. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32960. /**
  32961. * Gets camera class name
  32962. * @returns AnaglyphGamepadCamera
  32963. */
  32964. getClassName(): string;
  32965. }
  32966. }
  32967. declare module BABYLON {
  32968. /**
  32969. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  32970. */
  32971. class AnaglyphUniversalCamera extends UniversalCamera {
  32972. /**
  32973. * Creates a new AnaglyphUniversalCamera
  32974. * @param name defines camera name
  32975. * @param position defines initial position
  32976. * @param interaxialDistance defines distance between each color axis
  32977. * @param scene defines the hosting scene
  32978. */
  32979. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32980. /**
  32981. * Gets camera class name
  32982. * @returns AnaglyphUniversalCamera
  32983. */
  32984. getClassName(): string;
  32985. }
  32986. }
  32987. declare module BABYLON {
  32988. /**
  32989. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32990. */
  32991. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32992. /**
  32993. * Creates a new StereoscopicArcRotateCamera
  32994. * @param name defines camera name
  32995. * @param alpha defines alpha angle (in radians)
  32996. * @param beta defines beta angle (in radians)
  32997. * @param radius defines radius
  32998. * @param target defines camera target
  32999. * @param interaxialDistance defines distance between each color axis
  33000. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33001. * @param scene defines the hosting scene
  33002. */
  33003. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33004. /**
  33005. * Gets camera class name
  33006. * @returns StereoscopicArcRotateCamera
  33007. */
  33008. getClassName(): string;
  33009. }
  33010. }
  33011. declare module BABYLON {
  33012. /**
  33013. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33014. */
  33015. class StereoscopicFreeCamera extends FreeCamera {
  33016. /**
  33017. * Creates a new StereoscopicFreeCamera
  33018. * @param name defines camera name
  33019. * @param position defines initial position
  33020. * @param interaxialDistance defines distance between each color axis
  33021. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33022. * @param scene defines the hosting scene
  33023. */
  33024. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33025. /**
  33026. * Gets camera class name
  33027. * @returns StereoscopicFreeCamera
  33028. */
  33029. getClassName(): string;
  33030. }
  33031. }
  33032. declare module BABYLON {
  33033. /**
  33034. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33035. */
  33036. class StereoscopicGamepadCamera extends GamepadCamera {
  33037. /**
  33038. * Creates a new StereoscopicGamepadCamera
  33039. * @param name defines camera name
  33040. * @param position defines initial position
  33041. * @param interaxialDistance defines distance between each color axis
  33042. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33043. * @param scene defines the hosting scene
  33044. */
  33045. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33046. /**
  33047. * Gets camera class name
  33048. * @returns StereoscopicGamepadCamera
  33049. */
  33050. getClassName(): string;
  33051. }
  33052. }
  33053. declare module BABYLON {
  33054. /**
  33055. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33056. */
  33057. class StereoscopicUniversalCamera extends UniversalCamera {
  33058. /**
  33059. * Creates a new StereoscopicUniversalCamera
  33060. * @param name defines camera name
  33061. * @param position defines initial position
  33062. * @param interaxialDistance defines distance between each color axis
  33063. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33064. * @param scene defines the hosting scene
  33065. */
  33066. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33067. /**
  33068. * Gets camera class name
  33069. * @returns StereoscopicUniversalCamera
  33070. */
  33071. getClassName(): string;
  33072. }
  33073. }
  33074. declare module BABYLON {
  33075. class VRCameraMetrics {
  33076. hResolution: number;
  33077. vResolution: number;
  33078. hScreenSize: number;
  33079. vScreenSize: number;
  33080. vScreenCenter: number;
  33081. eyeToScreenDistance: number;
  33082. lensSeparationDistance: number;
  33083. interpupillaryDistance: number;
  33084. distortionK: number[];
  33085. chromaAbCorrection: number[];
  33086. postProcessScaleFactor: number;
  33087. lensCenterOffset: number;
  33088. compensateDistortion: boolean;
  33089. readonly aspectRatio: number;
  33090. readonly aspectRatioFov: number;
  33091. readonly leftHMatrix: Matrix;
  33092. readonly rightHMatrix: Matrix;
  33093. readonly leftPreViewMatrix: Matrix;
  33094. readonly rightPreViewMatrix: Matrix;
  33095. static GetDefault(): VRCameraMetrics;
  33096. }
  33097. }
  33098. declare module BABYLON {
  33099. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33100. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33101. getClassName(): string;
  33102. }
  33103. }
  33104. declare module BABYLON {
  33105. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33107. getClassName(): string;
  33108. }
  33109. }
  33110. declare module BABYLON {
  33111. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33112. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33113. getClassName(): string;
  33114. }
  33115. }
  33116. declare module BABYLON {
  33117. /**
  33118. * Options to modify the vr teleportation behavior.
  33119. */
  33120. interface VRTeleportationOptions {
  33121. /**
  33122. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33123. */
  33124. floorMeshName?: string;
  33125. /**
  33126. * A list of meshes to be used as the teleportation floor. (default: empty)
  33127. */
  33128. floorMeshes?: Mesh[];
  33129. }
  33130. /**
  33131. * Options to modify the vr experience helper's behavior.
  33132. */
  33133. interface VRExperienceHelperOptions extends WebVROptions {
  33134. /**
  33135. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  33136. */
  33137. createDeviceOrientationCamera?: boolean;
  33138. /**
  33139. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  33140. */
  33141. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33142. /**
  33143. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33144. */
  33145. laserToggle?: boolean;
  33146. /**
  33147. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33148. */
  33149. floorMeshes?: Mesh[];
  33150. }
  33151. /**
  33152. * Helps to quickly add VR support to an existing scene.
  33153. * See http://doc.babylonjs.com/how_to/webvr_helper
  33154. */
  33155. class VRExperienceHelper {
  33156. /** Options to modify the vr experience helper's behavior. */
  33157. webVROptions: VRExperienceHelperOptions;
  33158. private _scene;
  33159. private _position;
  33160. private _btnVR;
  33161. private _btnVRDisplayed;
  33162. private _webVRsupported;
  33163. private _webVRready;
  33164. private _webVRrequesting;
  33165. private _webVRpresenting;
  33166. private _hasEnteredVR;
  33167. private _fullscreenVRpresenting;
  33168. private _canvas;
  33169. private _webVRCamera;
  33170. private _vrDeviceOrientationCamera;
  33171. private _deviceOrientationCamera;
  33172. private _existingCamera;
  33173. private _onKeyDown;
  33174. private _onVrDisplayPresentChange;
  33175. private _onVRDisplayChanged;
  33176. private _onVRRequestPresentStart;
  33177. private _onVRRequestPresentComplete;
  33178. /**
  33179. * Observable raised when entering VR.
  33180. */
  33181. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33182. /**
  33183. * Observable raised when exiting VR.
  33184. */
  33185. onExitingVRObservable: Observable<VRExperienceHelper>;
  33186. /**
  33187. * Observable raised when controller mesh is loaded.
  33188. */
  33189. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33190. /** Return this.onEnteringVRObservable
  33191. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33192. */
  33193. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33194. /** Return this.onExitingVRObservable
  33195. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33196. */
  33197. readonly onExitingVR: Observable<VRExperienceHelper>;
  33198. /** Return this.onControllerMeshLoadedObservable
  33199. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33200. */
  33201. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33202. private _rayLength;
  33203. private _useCustomVRButton;
  33204. private _teleportationRequested;
  33205. private _teleportActive;
  33206. private _floorMeshName;
  33207. private _floorMeshesCollection;
  33208. private _rotationAllowed;
  33209. private _teleportBackwardsVector;
  33210. private _teleportationTarget;
  33211. private _isDefaultTeleportationTarget;
  33212. private _postProcessMove;
  33213. private _teleportationFillColor;
  33214. private _teleportationBorderColor;
  33215. private _rotationAngle;
  33216. private _haloCenter;
  33217. private _cameraGazer;
  33218. private _padSensibilityUp;
  33219. private _padSensibilityDown;
  33220. private _leftController;
  33221. private _rightController;
  33222. /**
  33223. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33224. */
  33225. onNewMeshSelected: Observable<AbstractMesh>;
  33226. /**
  33227. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33228. */
  33229. onNewMeshPicked: Observable<PickingInfo>;
  33230. private _circleEase;
  33231. /**
  33232. * Observable raised before camera teleportation
  33233. */
  33234. onBeforeCameraTeleport: Observable<Vector3>;
  33235. /**
  33236. * Observable raised after camera teleportation
  33237. */
  33238. onAfterCameraTeleport: Observable<Vector3>;
  33239. /**
  33240. * Observable raised when current selected mesh gets unselected
  33241. */
  33242. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33243. private _raySelectionPredicate;
  33244. /**
  33245. * To be optionaly changed by user to define custom ray selection
  33246. */
  33247. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33248. /**
  33249. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33250. */
  33251. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33252. /**
  33253. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33254. */
  33255. teleportationEnabled: boolean;
  33256. private _defaultHeight;
  33257. private _teleportationInitialized;
  33258. private _interactionsEnabled;
  33259. private _interactionsRequested;
  33260. private _displayGaze;
  33261. private _displayLaserPointer;
  33262. /**
  33263. * The mesh used to display where the user is going to teleport.
  33264. */
  33265. /**
  33266. * Sets the mesh to be used to display where the user is going to teleport.
  33267. */
  33268. teleportationTarget: Mesh;
  33269. /**
  33270. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  33271. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33272. * See http://doc.babylonjs.com/resources/baking_transformations
  33273. */
  33274. gazeTrackerMesh: Mesh;
  33275. /**
  33276. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  33277. */
  33278. updateGazeTrackerScale: boolean;
  33279. /**
  33280. * The gaze tracking mesh corresponding to the left controller
  33281. */
  33282. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  33283. /**
  33284. * The gaze tracking mesh corresponding to the right controller
  33285. */
  33286. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  33287. /**
  33288. * If the ray of the gaze should be displayed.
  33289. */
  33290. /**
  33291. * Sets if the ray of the gaze should be displayed.
  33292. */
  33293. displayGaze: boolean;
  33294. /**
  33295. * If the ray of the LaserPointer should be displayed.
  33296. */
  33297. /**
  33298. * Sets if the ray of the LaserPointer should be displayed.
  33299. */
  33300. displayLaserPointer: boolean;
  33301. /**
  33302. * The deviceOrientationCamera used as the camera when not in VR.
  33303. */
  33304. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33305. /**
  33306. * Based on the current WebVR support, returns the current VR camera used.
  33307. */
  33308. readonly currentVRCamera: Nullable<Camera>;
  33309. /**
  33310. * The webVRCamera which is used when in VR.
  33311. */
  33312. readonly webVRCamera: WebVRFreeCamera;
  33313. /**
  33314. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33315. */
  33316. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33317. private readonly _teleportationRequestInitiated;
  33318. /**
  33319. * Instantiates a VRExperienceHelper.
  33320. * Helps to quickly add VR support to an existing scene.
  33321. * @param scene The scene the VRExperienceHelper belongs to.
  33322. * @param webVROptions Options to modify the vr experience helper's behavior.
  33323. */
  33324. constructor(scene: Scene,
  33325. /** Options to modify the vr experience helper's behavior. */
  33326. webVROptions?: VRExperienceHelperOptions);
  33327. private _onDefaultMeshLoaded;
  33328. private _onResize;
  33329. private _onFullscreenChange;
  33330. /**
  33331. * Gets a value indicating if we are currently in VR mode.
  33332. */
  33333. readonly isInVRMode: boolean;
  33334. private onVrDisplayPresentChange;
  33335. private onVRDisplayChanged;
  33336. private moveButtonToBottomRight;
  33337. private displayVRButton;
  33338. private updateButtonVisibility;
  33339. /**
  33340. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33341. * Otherwise, will use the fullscreen API.
  33342. */
  33343. enterVR(): void;
  33344. /**
  33345. * Attempt to exit VR, or fullscreen.
  33346. */
  33347. exitVR(): void;
  33348. /**
  33349. * The position of the vr experience helper.
  33350. */
  33351. /**
  33352. * Sets the position of the vr experience helper.
  33353. */
  33354. position: Vector3;
  33355. /**
  33356. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33357. */
  33358. enableInteractions(): void;
  33359. private readonly _noControllerIsActive;
  33360. private beforeRender;
  33361. private _isTeleportationFloor;
  33362. /**
  33363. * Adds a floor mesh to be used for teleportation.
  33364. * @param floorMesh the mesh to be used for teleportation.
  33365. */
  33366. addFloorMesh(floorMesh: Mesh): void;
  33367. /**
  33368. * Removes a floor mesh from being used for teleportation.
  33369. * @param floorMesh the mesh to be removed.
  33370. */
  33371. removeFloorMesh(floorMesh: Mesh): void;
  33372. /**
  33373. * Enables interactions and teleportation using the VR controllers and gaze.
  33374. * @param vrTeleportationOptions options to modify teleportation behavior.
  33375. */
  33376. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33377. private _onNewGamepadConnected;
  33378. private _tryEnableInteractionOnController;
  33379. private _onNewGamepadDisconnected;
  33380. private _enableInteractionOnController;
  33381. private _checkTeleportWithRay;
  33382. private _checkRotate;
  33383. private _checkTeleportBackwards;
  33384. private _enableTeleportationOnController;
  33385. private _createTeleportationCircles;
  33386. private _displayTeleportationTarget;
  33387. private _hideTeleportationTarget;
  33388. private _rotateCamera;
  33389. private _moveTeleportationSelectorTo;
  33390. private _workingVector;
  33391. private _workingQuaternion;
  33392. private _workingMatrix;
  33393. /**
  33394. * Teleports the users feet to the desired location
  33395. * @param location The location where the user's feet should be placed
  33396. */
  33397. teleportCamera(location: Vector3): void;
  33398. private _convertNormalToDirectionOfRay;
  33399. private _castRayAndSelectObject;
  33400. private _notifySelectedMeshUnselected;
  33401. /**
  33402. * Sets the color of the laser ray from the vr controllers.
  33403. * @param color new color for the ray.
  33404. */
  33405. changeLaserColor(color: Color3): void;
  33406. /**
  33407. * Sets the color of the ray from the vr headsets gaze.
  33408. * @param color new color for the ray.
  33409. */
  33410. changeGazeColor(color: Color3): void;
  33411. /**
  33412. * Exits VR and disposes of the vr experience helper
  33413. */
  33414. dispose(): void;
  33415. /**
  33416. * Gets the name of the VRExperienceHelper class
  33417. * @returns "VRExperienceHelper"
  33418. */
  33419. getClassName(): string;
  33420. }
  33421. }
  33422. declare module BABYLON {
  33423. /**
  33424. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33425. * IMPORTANT!! The data is right-hand data.
  33426. * @export
  33427. * @interface DevicePose
  33428. */
  33429. interface DevicePose {
  33430. /**
  33431. * The position of the device, values in array are [x,y,z].
  33432. */
  33433. readonly position: Nullable<Float32Array>;
  33434. /**
  33435. * The linearVelocity of the device, values in array are [x,y,z].
  33436. */
  33437. readonly linearVelocity: Nullable<Float32Array>;
  33438. /**
  33439. * The linearAcceleration of the device, values in array are [x,y,z].
  33440. */
  33441. readonly linearAcceleration: Nullable<Float32Array>;
  33442. /**
  33443. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33444. */
  33445. readonly orientation: Nullable<Float32Array>;
  33446. /**
  33447. * The angularVelocity of the device, values in array are [x,y,z].
  33448. */
  33449. readonly angularVelocity: Nullable<Float32Array>;
  33450. /**
  33451. * The angularAcceleration of the device, values in array are [x,y,z].
  33452. */
  33453. readonly angularAcceleration: Nullable<Float32Array>;
  33454. }
  33455. /**
  33456. * Interface representing a pose controlled object in Babylon.
  33457. * A pose controlled object has both regular pose values as well as pose values
  33458. * from an external device such as a VR head mounted display
  33459. */
  33460. interface PoseControlled {
  33461. /**
  33462. * The position of the object in babylon space.
  33463. */
  33464. position: Vector3;
  33465. /**
  33466. * The rotation quaternion of the object in babylon space.
  33467. */
  33468. rotationQuaternion: Quaternion;
  33469. /**
  33470. * The position of the device in babylon space.
  33471. */
  33472. devicePosition?: Vector3;
  33473. /**
  33474. * The rotation quaternion of the device in babylon space.
  33475. */
  33476. deviceRotationQuaternion: Quaternion;
  33477. /**
  33478. * The raw pose coming from the device.
  33479. */
  33480. rawPose: Nullable<DevicePose>;
  33481. /**
  33482. * The scale of the device to be used when translating from device space to babylon space.
  33483. */
  33484. deviceScaleFactor: number;
  33485. /**
  33486. * Updates the poseControlled values based on the input device pose.
  33487. * @param poseData the pose data to update the object with
  33488. */
  33489. updateFromDevice(poseData: DevicePose): void;
  33490. }
  33491. /**
  33492. * Set of options to customize the webVRCamera
  33493. */
  33494. interface WebVROptions {
  33495. /**
  33496. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33497. */
  33498. trackPosition?: boolean;
  33499. /**
  33500. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33501. */
  33502. positionScale?: number;
  33503. /**
  33504. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33505. */
  33506. displayName?: string;
  33507. /**
  33508. * Should the native controller meshes be initialized. (default: true)
  33509. */
  33510. controllerMeshes?: boolean;
  33511. /**
  33512. * Creating a default HemiLight only on controllers. (default: true)
  33513. */
  33514. defaultLightingOnControllers?: boolean;
  33515. /**
  33516. * If you don't want to use the default VR button of the helper. (default: false)
  33517. */
  33518. useCustomVRButton?: boolean;
  33519. /**
  33520. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33521. */
  33522. customVRButton?: HTMLButtonElement;
  33523. /**
  33524. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33525. */
  33526. rayLength?: number;
  33527. /**
  33528. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33529. */
  33530. defaultHeight?: number;
  33531. }
  33532. /**
  33533. * This represents a WebVR camera.
  33534. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33535. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33536. */
  33537. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33538. private webVROptions;
  33539. /**
  33540. * @hidden
  33541. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33542. */
  33543. /**
  33544. * The rawPose of the vrDevice.
  33545. */
  33546. rawPose: Nullable<DevicePose>;
  33547. private _onVREnabled;
  33548. private _specsVersion;
  33549. private _attached;
  33550. private _frameData;
  33551. protected _descendants: Array<Node>;
  33552. private _deviceRoomPosition;
  33553. /** @hidden */
  33554. private _standingMatrix;
  33555. /**
  33556. * Represents device position in babylon space.
  33557. */
  33558. devicePosition: Vector3;
  33559. /**
  33560. * Represents device rotation in babylon space.
  33561. */
  33562. deviceRotationQuaternion: Quaternion;
  33563. /**
  33564. * The scale of the device to be used when translating from device space to babylon space.
  33565. */
  33566. deviceScaleFactor: number;
  33567. private _deviceToWorld;
  33568. private _worldToDevice;
  33569. /**
  33570. * References to the webVR controllers for the vrDevice.
  33571. */
  33572. controllers: Array<WebVRController>;
  33573. /**
  33574. * Emits an event when a controller is attached.
  33575. */
  33576. onControllersAttachedObservable: Observable<WebVRController[]>;
  33577. /**
  33578. * Emits an event when a controller's mesh has been loaded;
  33579. */
  33580. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33581. /**
  33582. * Emits an event when the HMD's pose has been updated.
  33583. */
  33584. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33585. private _poseSet;
  33586. /**
  33587. * If the rig cameras be used as parent instead of this camera.
  33588. */
  33589. rigParenting: boolean;
  33590. private _lightOnControllers;
  33591. private _defaultHeight?;
  33592. /**
  33593. * Instantiates a WebVRFreeCamera.
  33594. * @param name The name of the WebVRFreeCamera
  33595. * @param position The starting anchor position for the camera
  33596. * @param scene The scene the camera belongs to
  33597. * @param webVROptions a set of customizable options for the webVRCamera
  33598. */
  33599. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33600. /**
  33601. * Gets the device distance from the ground in meters.
  33602. * @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.
  33603. */
  33604. deviceDistanceToRoomGround(): number;
  33605. /**
  33606. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33607. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33608. */
  33609. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33610. /**
  33611. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33612. * @returns A promise with a boolean set to if the standing matrix is supported.
  33613. */
  33614. useStandingMatrixAsync(): Promise<boolean>;
  33615. /**
  33616. * Disposes the camera
  33617. */
  33618. dispose(): void;
  33619. /**
  33620. * Gets a vrController by name.
  33621. * @param name The name of the controller to retreive
  33622. * @returns the controller matching the name specified or null if not found
  33623. */
  33624. getControllerByName(name: string): Nullable<WebVRController>;
  33625. private _leftController;
  33626. /**
  33627. * The controller corrisponding to the users left hand.
  33628. */
  33629. readonly leftController: Nullable<WebVRController>;
  33630. private _rightController;
  33631. /**
  33632. * The controller corrisponding to the users right hand.
  33633. */
  33634. readonly rightController: Nullable<WebVRController>;
  33635. /**
  33636. * Casts a ray forward from the vrCamera's gaze.
  33637. * @param length Length of the ray (default: 100)
  33638. * @returns the ray corrisponding to the gaze
  33639. */
  33640. getForwardRay(length?: number): Ray;
  33641. /**
  33642. * @hidden
  33643. * Updates the camera based on device's frame data
  33644. */
  33645. /**
  33646. * Updates the poseControlled values based on the input device pose.
  33647. * @param poseData Pose coming from the device
  33648. */
  33649. updateFromDevice(poseData: DevicePose): void;
  33650. private _htmlElementAttached;
  33651. private _detachIfAttached;
  33652. /**
  33653. * WebVR's attach control will start broadcasting frames to the device.
  33654. * Note that in certain browsers (chrome for example) this function must be called
  33655. * within a user-interaction callback. Example:
  33656. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  33657. *
  33658. * @param element html element to attach the vrDevice to
  33659. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  33660. */
  33661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33662. /**
  33663. * Detaches the camera from the html element and disables VR
  33664. *
  33665. * @param element html element to detach from
  33666. */
  33667. detachControl(element: HTMLElement): void;
  33668. /**
  33669. * @returns the name of this class
  33670. */
  33671. getClassName(): string;
  33672. /**
  33673. * Calls resetPose on the vrDisplay
  33674. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  33675. */
  33676. resetToCurrentRotation(): void;
  33677. /**
  33678. * @hidden
  33679. * Updates the rig cameras (left and right eye)
  33680. */
  33681. private _workingVector;
  33682. private _oneVector;
  33683. private _workingMatrix;
  33684. private updateCacheCalled;
  33685. private _correctPositionIfNotTrackPosition;
  33686. /**
  33687. * @hidden
  33688. * Updates the cached values of the camera
  33689. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  33690. */
  33691. /**
  33692. * Updates the current device position and rotation in the babylon world
  33693. */
  33694. update(): void;
  33695. /**
  33696. * @hidden
  33697. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  33698. * @returns an identity matrix
  33699. */
  33700. private _tmpMatrix;
  33701. /**
  33702. * This function is called by the two RIG cameras.
  33703. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  33704. */
  33705. protected _getWebVRViewMatrix(): Matrix;
  33706. protected _getWebVRProjectionMatrix(): Matrix;
  33707. private _onGamepadConnectedObserver;
  33708. private _onGamepadDisconnectedObserver;
  33709. /**
  33710. * Initializes the controllers and their meshes
  33711. */
  33712. initControllers(): void;
  33713. }
  33714. }
  33715. declare module BABYLON {
  33716. interface IOctreeContainer<T> {
  33717. blocks: Array<OctreeBlock<T>>;
  33718. }
  33719. class Octree<T> {
  33720. maxDepth: number;
  33721. blocks: Array<OctreeBlock<T>>;
  33722. dynamicContent: T[];
  33723. private _maxBlockCapacity;
  33724. private _selectionContent;
  33725. private _creationFunc;
  33726. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33727. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33728. addMesh(entry: T): void;
  33729. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33730. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33731. intersectsRay(ray: Ray): SmartArray<T>;
  33732. 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;
  33733. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33734. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33735. }
  33736. }
  33737. declare module BABYLON {
  33738. class OctreeBlock<T> {
  33739. entries: T[];
  33740. blocks: Array<OctreeBlock<T>>;
  33741. private _depth;
  33742. private _maxDepth;
  33743. private _capacity;
  33744. private _minPoint;
  33745. private _maxPoint;
  33746. private _boundingVectors;
  33747. private _creationFunc;
  33748. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33749. readonly capacity: number;
  33750. readonly minPoint: Vector3;
  33751. readonly maxPoint: Vector3;
  33752. addEntry(entry: T): void;
  33753. addEntries(entries: T[]): void;
  33754. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33755. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33756. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33757. createInnerBlocks(): void;
  33758. }
  33759. }
  33760. declare module BABYLON {
  33761. interface Scene {
  33762. /**
  33763. * @hidden
  33764. * Backing Filed
  33765. */
  33766. /**
  33767. * Gets the octree used to boost mesh selection (picking)
  33768. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33769. */
  33770. selectionOctree: Octree<AbstractMesh>;
  33771. /**
  33772. * Creates or updates the octree used to boost selection (picking)
  33773. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33774. * @param maxCapacity defines the maximum capacity per leaf
  33775. * @param maxDepth defines the maximum depth of the octree
  33776. * @returns an octree of AbstractMesh
  33777. */
  33778. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  33779. }
  33780. interface AbstractMesh {
  33781. /**
  33782. * @hidden
  33783. * Backing Field
  33784. */
  33785. /**
  33786. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  33787. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  33788. * @param maxCapacity defines the maximum size of each block (64 by default)
  33789. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  33790. * @returns the new octree
  33791. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  33792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  33793. */
  33794. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  33795. }
  33796. /**
  33797. * Defines the octree scene component responsible to manage any octrees
  33798. * in a given scene.
  33799. */
  33800. class OctreeSceneComponent {
  33801. /**
  33802. * The component name helpfull to identify the component in the list of scene components.
  33803. */
  33804. readonly name: string;
  33805. /**
  33806. * The scene the component belongs to.
  33807. */
  33808. scene: Scene;
  33809. /**
  33810. * Indicates if the meshes have been checked to make sure they are isEnabled()
  33811. */
  33812. readonly checksIsEnabled: boolean;
  33813. /**
  33814. * Creates a new instance of the component for the given scene
  33815. * @param scene Defines the scene to register the component in
  33816. */
  33817. constructor(scene: Scene);
  33818. /**
  33819. * Registers the component in a given scene
  33820. */
  33821. register(): void;
  33822. /**
  33823. * Return the list of active meshes
  33824. * @returns the list of active meshes
  33825. */
  33826. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33827. /**
  33828. * Return the list of active sub meshes
  33829. * @param mesh The mesh to get the candidates sub meshes from
  33830. * @returns the list of active sub meshes
  33831. */
  33832. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33833. private _tempRay;
  33834. /**
  33835. * Return the list of sub meshes intersecting with a given local ray
  33836. * @param mesh defines the mesh to find the submesh for
  33837. * @param localRay defines the ray in local space
  33838. * @returns the list of intersecting sub meshes
  33839. */
  33840. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  33841. /**
  33842. * Return the list of sub meshes colliding with a collider
  33843. * @param mesh defines the mesh to find the submesh for
  33844. * @param collider defines the collider to evaluate the collision against
  33845. * @returns the list of colliding sub meshes
  33846. */
  33847. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  33848. /**
  33849. * Rebuilds the elements related to this component in case of
  33850. * context lost for instance.
  33851. */
  33852. rebuild(): void;
  33853. /**
  33854. * Disposes the component and the associated ressources.
  33855. */
  33856. dispose(): void;
  33857. }
  33858. }
  33859. declare module BABYLON {
  33860. interface Engine {
  33861. /**
  33862. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  33863. * @return the new query
  33864. */
  33865. createQuery(): WebGLQuery;
  33866. /**
  33867. * Delete and release a webGL query
  33868. * @param query defines the query to delete
  33869. * @return the current engine
  33870. */
  33871. deleteQuery(query: WebGLQuery): Engine;
  33872. /**
  33873. * Check if a given query has resolved and got its value
  33874. * @param query defines the query to check
  33875. * @returns true if the query got its value
  33876. */
  33877. isQueryResultAvailable(query: WebGLQuery): boolean;
  33878. /**
  33879. * Gets the value of a given query
  33880. * @param query defines the query to check
  33881. * @returns the value of the query
  33882. */
  33883. getQueryResult(query: WebGLQuery): number;
  33884. /**
  33885. * Initiates an occlusion query
  33886. * @param algorithmType defines the algorithm to use
  33887. * @param query defines the query to use
  33888. * @returns the current engine
  33889. * @see http://doc.babylonjs.com/features/occlusionquery
  33890. */
  33891. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33892. /**
  33893. * Ends an occlusion query
  33894. * @see http://doc.babylonjs.com/features/occlusionquery
  33895. * @param algorithmType defines the algorithm to use
  33896. * @returns the current engine
  33897. */
  33898. endOcclusionQuery(algorithmType: number): Engine;
  33899. /**
  33900. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33901. * Please note that only one query can be issued at a time
  33902. * @returns a time token used to track the time span
  33903. */
  33904. startTimeQuery(): Nullable<_TimeToken>;
  33905. /**
  33906. * Ends a time query
  33907. * @param token defines the token used to measure the time span
  33908. * @returns the time spent (in ns)
  33909. */
  33910. endTimeQuery(token: _TimeToken): int;
  33911. /** @hidden */
  33912. /** @hidden */
  33913. /** @hidden */
  33914. /** @hidden */
  33915. /** @hidden */
  33916. /** @hidden */
  33917. }
  33918. }
  33919. declare module BABYLON {
  33920. interface Engine {
  33921. /**
  33922. * Creates a webGL transform feedback object
  33923. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  33924. * @returns the webGL transform feedback object
  33925. */
  33926. createTransformFeedback(): WebGLTransformFeedback;
  33927. /**
  33928. * Delete a webGL transform feedback object
  33929. * @param value defines the webGL transform feedback object to delete
  33930. */
  33931. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  33932. /**
  33933. * Bind a webGL transform feedback object to the webgl context
  33934. * @param value defines the webGL transform feedback object to bind
  33935. */
  33936. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  33937. /**
  33938. * Begins a transform feedback operation
  33939. * @param usePoints defines if points or triangles must be used
  33940. */
  33941. beginTransformFeedback(usePoints: boolean): void;
  33942. /**
  33943. * Ends a transform feedback operation
  33944. */
  33945. endTransformFeedback(): void;
  33946. /**
  33947. * Specify the varyings to use with transform feedback
  33948. * @param program defines the associated webGL program
  33949. * @param value defines the list of strings representing the varying names
  33950. */
  33951. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  33952. /**
  33953. * Bind a webGL buffer for a transform feedback operation
  33954. * @param value defines the webGL buffer to bind
  33955. */
  33956. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  33957. }
  33958. }
  33959. declare module BABYLON {
  33960. /**
  33961. * Google Daydream controller
  33962. */
  33963. class DaydreamController extends WebVRController {
  33964. /**
  33965. * Base Url for the controller model.
  33966. */
  33967. static MODEL_BASE_URL: string;
  33968. /**
  33969. * File name for the controller model.
  33970. */
  33971. static MODEL_FILENAME: string;
  33972. /**
  33973. * Gamepad Id prefix used to identify Daydream Controller.
  33974. */
  33975. static readonly GAMEPAD_ID_PREFIX: string;
  33976. /**
  33977. * Creates a new DaydreamController from a gamepad
  33978. * @param vrGamepad the gamepad that the controller should be created from
  33979. */
  33980. constructor(vrGamepad: any);
  33981. /**
  33982. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33983. * @param scene scene in which to add meshes
  33984. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33985. */
  33986. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33987. /**
  33988. * Called once for each button that changed state since the last frame
  33989. * @param buttonIdx Which button index changed
  33990. * @param state New state of the button
  33991. * @param changes Which properties on the state changed since last frame
  33992. */
  33993. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33994. }
  33995. }
  33996. declare module BABYLON {
  33997. /**
  33998. * Gear VR Controller
  33999. */
  34000. class GearVRController extends WebVRController {
  34001. /**
  34002. * Base Url for the controller model.
  34003. */
  34004. static MODEL_BASE_URL: string;
  34005. /**
  34006. * File name for the controller model.
  34007. */
  34008. static MODEL_FILENAME: string;
  34009. private _maxRotationDistFromHeadset;
  34010. private _draggedRoomRotation;
  34011. private _tmpVector;
  34012. /**
  34013. * Gamepad Id prefix used to identify this controller.
  34014. */
  34015. static readonly GAMEPAD_ID_PREFIX: string;
  34016. private readonly _buttonIndexToObservableNameMap;
  34017. /**
  34018. * Creates a new GearVRController from a gamepad
  34019. * @param vrGamepad the gamepad that the controller should be created from
  34020. */
  34021. constructor(vrGamepad: any);
  34022. /**
  34023. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34024. * @param poseData raw pose fromthe device
  34025. */
  34026. updateFromDevice(poseData: DevicePose): void;
  34027. /**
  34028. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34029. * @param scene scene in which to add meshes
  34030. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34031. */
  34032. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34033. /**
  34034. * Called once for each button that changed state since the last frame
  34035. * @param buttonIdx Which button index changed
  34036. * @param state New state of the button
  34037. * @param changes Which properties on the state changed since last frame
  34038. */
  34039. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34040. }
  34041. }
  34042. declare module BABYLON {
  34043. /**
  34044. * Generic Controller
  34045. */
  34046. class GenericController extends WebVRController {
  34047. /**
  34048. * Base Url for the controller model.
  34049. */
  34050. static readonly MODEL_BASE_URL: string;
  34051. /**
  34052. * File name for the controller model.
  34053. */
  34054. static readonly MODEL_FILENAME: string;
  34055. /**
  34056. * Creates a new GenericController from a gamepad
  34057. * @param vrGamepad the gamepad that the controller should be created from
  34058. */
  34059. constructor(vrGamepad: any);
  34060. /**
  34061. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34062. * @param scene scene in which to add meshes
  34063. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34064. */
  34065. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34066. /**
  34067. * Called once for each button that changed state since the last frame
  34068. * @param buttonIdx Which button index changed
  34069. * @param state New state of the button
  34070. * @param changes Which properties on the state changed since last frame
  34071. */
  34072. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34073. }
  34074. }
  34075. declare module BABYLON {
  34076. /**
  34077. * Oculus Touch Controller
  34078. */
  34079. class OculusTouchController extends WebVRController {
  34080. /**
  34081. * Base Url for the controller model.
  34082. */
  34083. static MODEL_BASE_URL: string;
  34084. /**
  34085. * File name for the left controller model.
  34086. */
  34087. static MODEL_LEFT_FILENAME: string;
  34088. /**
  34089. * File name for the right controller model.
  34090. */
  34091. static MODEL_RIGHT_FILENAME: string;
  34092. /**
  34093. * Fired when the secondary trigger on this controller is modified
  34094. */
  34095. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34096. /**
  34097. * Fired when the thumb rest on this controller is modified
  34098. */
  34099. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34100. /**
  34101. * Creates a new OculusTouchController from a gamepad
  34102. * @param vrGamepad the gamepad that the controller should be created from
  34103. */
  34104. constructor(vrGamepad: any);
  34105. /**
  34106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34107. * @param scene scene in which to add meshes
  34108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34109. */
  34110. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34111. /**
  34112. * Fired when the A button on this controller is modified
  34113. */
  34114. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34115. /**
  34116. * Fired when the B button on this controller is modified
  34117. */
  34118. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34119. /**
  34120. * Fired when the X button on this controller is modified
  34121. */
  34122. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34123. /**
  34124. * Fired when the Y button on this controller is modified
  34125. */
  34126. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34127. /**
  34128. * Called once for each button that changed state since the last frame
  34129. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34130. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34131. * 2) secondary trigger (same)
  34132. * 3) A (right) X (left), touch, pressed = value
  34133. * 4) B / Y
  34134. * 5) thumb rest
  34135. * @param buttonIdx Which button index changed
  34136. * @param state New state of the button
  34137. * @param changes Which properties on the state changed since last frame
  34138. */
  34139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34140. }
  34141. }
  34142. declare module BABYLON {
  34143. /**
  34144. * Defines the types of pose enabled controllers that are supported
  34145. */
  34146. enum PoseEnabledControllerType {
  34147. /**
  34148. * HTC Vive
  34149. */
  34150. VIVE = 0,
  34151. /**
  34152. * Oculus Rift
  34153. */
  34154. OCULUS = 1,
  34155. /**
  34156. * Windows mixed reality
  34157. */
  34158. WINDOWS = 2,
  34159. /**
  34160. * Samsung gear VR
  34161. */
  34162. GEAR_VR = 3,
  34163. /**
  34164. * Google Daydream
  34165. */
  34166. DAYDREAM = 4,
  34167. /**
  34168. * Generic
  34169. */
  34170. GENERIC = 5
  34171. }
  34172. /**
  34173. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34174. */
  34175. interface MutableGamepadButton {
  34176. /**
  34177. * Value of the button/trigger
  34178. */
  34179. value: number;
  34180. /**
  34181. * If the button/trigger is currently touched
  34182. */
  34183. touched: boolean;
  34184. /**
  34185. * If the button/trigger is currently pressed
  34186. */
  34187. pressed: boolean;
  34188. }
  34189. /**
  34190. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34191. * @hidden
  34192. */
  34193. interface ExtendedGamepadButton extends GamepadButton {
  34194. /**
  34195. * If the button/trigger is currently pressed
  34196. */
  34197. readonly pressed: boolean;
  34198. /**
  34199. * If the button/trigger is currently touched
  34200. */
  34201. readonly touched: boolean;
  34202. /**
  34203. * Value of the button/trigger
  34204. */
  34205. readonly value: number;
  34206. }
  34207. /**
  34208. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34209. */
  34210. class PoseEnabledControllerHelper {
  34211. /**
  34212. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34213. * @param vrGamepad the gamepad to initialized
  34214. * @returns a vr controller of the type the gamepad identified as
  34215. */
  34216. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  34217. }
  34218. /**
  34219. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34220. */
  34221. class PoseEnabledController extends Gamepad implements PoseControlled {
  34222. private _deviceRoomPosition;
  34223. private _deviceRoomRotationQuaternion;
  34224. /**
  34225. * The device position in babylon space
  34226. */
  34227. devicePosition: Vector3;
  34228. /**
  34229. * The device rotation in babylon space
  34230. */
  34231. deviceRotationQuaternion: Quaternion;
  34232. /**
  34233. * The scale factor of the device in babylon space
  34234. */
  34235. deviceScaleFactor: number;
  34236. /**
  34237. * (Likely devicePosition should be used instead) The device position in its room space
  34238. */
  34239. position: Vector3;
  34240. /**
  34241. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34242. */
  34243. rotationQuaternion: Quaternion;
  34244. /**
  34245. * The type of controller (Eg. Windows mixed reality)
  34246. */
  34247. controllerType: PoseEnabledControllerType;
  34248. protected _calculatedPosition: Vector3;
  34249. private _calculatedRotation;
  34250. /**
  34251. * The raw pose from the device
  34252. */
  34253. rawPose: DevicePose;
  34254. /**
  34255. * Internal, the mesh attached to the controller
  34256. * @hidden
  34257. */
  34258. private _poseControlledCamera;
  34259. private _leftHandSystemQuaternion;
  34260. /**
  34261. * Internal, matrix used to convert room space to babylon space
  34262. * @hidden
  34263. */
  34264. /**
  34265. * Node to be used when casting a ray from the controller
  34266. * @hidden
  34267. */
  34268. /**
  34269. * Name of the child mesh that can be used to cast a ray from the controller
  34270. */
  34271. static readonly POINTING_POSE: string;
  34272. /**
  34273. * Creates a new PoseEnabledController from a gamepad
  34274. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34275. */
  34276. constructor(browserGamepad: any);
  34277. private _workingMatrix;
  34278. /**
  34279. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34280. */
  34281. update(): void;
  34282. /**
  34283. * Updates only the pose device and mesh without doing any button event checking
  34284. */
  34285. protected _updatePoseAndMesh(): void;
  34286. /**
  34287. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34288. * @param poseData raw pose fromthe device
  34289. */
  34290. updateFromDevice(poseData: DevicePose): void;
  34291. /**
  34292. * @hidden
  34293. */
  34294. /**
  34295. * Attaches a mesh to the controller
  34296. * @param mesh the mesh to be attached
  34297. */
  34298. attachToMesh(mesh: AbstractMesh): void;
  34299. /**
  34300. * Attaches the controllers mesh to a camera
  34301. * @param camera the camera the mesh should be attached to
  34302. */
  34303. attachToPoseControlledCamera(camera: TargetCamera): void;
  34304. /**
  34305. * Disposes of the controller
  34306. */
  34307. dispose(): void;
  34308. /**
  34309. * The mesh that is attached to the controller
  34310. */
  34311. readonly mesh: Nullable<AbstractMesh>;
  34312. /**
  34313. * Gets the ray of the controller in the direction the controller is pointing
  34314. * @param length the length the resulting ray should be
  34315. * @returns a ray in the direction the controller is pointing
  34316. */
  34317. getForwardRay(length?: number): Ray;
  34318. }
  34319. }
  34320. declare module BABYLON {
  34321. /**
  34322. * Vive Controller
  34323. */
  34324. class ViveController extends WebVRController {
  34325. /**
  34326. * Base Url for the controller model.
  34327. */
  34328. static MODEL_BASE_URL: string;
  34329. /**
  34330. * File name for the controller model.
  34331. */
  34332. static MODEL_FILENAME: string;
  34333. /**
  34334. * Creates a new ViveController from a gamepad
  34335. * @param vrGamepad the gamepad that the controller should be created from
  34336. */
  34337. constructor(vrGamepad: any);
  34338. /**
  34339. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34340. * @param scene scene in which to add meshes
  34341. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34342. */
  34343. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34344. /**
  34345. * Fired when the left button on this controller is modified
  34346. */
  34347. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34348. /**
  34349. * Fired when the right button on this controller is modified
  34350. */
  34351. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34352. /**
  34353. * Fired when the menu button on this controller is modified
  34354. */
  34355. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34356. /**
  34357. * Called once for each button that changed state since the last frame
  34358. * Vive mapping:
  34359. * 0: touchpad
  34360. * 1: trigger
  34361. * 2: left AND right buttons
  34362. * 3: menu button
  34363. * @param buttonIdx Which button index changed
  34364. * @param state New state of the button
  34365. * @param changes Which properties on the state changed since last frame
  34366. */
  34367. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34368. }
  34369. }
  34370. declare module BABYLON {
  34371. /**
  34372. * Defines the WebVRController object that represents controllers tracked in 3D space
  34373. */
  34374. abstract class WebVRController extends PoseEnabledController {
  34375. /**
  34376. * Internal, the default controller model for the controller
  34377. */
  34378. protected _defaultModel: AbstractMesh;
  34379. /**
  34380. * Fired when the trigger state has changed
  34381. */
  34382. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34383. /**
  34384. * Fired when the main button state has changed
  34385. */
  34386. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34387. /**
  34388. * Fired when the secondary button state has changed
  34389. */
  34390. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34391. /**
  34392. * Fired when the pad state has changed
  34393. */
  34394. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34395. /**
  34396. * Fired when controllers stick values have changed
  34397. */
  34398. onPadValuesChangedObservable: Observable<StickValues>;
  34399. /**
  34400. * Array of button availible on the controller
  34401. */
  34402. protected _buttons: Array<MutableGamepadButton>;
  34403. private _onButtonStateChange;
  34404. /**
  34405. * Fired when a controller button's state has changed
  34406. * @param callback the callback containing the button that was modified
  34407. */
  34408. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34409. /**
  34410. * X and Y axis corrisponding to the controllers joystick
  34411. */
  34412. pad: StickValues;
  34413. /**
  34414. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34415. */
  34416. hand: string;
  34417. /**
  34418. * The default controller model for the controller
  34419. */
  34420. readonly defaultModel: AbstractMesh;
  34421. /**
  34422. * Creates a new WebVRController from a gamepad
  34423. * @param vrGamepad the gamepad that the WebVRController should be created from
  34424. */
  34425. constructor(vrGamepad: any);
  34426. /**
  34427. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34428. */
  34429. update(): void;
  34430. /**
  34431. * Function to be called when a button is modified
  34432. */
  34433. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34434. /**
  34435. * Loads a mesh and attaches it to the controller
  34436. * @param scene the scene the mesh should be added to
  34437. * @param meshLoaded callback for when the mesh has been loaded
  34438. */
  34439. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34440. private _setButtonValue;
  34441. private _changes;
  34442. private _checkChanges;
  34443. /**
  34444. * Disposes of th webVRCOntroller
  34445. */
  34446. dispose(): void;
  34447. }
  34448. }
  34449. declare module BABYLON {
  34450. /**
  34451. * Defines the WindowsMotionController object that the state of the windows motion controller
  34452. */
  34453. class WindowsMotionController extends WebVRController {
  34454. /**
  34455. * The base url used to load the left and right controller models
  34456. */
  34457. static MODEL_BASE_URL: string;
  34458. /**
  34459. * The name of the left controller model file
  34460. */
  34461. static MODEL_LEFT_FILENAME: string;
  34462. /**
  34463. * The name of the right controller model file
  34464. */
  34465. static MODEL_RIGHT_FILENAME: string;
  34466. /**
  34467. * The controller name prefix for this controller type
  34468. */
  34469. static readonly GAMEPAD_ID_PREFIX: string;
  34470. /**
  34471. * The controller id pattern for this controller type
  34472. */
  34473. private static readonly GAMEPAD_ID_PATTERN;
  34474. private _loadedMeshInfo;
  34475. private readonly _mapping;
  34476. /**
  34477. * Fired when the trackpad on this controller is clicked
  34478. */
  34479. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34480. /**
  34481. * Fired when the trackpad on this controller is modified
  34482. */
  34483. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34484. /**
  34485. * The current x and y values of this controller's trackpad
  34486. */
  34487. trackpad: StickValues;
  34488. /**
  34489. * Creates a new WindowsMotionController from a gamepad
  34490. * @param vrGamepad the gamepad that the controller should be created from
  34491. */
  34492. constructor(vrGamepad: any);
  34493. /**
  34494. * Fired when the trigger on this controller is modified
  34495. */
  34496. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34497. /**
  34498. * Fired when the menu button on this controller is modified
  34499. */
  34500. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34501. /**
  34502. * Fired when the grip button on this controller is modified
  34503. */
  34504. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34505. /**
  34506. * Fired when the thumbstick button on this controller is modified
  34507. */
  34508. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34509. /**
  34510. * Fired when the touchpad button on this controller is modified
  34511. */
  34512. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34513. /**
  34514. * Fired when the touchpad values on this controller are modified
  34515. */
  34516. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34517. private _updateTrackpad;
  34518. /**
  34519. * Called once per frame by the engine.
  34520. */
  34521. update(): void;
  34522. /**
  34523. * Called once for each button that changed state since the last frame
  34524. * @param buttonIdx Which button index changed
  34525. * @param state New state of the button
  34526. * @param changes Which properties on the state changed since last frame
  34527. */
  34528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34529. /**
  34530. * Moves the buttons on the controller mesh based on their current state
  34531. * @param buttonName the name of the button to move
  34532. * @param buttonValue the value of the button which determines the buttons new position
  34533. */
  34534. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34535. /**
  34536. * Moves the axis on the controller mesh based on its current state
  34537. * @param axis the index of the axis
  34538. * @param axisValue the value of the axis which determines the meshes new position
  34539. * @hidden
  34540. */
  34541. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34542. /**
  34543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34544. * @param scene scene in which to add meshes
  34545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34546. */
  34547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34548. /**
  34549. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34550. * can be transformed by button presses and axes values, based on this._mapping.
  34551. *
  34552. * @param scene scene in which the meshes exist
  34553. * @param meshes list of meshes that make up the controller model to process
  34554. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34555. */
  34556. private processModel;
  34557. private createMeshInfo;
  34558. /**
  34559. * Gets the ray of the controller in the direction the controller is pointing
  34560. * @param length the length the resulting ray should be
  34561. * @returns a ray in the direction the controller is pointing
  34562. */
  34563. getForwardRay(length?: number): Ray;
  34564. /**
  34565. * Disposes of the controller
  34566. */
  34567. dispose(): void;
  34568. }
  34569. }
  34570. declare module BABYLON {
  34571. /**
  34572. * Interface to implement to create a shadow generator compatible with BJS.
  34573. */
  34574. interface IShadowGenerator {
  34575. /**
  34576. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34577. * @returns The render target texture if present otherwise, null
  34578. */
  34579. getShadowMap(): Nullable<RenderTargetTexture>;
  34580. /**
  34581. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34582. * @returns The render target texture if the shadow map is present otherwise, null
  34583. */
  34584. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34585. /**
  34586. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34587. * @param subMesh The submesh we want to render in the shadow map
  34588. * @param useInstances Defines wether will draw in the map using instances
  34589. * @returns true if ready otherwise, false
  34590. */
  34591. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34592. /**
  34593. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34594. * @param defines Defines of the material we want to update
  34595. * @param lightIndex Index of the light in the enabled light list of the material
  34596. */
  34597. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34598. /**
  34599. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34600. * defined in the generator but impacting the effect).
  34601. * It implies the unifroms available on the materials are the standard BJS ones.
  34602. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34603. * @param effect The effect we are binfing the information for
  34604. */
  34605. bindShadowLight(lightIndex: string, effect: Effect): void;
  34606. /**
  34607. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34608. * (eq to shadow prjection matrix * light transform matrix)
  34609. * @returns The transform matrix used to create the shadow map
  34610. */
  34611. getTransformMatrix(): Matrix;
  34612. /**
  34613. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34614. * Cube and 2D textures for instance.
  34615. */
  34616. recreateShadowMap(): void;
  34617. /**
  34618. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34619. * @param onCompiled Callback triggered at the and of the effects compilation
  34620. * @param options Sets of optional options forcing the compilation with different modes
  34621. */
  34622. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34623. useInstances: boolean;
  34624. }>): void;
  34625. /**
  34626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34627. * @param options Sets of optional options forcing the compilation with different modes
  34628. * @returns A promise that resolves when the compilation completes
  34629. */
  34630. forceCompilationAsync(options?: Partial<{
  34631. useInstances: boolean;
  34632. }>): Promise<void>;
  34633. /**
  34634. * Serializes the shadow generator setup to a json object.
  34635. * @returns The serialized JSON object
  34636. */
  34637. serialize(): any;
  34638. /**
  34639. * Disposes the Shadow map and related Textures and effects.
  34640. */
  34641. dispose(): void;
  34642. }
  34643. /**
  34644. * Default implementation IShadowGenerator.
  34645. * This is the main object responsible of generating shadows in the framework.
  34646. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34647. */
  34648. class ShadowGenerator implements IShadowGenerator {
  34649. /**
  34650. * Shadow generator mode None: no filtering applied.
  34651. */
  34652. static readonly FILTER_NONE: number;
  34653. /**
  34654. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34655. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34656. */
  34657. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34658. /**
  34659. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34660. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34661. */
  34662. static readonly FILTER_POISSONSAMPLING: number;
  34663. /**
  34664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34665. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34666. */
  34667. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34668. /**
  34669. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34670. * edge artifacts on steep falloff.
  34671. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34672. */
  34673. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34674. /**
  34675. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34676. * edge artifacts on steep falloff.
  34677. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34678. */
  34679. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34680. /**
  34681. * Shadow generator mode PCF: Percentage Closer Filtering
  34682. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34683. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34684. */
  34685. static readonly FILTER_PCF: number;
  34686. /**
  34687. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34688. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34689. * Contact Hardening
  34690. */
  34691. static readonly FILTER_PCSS: number;
  34692. /**
  34693. * Reserved for PCF and PCSS
  34694. * Highest Quality.
  34695. *
  34696. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34697. *
  34698. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34699. */
  34700. static readonly QUALITY_HIGH: number;
  34701. /**
  34702. * Reserved for PCF and PCSS
  34703. * Good tradeoff for quality/perf cross devices
  34704. *
  34705. * Execute PCF on a 3*3 kernel.
  34706. *
  34707. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34708. */
  34709. static readonly QUALITY_MEDIUM: number;
  34710. /**
  34711. * Reserved for PCF and PCSS
  34712. * The lowest quality but the fastest.
  34713. *
  34714. * Execute PCF on a 1*1 kernel.
  34715. *
  34716. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34717. */
  34718. static readonly QUALITY_LOW: number;
  34719. private _bias;
  34720. /**
  34721. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34722. */
  34723. /**
  34724. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34725. */
  34726. bias: number;
  34727. private _normalBias;
  34728. /**
  34729. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34730. */
  34731. /**
  34732. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34733. */
  34734. normalBias: number;
  34735. private _blurBoxOffset;
  34736. /**
  34737. * Gets the blur box offset: offset applied during the blur pass.
  34738. * Only usefull if useKernelBlur = false
  34739. */
  34740. /**
  34741. * Sets the blur box offset: offset applied during the blur pass.
  34742. * Only usefull if useKernelBlur = false
  34743. */
  34744. blurBoxOffset: number;
  34745. private _blurScale;
  34746. /**
  34747. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34748. * 2 means half of the size.
  34749. */
  34750. /**
  34751. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34752. * 2 means half of the size.
  34753. */
  34754. blurScale: number;
  34755. private _blurKernel;
  34756. /**
  34757. * Gets the blur kernel: kernel size of the blur pass.
  34758. * Only usefull if useKernelBlur = true
  34759. */
  34760. /**
  34761. * Sets the blur kernel: kernel size of the blur pass.
  34762. * Only usefull if useKernelBlur = true
  34763. */
  34764. blurKernel: number;
  34765. private _useKernelBlur;
  34766. /**
  34767. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34768. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34769. */
  34770. /**
  34771. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34772. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34773. */
  34774. useKernelBlur: boolean;
  34775. private _depthScale;
  34776. /**
  34777. * Gets the depth scale used in ESM mode.
  34778. */
  34779. /**
  34780. * Sets the depth scale used in ESM mode.
  34781. * This can override the scale stored on the light.
  34782. */
  34783. depthScale: number;
  34784. private _filter;
  34785. /**
  34786. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34787. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34788. */
  34789. /**
  34790. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34791. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34792. */
  34793. filter: number;
  34794. /**
  34795. * Gets if the current filter is set to Poisson Sampling.
  34796. */
  34797. /**
  34798. * Sets the current filter to Poisson Sampling.
  34799. */
  34800. usePoissonSampling: boolean;
  34801. /**
  34802. * Gets if the current filter is set to VSM.
  34803. * DEPRECATED. Should use useExponentialShadowMap instead.
  34804. */
  34805. /**
  34806. * Sets the current filter is to VSM.
  34807. * DEPRECATED. Should use useExponentialShadowMap instead.
  34808. */
  34809. useVarianceShadowMap: boolean;
  34810. /**
  34811. * Gets if the current filter is set to blurred VSM.
  34812. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34813. */
  34814. /**
  34815. * Sets the current filter is to blurred VSM.
  34816. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34817. */
  34818. useBlurVarianceShadowMap: boolean;
  34819. /**
  34820. * Gets if the current filter is set to ESM.
  34821. */
  34822. /**
  34823. * Sets the current filter is to ESM.
  34824. */
  34825. useExponentialShadowMap: boolean;
  34826. /**
  34827. * Gets if the current filter is set to filtered ESM.
  34828. */
  34829. /**
  34830. * Gets if the current filter is set to filtered ESM.
  34831. */
  34832. useBlurExponentialShadowMap: boolean;
  34833. /**
  34834. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34835. * exponential to prevent steep falloff artifacts).
  34836. */
  34837. /**
  34838. * Sets the current filter to "close ESM" (using the inverse of the
  34839. * exponential to prevent steep falloff artifacts).
  34840. */
  34841. useCloseExponentialShadowMap: boolean;
  34842. /**
  34843. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34844. * exponential to prevent steep falloff artifacts).
  34845. */
  34846. /**
  34847. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34848. * exponential to prevent steep falloff artifacts).
  34849. */
  34850. useBlurCloseExponentialShadowMap: boolean;
  34851. /**
  34852. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34853. */
  34854. /**
  34855. * Sets the current filter to "PCF" (percentage closer filtering).
  34856. */
  34857. usePercentageCloserFiltering: boolean;
  34858. private _filteringQuality;
  34859. /**
  34860. * Gets the PCF or PCSS Quality.
  34861. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34862. */
  34863. /**
  34864. * Sets the PCF or PCSS Quality.
  34865. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34866. */
  34867. filteringQuality: number;
  34868. /**
  34869. * Gets if the current filter is set to "PCSS" (contact hardening).
  34870. */
  34871. /**
  34872. * Sets the current filter to "PCSS" (contact hardening).
  34873. */
  34874. useContactHardeningShadow: boolean;
  34875. private _contactHardeningLightSizeUVRatio;
  34876. /**
  34877. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34878. * Using a ratio helps keeping shape stability independently of the map size.
  34879. *
  34880. * It does not account for the light projection as it was having too much
  34881. * instability during the light setup or during light position changes.
  34882. *
  34883. * Only valid if useContactHardeningShadow is true.
  34884. */
  34885. /**
  34886. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34887. * Using a ratio helps keeping shape stability independently of the map size.
  34888. *
  34889. * It does not account for the light projection as it was having too much
  34890. * instability during the light setup or during light position changes.
  34891. *
  34892. * Only valid if useContactHardeningShadow is true.
  34893. */
  34894. contactHardeningLightSizeUVRatio: number;
  34895. private _darkness;
  34896. /**
  34897. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34898. * 0 means strongest and 1 would means no shadow.
  34899. * @returns the darkness.
  34900. */
  34901. getDarkness(): number;
  34902. /**
  34903. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34904. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34905. * @returns the shadow generator allowing fluent coding.
  34906. */
  34907. setDarkness(darkness: number): ShadowGenerator;
  34908. private _transparencyShadow;
  34909. /**
  34910. * Sets the ability to have transparent shadow (boolean).
  34911. * @param transparent True if transparent else False
  34912. * @returns the shadow generator allowing fluent coding
  34913. */
  34914. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34915. private _shadowMap;
  34916. private _shadowMap2;
  34917. /**
  34918. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34919. * @returns The render target texture if present otherwise, null
  34920. */
  34921. getShadowMap(): Nullable<RenderTargetTexture>;
  34922. /**
  34923. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34924. * @returns The render target texture if the shadow map is present otherwise, null
  34925. */
  34926. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34927. /**
  34928. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34929. * @param mesh Mesh to add
  34930. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34931. * @returns the Shadow Generator itself
  34932. */
  34933. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34934. /**
  34935. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34936. * @param mesh Mesh to remove
  34937. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34938. * @returns the Shadow Generator itself
  34939. */
  34940. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34941. /**
  34942. * Controls the extent to which the shadows fade out at the edge of the frustum
  34943. * Used only by directionals and spots
  34944. */
  34945. frustumEdgeFalloff: number;
  34946. private _light;
  34947. /**
  34948. * Returns the associated light object.
  34949. * @returns the light generating the shadow
  34950. */
  34951. getLight(): IShadowLight;
  34952. /**
  34953. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34954. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34955. * It might on the other hand introduce peter panning.
  34956. */
  34957. forceBackFacesOnly: boolean;
  34958. private _scene;
  34959. private _lightDirection;
  34960. private _effect;
  34961. private _viewMatrix;
  34962. private _projectionMatrix;
  34963. private _transformMatrix;
  34964. private _cachedPosition;
  34965. private _cachedDirection;
  34966. private _cachedDefines;
  34967. private _currentRenderID;
  34968. private _boxBlurPostprocess;
  34969. private _kernelBlurXPostprocess;
  34970. private _kernelBlurYPostprocess;
  34971. private _blurPostProcesses;
  34972. private _mapSize;
  34973. private _currentFaceIndex;
  34974. private _currentFaceIndexCache;
  34975. private _textureType;
  34976. private _defaultTextureMatrix;
  34977. /**
  34978. * Creates a ShadowGenerator object.
  34979. * A ShadowGenerator is the required tool to use the shadows.
  34980. * Each light casting shadows needs to use its own ShadowGenerator.
  34981. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34982. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34983. * @param light The light object generating the shadows.
  34984. * @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.
  34985. */
  34986. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34987. private _initializeGenerator;
  34988. private _initializeShadowMap;
  34989. private _initializeBlurRTTAndPostProcesses;
  34990. private _renderForShadowMap;
  34991. private _renderSubMeshForShadowMap;
  34992. private _applyFilterValues;
  34993. /**
  34994. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34995. * @param onCompiled Callback triggered at the and of the effects compilation
  34996. * @param options Sets of optional options forcing the compilation with different modes
  34997. */
  34998. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34999. useInstances: boolean;
  35000. }>): void;
  35001. /**
  35002. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35003. * @param options Sets of optional options forcing the compilation with different modes
  35004. * @returns A promise that resolves when the compilation completes
  35005. */
  35006. forceCompilationAsync(options?: Partial<{
  35007. useInstances: boolean;
  35008. }>): Promise<void>;
  35009. /**
  35010. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35011. * @param subMesh The submesh we want to render in the shadow map
  35012. * @param useInstances Defines wether will draw in the map using instances
  35013. * @returns true if ready otherwise, false
  35014. */
  35015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35016. /**
  35017. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35018. * @param defines Defines of the material we want to update
  35019. * @param lightIndex Index of the light in the enabled light list of the material
  35020. */
  35021. prepareDefines(defines: any, lightIndex: number): void;
  35022. /**
  35023. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35024. * defined in the generator but impacting the effect).
  35025. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35026. * @param effect The effect we are binfing the information for
  35027. */
  35028. bindShadowLight(lightIndex: string, effect: Effect): void;
  35029. /**
  35030. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35031. * (eq to shadow prjection matrix * light transform matrix)
  35032. * @returns The transform matrix used to create the shadow map
  35033. */
  35034. getTransformMatrix(): Matrix;
  35035. /**
  35036. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35037. * Cube and 2D textures for instance.
  35038. */
  35039. recreateShadowMap(): void;
  35040. private _disposeBlurPostProcesses;
  35041. private _disposeRTTandPostProcesses;
  35042. /**
  35043. * Disposes the ShadowGenerator.
  35044. * Returns nothing.
  35045. */
  35046. dispose(): void;
  35047. /**
  35048. * Serializes the shadow generator setup to a json object.
  35049. * @returns The serialized JSON object
  35050. */
  35051. serialize(): any;
  35052. /**
  35053. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35054. * @param parsedShadowGenerator The JSON object to parse
  35055. * @param scene The scene to create the shadow map for
  35056. * @returns The parsed shadow generator
  35057. */
  35058. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35059. }
  35060. }
  35061. declare module BABYLON {
  35062. /**
  35063. * Defines the shadow generator component responsible to manage any shadow generators
  35064. * in a given scene.
  35065. */
  35066. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  35067. /**
  35068. * The component name helpfull to identify the component in the list of scene components.
  35069. */
  35070. readonly name: string;
  35071. /**
  35072. * The scene the component belongs to.
  35073. */
  35074. scene: Scene;
  35075. /**
  35076. * Creates a new instance of the component for the given scene
  35077. * @param scene Defines the scene to register the component in
  35078. */
  35079. constructor(scene: Scene);
  35080. /**
  35081. * Registers the component in a given scene
  35082. */
  35083. register(): void;
  35084. /**
  35085. * Rebuilds the elements related to this component in case of
  35086. * context lost for instance.
  35087. */
  35088. rebuild(): void;
  35089. /**
  35090. * Serializes the component data to the specified json object
  35091. * @param serializationObject The object to serialize to
  35092. */
  35093. serialize(serializationObject: any): void;
  35094. /**
  35095. * Adds all the element from the container to the scene
  35096. * @param container the container holding the elements
  35097. */
  35098. addFromContainer(container: AbstractScene): void;
  35099. /**
  35100. * Removes all the elements in the container from the scene
  35101. * @param container contains the elements to remove
  35102. */
  35103. removeFromContainer(container: AbstractScene): void;
  35104. /**
  35105. * Rebuilds the elements related to this component in case of
  35106. * context lost for instance.
  35107. */
  35108. dispose(): void;
  35109. private _gatherRenderTargets;
  35110. }
  35111. }
  35112. declare module BABYLON {
  35113. }
  35114. declare module BABYLON {
  35115. /**
  35116. * Background material used to create an efficient environement around your scene.
  35117. */
  35118. class BackgroundMaterial extends PushMaterial {
  35119. /**
  35120. * Standard reflectance value at parallel view angle.
  35121. */
  35122. static StandardReflectance0: number;
  35123. /**
  35124. * Standard reflectance value at grazing angle.
  35125. */
  35126. static StandardReflectance90: number;
  35127. protected _primaryColor: Color3;
  35128. /**
  35129. * Key light Color (multiply against the environement texture)
  35130. */
  35131. primaryColor: Color3;
  35132. protected __perceptualColor: Nullable<Color3>;
  35133. /**
  35134. * Experimental Internal Use Only.
  35135. *
  35136. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  35137. * This acts as a helper to set the primary color to a more "human friendly" value.
  35138. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  35139. * output color as close as possible from the chosen value.
  35140. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  35141. * part of lighting setup.)
  35142. */
  35143. protected _primaryColorShadowLevel: float;
  35144. /**
  35145. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  35146. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  35147. */
  35148. primaryColorShadowLevel: float;
  35149. protected _primaryColorHighlightLevel: float;
  35150. /**
  35151. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  35152. * The primary color is used at the level chosen to define what the white area would look.
  35153. */
  35154. primaryColorHighlightLevel: float;
  35155. protected _reflectionTexture: Nullable<BaseTexture>;
  35156. /**
  35157. * Reflection Texture used in the material.
  35158. * Should be author in a specific way for the best result (refer to the documentation).
  35159. */
  35160. reflectionTexture: Nullable<BaseTexture>;
  35161. protected _reflectionBlur: float;
  35162. /**
  35163. * Reflection Texture level of blur.
  35164. *
  35165. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  35166. * texture twice.
  35167. */
  35168. reflectionBlur: float;
  35169. protected _diffuseTexture: Nullable<BaseTexture>;
  35170. /**
  35171. * Diffuse Texture used in the material.
  35172. * Should be author in a specific way for the best result (refer to the documentation).
  35173. */
  35174. diffuseTexture: Nullable<BaseTexture>;
  35175. protected _shadowLights: Nullable<IShadowLight[]>;
  35176. /**
  35177. * Specify the list of lights casting shadow on the material.
  35178. * All scene shadow lights will be included if null.
  35179. */
  35180. shadowLights: Nullable<IShadowLight[]>;
  35181. protected _shadowLevel: float;
  35182. /**
  35183. * Helps adjusting the shadow to a softer level if required.
  35184. * 0 means black shadows and 1 means no shadows.
  35185. */
  35186. shadowLevel: float;
  35187. protected _sceneCenter: Vector3;
  35188. /**
  35189. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  35190. * It is usually zero but might be interesting to modify according to your setup.
  35191. */
  35192. sceneCenter: Vector3;
  35193. protected _opacityFresnel: boolean;
  35194. /**
  35195. * This helps specifying that the material is falling off to the sky box at grazing angle.
  35196. * This helps ensuring a nice transition when the camera goes under the ground.
  35197. */
  35198. opacityFresnel: boolean;
  35199. protected _reflectionFresnel: boolean;
  35200. /**
  35201. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  35202. * This helps adding a mirror texture on the ground.
  35203. */
  35204. reflectionFresnel: boolean;
  35205. protected _reflectionFalloffDistance: number;
  35206. /**
  35207. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  35208. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  35209. */
  35210. reflectionFalloffDistance: number;
  35211. protected _reflectionAmount: number;
  35212. /**
  35213. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  35214. */
  35215. reflectionAmount: number;
  35216. protected _reflectionReflectance0: number;
  35217. /**
  35218. * This specifies the weight of the reflection at grazing angle.
  35219. */
  35220. reflectionReflectance0: number;
  35221. protected _reflectionReflectance90: number;
  35222. /**
  35223. * This specifies the weight of the reflection at a perpendicular point of view.
  35224. */
  35225. reflectionReflectance90: number;
  35226. /**
  35227. * Sets the reflection reflectance fresnel values according to the default standard
  35228. * empirically know to work well :-)
  35229. */
  35230. reflectionStandardFresnelWeight: number;
  35231. protected _useRGBColor: boolean;
  35232. /**
  35233. * Helps to directly use the maps channels instead of their level.
  35234. */
  35235. useRGBColor: boolean;
  35236. protected _enableNoise: boolean;
  35237. /**
  35238. * This helps reducing the banding effect that could occur on the background.
  35239. */
  35240. enableNoise: boolean;
  35241. /**
  35242. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  35243. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  35244. * Recommended to be keep at 1.0 except for special cases.
  35245. */
  35246. fovMultiplier: number;
  35247. private _fovMultiplier;
  35248. /**
  35249. * Enable the FOV adjustment feature controlled by fovMultiplier.
  35250. */
  35251. useEquirectangularFOV: boolean;
  35252. private _maxSimultaneousLights;
  35253. /**
  35254. * Number of Simultaneous lights allowed on the material.
  35255. */
  35256. maxSimultaneousLights: int;
  35257. /**
  35258. * Default configuration related to image processing available in the Background Material.
  35259. */
  35260. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35261. /**
  35262. * Keep track of the image processing observer to allow dispose and replace.
  35263. */
  35264. private _imageProcessingObserver;
  35265. /**
  35266. * Attaches a new image processing configuration to the PBR Material.
  35267. * @param configuration (if null the scene configuration will be use)
  35268. */
  35269. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35270. /**
  35271. * Gets the image processing configuration used either in this material.
  35272. */
  35273. /**
  35274. * Sets the Default image processing configuration used either in the this material.
  35275. *
  35276. * If sets to null, the scene one is in use.
  35277. */
  35278. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  35279. /**
  35280. * Gets wether the color curves effect is enabled.
  35281. */
  35282. /**
  35283. * Sets wether the color curves effect is enabled.
  35284. */
  35285. cameraColorCurvesEnabled: boolean;
  35286. /**
  35287. * Gets wether the color grading effect is enabled.
  35288. */
  35289. /**
  35290. * Gets wether the color grading effect is enabled.
  35291. */
  35292. cameraColorGradingEnabled: boolean;
  35293. /**
  35294. * Gets wether tonemapping is enabled or not.
  35295. */
  35296. /**
  35297. * Sets wether tonemapping is enabled or not
  35298. */
  35299. cameraToneMappingEnabled: boolean;
  35300. /**
  35301. * The camera exposure used on this material.
  35302. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35303. * This corresponds to a photographic exposure.
  35304. */
  35305. /**
  35306. * The camera exposure used on this material.
  35307. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35308. * This corresponds to a photographic exposure.
  35309. */
  35310. cameraExposure: float;
  35311. /**
  35312. * Gets The camera contrast used on this material.
  35313. */
  35314. /**
  35315. * Sets The camera contrast used on this material.
  35316. */
  35317. cameraContrast: float;
  35318. /**
  35319. * Gets the Color Grading 2D Lookup Texture.
  35320. */
  35321. /**
  35322. * Sets the Color Grading 2D Lookup Texture.
  35323. */
  35324. cameraColorGradingTexture: Nullable<BaseTexture>;
  35325. /**
  35326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35328. * 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;
  35329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35330. */
  35331. /**
  35332. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35333. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35334. * 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;
  35335. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35336. */
  35337. cameraColorCurves: Nullable<ColorCurves>;
  35338. /**
  35339. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  35340. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  35341. */
  35342. switchToBGR: boolean;
  35343. private _renderTargets;
  35344. private _reflectionControls;
  35345. private _white;
  35346. private _primaryShadowColor;
  35347. private _primaryHighlightColor;
  35348. /**
  35349. * Instantiates a Background Material in the given scene
  35350. * @param name The friendly name of the material
  35351. * @param scene The scene to add the material to
  35352. */
  35353. constructor(name: string, scene: Scene);
  35354. /**
  35355. * The entire material has been created in order to prevent overdraw.
  35356. * @returns false
  35357. */
  35358. needAlphaTesting(): boolean;
  35359. /**
  35360. * The entire material has been created in order to prevent overdraw.
  35361. * @returns true if blending is enable
  35362. */
  35363. needAlphaBlending(): boolean;
  35364. /**
  35365. * Checks wether the material is ready to be rendered for a given mesh.
  35366. * @param mesh The mesh to render
  35367. * @param subMesh The submesh to check against
  35368. * @param useInstances Specify wether or not the material is used with instances
  35369. * @returns true if all the dependencies are ready (Textures, Effects...)
  35370. */
  35371. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35372. /**
  35373. * Compute the primary color according to the chosen perceptual color.
  35374. */
  35375. private _computePrimaryColorFromPerceptualColor;
  35376. /**
  35377. * Compute the highlights and shadow colors according to their chosen levels.
  35378. */
  35379. private _computePrimaryColors;
  35380. /**
  35381. * Build the uniform buffer used in the material.
  35382. */
  35383. buildUniformLayout(): void;
  35384. /**
  35385. * Unbind the material.
  35386. */
  35387. unbind(): void;
  35388. /**
  35389. * Bind only the world matrix to the material.
  35390. * @param world The world matrix to bind.
  35391. */
  35392. bindOnlyWorldMatrix(world: Matrix): void;
  35393. /**
  35394. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  35395. * @param world The world matrix to bind.
  35396. * @param subMesh The submesh to bind for.
  35397. */
  35398. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35399. /**
  35400. * Dispose the material.
  35401. * @param forceDisposeEffect Force disposal of the associated effect.
  35402. * @param forceDisposeTextures Force disposal of the associated textures.
  35403. */
  35404. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35405. /**
  35406. * Clones the material.
  35407. * @param name The cloned name.
  35408. * @returns The cloned material.
  35409. */
  35410. clone(name: string): BackgroundMaterial;
  35411. /**
  35412. * Serializes the current material to its JSON representation.
  35413. * @returns The JSON representation.
  35414. */
  35415. serialize(): any;
  35416. /**
  35417. * Gets the class name of the material
  35418. * @returns "BackgroundMaterial"
  35419. */
  35420. getClassName(): string;
  35421. /**
  35422. * Parse a JSON input to create back a background material.
  35423. * @param source The JSON data to parse
  35424. * @param scene The scene to create the parsed material in
  35425. * @param rootUrl The root url of the assets the material depends upon
  35426. * @returns the instantiated BackgroundMaterial.
  35427. */
  35428. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  35429. }
  35430. }
  35431. declare module BABYLON {
  35432. /**
  35433. * The Physically based material base class of BJS.
  35434. *
  35435. * This offers the main features of a standard PBR material.
  35436. * For more information, please refer to the documentation :
  35437. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35438. */
  35439. abstract class PBRBaseMaterial extends PushMaterial {
  35440. /**
  35441. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  35442. */
  35443. static readonly LIGHTFALLOFF_PHYSICAL: number;
  35444. /**
  35445. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  35446. * to enhance interoperability with other engines.
  35447. */
  35448. static readonly LIGHTFALLOFF_GLTF: number;
  35449. /**
  35450. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  35451. * to enhance interoperability with other materials.
  35452. */
  35453. static readonly LIGHTFALLOFF_STANDARD: number;
  35454. /**
  35455. * Intensity of the direct lights e.g. the four lights available in your scene.
  35456. * This impacts both the direct diffuse and specular highlights.
  35457. */
  35458. protected _directIntensity: number;
  35459. /**
  35460. * Intensity of the emissive part of the material.
  35461. * This helps controlling the emissive effect without modifying the emissive color.
  35462. */
  35463. protected _emissiveIntensity: number;
  35464. /**
  35465. * Intensity of the environment e.g. how much the environment will light the object
  35466. * either through harmonics for rough material or through the refelction for shiny ones.
  35467. */
  35468. protected _environmentIntensity: number;
  35469. /**
  35470. * This is a special control allowing the reduction of the specular highlights coming from the
  35471. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35472. */
  35473. protected _specularIntensity: number;
  35474. /**
  35475. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  35476. */
  35477. private _lightingInfos;
  35478. /**
  35479. * Debug Control allowing disabling the bump map on this material.
  35480. */
  35481. protected _disableBumpMap: boolean;
  35482. /**
  35483. * AKA Diffuse Texture in standard nomenclature.
  35484. */
  35485. protected _albedoTexture: BaseTexture;
  35486. /**
  35487. * AKA Occlusion Texture in other nomenclature.
  35488. */
  35489. protected _ambientTexture: BaseTexture;
  35490. /**
  35491. * AKA Occlusion Texture Intensity in other nomenclature.
  35492. */
  35493. protected _ambientTextureStrength: number;
  35494. /**
  35495. * Defines how much the AO map is occluding the analytical lights (point spot...).
  35496. * 1 means it completely occludes it
  35497. * 0 mean it has no impact
  35498. */
  35499. protected _ambientTextureImpactOnAnalyticalLights: number;
  35500. /**
  35501. * Stores the alpha values in a texture.
  35502. */
  35503. protected _opacityTexture: BaseTexture;
  35504. /**
  35505. * Stores the reflection values in a texture.
  35506. */
  35507. protected _reflectionTexture: BaseTexture;
  35508. /**
  35509. * Stores the refraction values in a texture.
  35510. */
  35511. protected _refractionTexture: BaseTexture;
  35512. /**
  35513. * Stores the emissive values in a texture.
  35514. */
  35515. protected _emissiveTexture: BaseTexture;
  35516. /**
  35517. * AKA Specular texture in other nomenclature.
  35518. */
  35519. protected _reflectivityTexture: BaseTexture;
  35520. /**
  35521. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35522. */
  35523. protected _metallicTexture: BaseTexture;
  35524. /**
  35525. * Specifies the metallic scalar of the metallic/roughness workflow.
  35526. * Can also be used to scale the metalness values of the metallic texture.
  35527. */
  35528. protected _metallic: Nullable<number>;
  35529. /**
  35530. * Specifies the roughness scalar of the metallic/roughness workflow.
  35531. * Can also be used to scale the roughness values of the metallic texture.
  35532. */
  35533. protected _roughness: Nullable<number>;
  35534. /**
  35535. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35537. */
  35538. protected _microSurfaceTexture: BaseTexture;
  35539. /**
  35540. * Stores surface normal data used to displace a mesh in a texture.
  35541. */
  35542. protected _bumpTexture: BaseTexture;
  35543. /**
  35544. * Stores the pre-calculated light information of a mesh in a texture.
  35545. */
  35546. protected _lightmapTexture: BaseTexture;
  35547. /**
  35548. * The color of a material in ambient lighting.
  35549. */
  35550. protected _ambientColor: Color3;
  35551. /**
  35552. * AKA Diffuse Color in other nomenclature.
  35553. */
  35554. protected _albedoColor: Color3;
  35555. /**
  35556. * AKA Specular Color in other nomenclature.
  35557. */
  35558. protected _reflectivityColor: Color3;
  35559. /**
  35560. * The color applied when light is reflected from a material.
  35561. */
  35562. protected _reflectionColor: Color3;
  35563. /**
  35564. * The color applied when light is emitted from a material.
  35565. */
  35566. protected _emissiveColor: Color3;
  35567. /**
  35568. * AKA Glossiness in other nomenclature.
  35569. */
  35570. protected _microSurface: number;
  35571. /**
  35572. * source material index of refraction (IOR)' / 'destination material IOR.
  35573. */
  35574. protected _indexOfRefraction: number;
  35575. /**
  35576. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35577. */
  35578. protected _invertRefractionY: boolean;
  35579. /**
  35580. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35581. * Materials half opaque for instance using refraction could benefit from this control.
  35582. */
  35583. protected _linkRefractionWithTransparency: boolean;
  35584. /**
  35585. * Specifies that the material will use the light map as a show map.
  35586. */
  35587. protected _useLightmapAsShadowmap: boolean;
  35588. /**
  35589. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35590. * makes the reflect vector face the model (under horizon).
  35591. */
  35592. protected _useHorizonOcclusion: boolean;
  35593. /**
  35594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35595. * too much the area relying on ambient texture to define their ambient occlusion.
  35596. */
  35597. protected _useRadianceOcclusion: boolean;
  35598. /**
  35599. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35600. */
  35601. protected _useAlphaFromAlbedoTexture: boolean;
  35602. /**
  35603. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35604. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35605. */
  35606. protected _useSpecularOverAlpha: boolean;
  35607. /**
  35608. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35609. */
  35610. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35611. /**
  35612. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35613. */
  35614. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  35615. /**
  35616. * Specifies if the metallic texture contains the roughness information in its green channel.
  35617. */
  35618. protected _useRoughnessFromMetallicTextureGreen: boolean;
  35619. /**
  35620. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35621. */
  35622. protected _useMetallnessFromMetallicTextureBlue: boolean;
  35623. /**
  35624. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35625. */
  35626. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  35627. /**
  35628. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35629. */
  35630. protected _useAmbientInGrayScale: boolean;
  35631. /**
  35632. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35633. * The material will try to infer what glossiness each pixel should be.
  35634. */
  35635. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  35636. /**
  35637. * Defines the falloff type used in this material.
  35638. * It by default is Physical.
  35639. */
  35640. protected _lightFalloff: number;
  35641. /**
  35642. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35643. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35644. */
  35645. protected _useRadianceOverAlpha: boolean;
  35646. /**
  35647. * Allows using an object space normal map (instead of tangent space).
  35648. */
  35649. protected _useObjectSpaceNormalMap: boolean;
  35650. /**
  35651. * Allows using the bump map in parallax mode.
  35652. */
  35653. protected _useParallax: boolean;
  35654. /**
  35655. * Allows using the bump map in parallax occlusion mode.
  35656. */
  35657. protected _useParallaxOcclusion: boolean;
  35658. /**
  35659. * Controls the scale bias of the parallax mode.
  35660. */
  35661. protected _parallaxScaleBias: number;
  35662. /**
  35663. * If sets to true, disables all the lights affecting the material.
  35664. */
  35665. protected _disableLighting: boolean;
  35666. /**
  35667. * Number of Simultaneous lights allowed on the material.
  35668. */
  35669. protected _maxSimultaneousLights: number;
  35670. /**
  35671. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  35672. */
  35673. protected _invertNormalMapX: boolean;
  35674. /**
  35675. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  35676. */
  35677. protected _invertNormalMapY: boolean;
  35678. /**
  35679. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35680. */
  35681. protected _twoSidedLighting: boolean;
  35682. /**
  35683. * Defines the alpha limits in alpha test mode.
  35684. */
  35685. protected _alphaCutOff: number;
  35686. /**
  35687. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35688. */
  35689. protected _forceAlphaTest: boolean;
  35690. /**
  35691. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35692. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35693. */
  35694. protected _useAlphaFresnel: boolean;
  35695. /**
  35696. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35697. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35698. */
  35699. protected _useLinearAlphaFresnel: boolean;
  35700. /**
  35701. * The transparency mode of the material.
  35702. */
  35703. protected _transparencyMode: Nullable<number>;
  35704. /**
  35705. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  35706. * from cos thetav and roughness:
  35707. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  35708. */
  35709. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  35710. /**
  35711. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35712. */
  35713. protected _forceIrradianceInFragment: boolean;
  35714. /**
  35715. * Force normal to face away from face.
  35716. */
  35717. protected _forceNormalForward: boolean;
  35718. /**
  35719. * Enables specular anti aliasing in the PBR shader.
  35720. * It will both interacts on the Geometry for analytical and IBL lighting.
  35721. * It also prefilter the roughness map based on the bump values.
  35722. */
  35723. protected _enableSpecularAntiAliasing: boolean;
  35724. /**
  35725. * Default configuration related to image processing available in the PBR Material.
  35726. */
  35727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35728. /**
  35729. * Keep track of the image processing observer to allow dispose and replace.
  35730. */
  35731. private _imageProcessingObserver;
  35732. /**
  35733. * Attaches a new image processing configuration to the PBR Material.
  35734. * @param configuration
  35735. */
  35736. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35737. /**
  35738. * Stores the available render targets.
  35739. */
  35740. private _renderTargets;
  35741. /**
  35742. * Sets the global ambient color for the material used in lighting calculations.
  35743. */
  35744. private _globalAmbientColor;
  35745. /**
  35746. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35747. */
  35748. private _useLogarithmicDepth;
  35749. /**
  35750. * If set to true, no lighting calculations will be applied.
  35751. */
  35752. private _unlit;
  35753. /**
  35754. * Instantiates a new PBRMaterial instance.
  35755. *
  35756. * @param name The material name
  35757. * @param scene The scene the material will be use in.
  35758. */
  35759. constructor(name: string, scene: Scene);
  35760. /**
  35761. * Gets the name of the material class.
  35762. */
  35763. getClassName(): string;
  35764. /**
  35765. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35766. */
  35767. /**
  35768. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35769. */
  35770. useLogarithmicDepth: boolean;
  35771. /**
  35772. * Gets the current transparency mode.
  35773. */
  35774. /**
  35775. * Sets the transparency mode of the material.
  35776. *
  35777. * | Value | Type | Description |
  35778. * | ----- | ----------------------------------- | ----------- |
  35779. * | 0 | OPAQUE | |
  35780. * | 1 | ALPHATEST | |
  35781. * | 2 | ALPHABLEND | |
  35782. * | 3 | ALPHATESTANDBLEND | |
  35783. *
  35784. */
  35785. transparencyMode: Nullable<number>;
  35786. /**
  35787. * Returns true if alpha blending should be disabled.
  35788. */
  35789. private readonly _disableAlphaBlending;
  35790. /**
  35791. * Specifies whether or not this material should be rendered in alpha blend mode.
  35792. */
  35793. needAlphaBlending(): boolean;
  35794. /**
  35795. * Specifies if the mesh will require alpha blending.
  35796. * @param mesh - BJS mesh.
  35797. */
  35798. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  35799. /**
  35800. * Specifies whether or not this material should be rendered in alpha test mode.
  35801. */
  35802. needAlphaTesting(): boolean;
  35803. /**
  35804. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  35805. */
  35806. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  35807. /**
  35808. * Gets the texture used for the alpha test.
  35809. */
  35810. getAlphaTestTexture(): BaseTexture;
  35811. /**
  35812. * Stores the reflectivity values based on metallic roughness workflow.
  35813. */
  35814. private static _scaledReflectivity;
  35815. /**
  35816. * Specifies that the submesh is ready to be used.
  35817. * @param mesh - BJS mesh.
  35818. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  35819. * @param useInstances - Specifies that instances should be used.
  35820. * @returns - boolean indicating that the submesh is ready or not.
  35821. */
  35822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35823. /**
  35824. * Specifies if the material uses metallic roughness workflow.
  35825. * @returns boolean specifiying if the material uses metallic roughness workflow.
  35826. */
  35827. isMetallicWorkflow(): boolean;
  35828. private _prepareEffect;
  35829. private _prepareDefines;
  35830. /**
  35831. * Force shader compilation
  35832. */
  35833. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  35834. clipPlane: boolean;
  35835. }>): void;
  35836. /**
  35837. * Initializes the uniform buffer layout for the shader.
  35838. */
  35839. buildUniformLayout(): void;
  35840. /**
  35841. * Unbinds the textures.
  35842. */
  35843. unbind(): void;
  35844. /**
  35845. * Binds the submesh data.
  35846. * @param world - The world matrix.
  35847. * @param mesh - The BJS mesh.
  35848. * @param subMesh - A submesh of the BJS mesh.
  35849. */
  35850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35851. /**
  35852. * Returns the animatable textures.
  35853. * @returns - Array of animatable textures.
  35854. */
  35855. getAnimatables(): IAnimatable[];
  35856. /**
  35857. * Returns the texture used for reflections.
  35858. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  35859. */
  35860. private _getReflectionTexture;
  35861. /**
  35862. * Returns the texture used for refraction or null if none is used.
  35863. * @returns - Refection texture if present. If no refraction texture and refraction
  35864. * is linked with transparency, returns environment texture. Otherwise, returns null.
  35865. */
  35866. private _getRefractionTexture;
  35867. /**
  35868. * Disposes the resources of the material.
  35869. * @param forceDisposeEffect - Forces the disposal of effects.
  35870. * @param forceDisposeTextures - Forces the disposal of all textures.
  35871. */
  35872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35873. }
  35874. }
  35875. declare module BABYLON {
  35876. /**
  35877. * The Physically based simple base material of BJS.
  35878. *
  35879. * This enables better naming and convention enforcements on top of the pbrMaterial.
  35880. * It is used as the base class for both the specGloss and metalRough conventions.
  35881. */
  35882. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  35883. /**
  35884. * Number of Simultaneous lights allowed on the material.
  35885. */
  35886. maxSimultaneousLights: number;
  35887. /**
  35888. * If sets to true, disables all the lights affecting the material.
  35889. */
  35890. disableLighting: boolean;
  35891. /**
  35892. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  35893. */
  35894. environmentTexture: BaseTexture;
  35895. /**
  35896. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35897. */
  35898. invertNormalMapX: boolean;
  35899. /**
  35900. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35901. */
  35902. invertNormalMapY: boolean;
  35903. /**
  35904. * Normal map used in the model.
  35905. */
  35906. normalTexture: BaseTexture;
  35907. /**
  35908. * Emissivie color used to self-illuminate the model.
  35909. */
  35910. emissiveColor: Color3;
  35911. /**
  35912. * Emissivie texture used to self-illuminate the model.
  35913. */
  35914. emissiveTexture: BaseTexture;
  35915. /**
  35916. * Occlusion Channel Strenght.
  35917. */
  35918. occlusionStrength: number;
  35919. /**
  35920. * Occlusion Texture of the material (adding extra occlusion effects).
  35921. */
  35922. occlusionTexture: BaseTexture;
  35923. /**
  35924. * Defines the alpha limits in alpha test mode.
  35925. */
  35926. alphaCutOff: number;
  35927. /**
  35928. * Gets the current double sided mode.
  35929. */
  35930. /**
  35931. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35932. */
  35933. doubleSided: boolean;
  35934. lightmapTexture: BaseTexture;
  35935. useLightmapAsShadowmap: boolean;
  35936. /**
  35937. * Return the active textures of the material.
  35938. */
  35939. getActiveTextures(): BaseTexture[];
  35940. hasTexture(texture: BaseTexture): boolean;
  35941. /**
  35942. * Instantiates a new PBRMaterial instance.
  35943. *
  35944. * @param name The material name
  35945. * @param scene The scene the material will be use in.
  35946. */
  35947. constructor(name: string, scene: Scene);
  35948. getClassName(): string;
  35949. }
  35950. }
  35951. declare module BABYLON {
  35952. /**
  35953. * The Physically based material of BJS.
  35954. *
  35955. * This offers the main features of a standard PBR material.
  35956. * For more information, please refer to the documentation :
  35957. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35958. */
  35959. class PBRMaterial extends PBRBaseMaterial {
  35960. /**
  35961. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  35962. */
  35963. static readonly PBRMATERIAL_OPAQUE: number;
  35964. /**
  35965. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  35966. */
  35967. static readonly PBRMATERIAL_ALPHATEST: number;
  35968. /**
  35969. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35970. */
  35971. static readonly PBRMATERIAL_ALPHABLEND: number;
  35972. /**
  35973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35974. * They are also discarded below the alpha cutoff threshold to improve performances.
  35975. */
  35976. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  35977. /**
  35978. * Defines the default value of how much AO map is occluding the analytical lights
  35979. * (point spot...).
  35980. */
  35981. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  35982. /**
  35983. * Intensity of the direct lights e.g. the four lights available in your scene.
  35984. * This impacts both the direct diffuse and specular highlights.
  35985. */
  35986. directIntensity: number;
  35987. /**
  35988. * Intensity of the emissive part of the material.
  35989. * This helps controlling the emissive effect without modifying the emissive color.
  35990. */
  35991. emissiveIntensity: number;
  35992. /**
  35993. * Intensity of the environment e.g. how much the environment will light the object
  35994. * either through harmonics for rough material or through the refelction for shiny ones.
  35995. */
  35996. environmentIntensity: number;
  35997. /**
  35998. * This is a special control allowing the reduction of the specular highlights coming from the
  35999. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36000. */
  36001. specularIntensity: number;
  36002. /**
  36003. * Debug Control allowing disabling the bump map on this material.
  36004. */
  36005. disableBumpMap: boolean;
  36006. /**
  36007. * AKA Diffuse Texture in standard nomenclature.
  36008. */
  36009. albedoTexture: BaseTexture;
  36010. /**
  36011. * AKA Occlusion Texture in other nomenclature.
  36012. */
  36013. ambientTexture: BaseTexture;
  36014. /**
  36015. * AKA Occlusion Texture Intensity in other nomenclature.
  36016. */
  36017. ambientTextureStrength: number;
  36018. /**
  36019. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36020. * 1 means it completely occludes it
  36021. * 0 mean it has no impact
  36022. */
  36023. ambientTextureImpactOnAnalyticalLights: number;
  36024. /**
  36025. * Stores the alpha values in a texture.
  36026. */
  36027. opacityTexture: BaseTexture;
  36028. /**
  36029. * Stores the reflection values in a texture.
  36030. */
  36031. reflectionTexture: Nullable<BaseTexture>;
  36032. /**
  36033. * Stores the emissive values in a texture.
  36034. */
  36035. emissiveTexture: BaseTexture;
  36036. /**
  36037. * AKA Specular texture in other nomenclature.
  36038. */
  36039. reflectivityTexture: BaseTexture;
  36040. /**
  36041. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36042. */
  36043. metallicTexture: BaseTexture;
  36044. /**
  36045. * Specifies the metallic scalar of the metallic/roughness workflow.
  36046. * Can also be used to scale the metalness values of the metallic texture.
  36047. */
  36048. metallic: Nullable<number>;
  36049. /**
  36050. * Specifies the roughness scalar of the metallic/roughness workflow.
  36051. * Can also be used to scale the roughness values of the metallic texture.
  36052. */
  36053. roughness: Nullable<number>;
  36054. /**
  36055. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36056. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36057. */
  36058. microSurfaceTexture: BaseTexture;
  36059. /**
  36060. * Stores surface normal data used to displace a mesh in a texture.
  36061. */
  36062. bumpTexture: BaseTexture;
  36063. /**
  36064. * Stores the pre-calculated light information of a mesh in a texture.
  36065. */
  36066. lightmapTexture: BaseTexture;
  36067. /**
  36068. * Stores the refracted light information in a texture.
  36069. */
  36070. refractionTexture: BaseTexture;
  36071. /**
  36072. * The color of a material in ambient lighting.
  36073. */
  36074. ambientColor: Color3;
  36075. /**
  36076. * AKA Diffuse Color in other nomenclature.
  36077. */
  36078. albedoColor: Color3;
  36079. /**
  36080. * AKA Specular Color in other nomenclature.
  36081. */
  36082. reflectivityColor: Color3;
  36083. /**
  36084. * The color reflected from the material.
  36085. */
  36086. reflectionColor: Color3;
  36087. /**
  36088. * The color emitted from the material.
  36089. */
  36090. emissiveColor: Color3;
  36091. /**
  36092. * AKA Glossiness in other nomenclature.
  36093. */
  36094. microSurface: number;
  36095. /**
  36096. * source material index of refraction (IOR)' / 'destination material IOR.
  36097. */
  36098. indexOfRefraction: number;
  36099. /**
  36100. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36101. */
  36102. invertRefractionY: boolean;
  36103. /**
  36104. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36105. * Materials half opaque for instance using refraction could benefit from this control.
  36106. */
  36107. linkRefractionWithTransparency: boolean;
  36108. useLightmapAsShadowmap: boolean;
  36109. /**
  36110. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36111. */
  36112. useAlphaFromAlbedoTexture: boolean;
  36113. /**
  36114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36115. */
  36116. forceAlphaTest: boolean;
  36117. /**
  36118. * Defines the alpha limits in alpha test mode.
  36119. */
  36120. alphaCutOff: number;
  36121. /**
  36122. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36123. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36124. */
  36125. useSpecularOverAlpha: boolean;
  36126. /**
  36127. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36128. */
  36129. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36130. /**
  36131. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36132. */
  36133. useRoughnessFromMetallicTextureAlpha: boolean;
  36134. /**
  36135. * Specifies if the metallic texture contains the roughness information in its green channel.
  36136. */
  36137. useRoughnessFromMetallicTextureGreen: boolean;
  36138. /**
  36139. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36140. */
  36141. useMetallnessFromMetallicTextureBlue: boolean;
  36142. /**
  36143. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36144. */
  36145. useAmbientOcclusionFromMetallicTextureRed: boolean;
  36146. /**
  36147. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36148. */
  36149. useAmbientInGrayScale: boolean;
  36150. /**
  36151. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36152. * The material will try to infer what glossiness each pixel should be.
  36153. */
  36154. useAutoMicroSurfaceFromReflectivityMap: boolean;
  36155. /**
  36156. * BJS is using an harcoded light falloff based on a manually sets up range.
  36157. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36158. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36159. */
  36160. /**
  36161. * BJS is using an harcoded light falloff based on a manually sets up range.
  36162. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36163. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36164. */
  36165. usePhysicalLightFalloff: boolean;
  36166. /**
  36167. * In order to support the falloff compatibility with gltf, a special mode has been added
  36168. * to reproduce the gltf light falloff.
  36169. */
  36170. /**
  36171. * In order to support the falloff compatibility with gltf, a special mode has been added
  36172. * to reproduce the gltf light falloff.
  36173. */
  36174. useGLTFLightFalloff: boolean;
  36175. /**
  36176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36178. */
  36179. useRadianceOverAlpha: boolean;
  36180. /**
  36181. * Allows using an object space normal map (instead of tangent space).
  36182. */
  36183. useObjectSpaceNormalMap: boolean;
  36184. /**
  36185. * Allows using the bump map in parallax mode.
  36186. */
  36187. useParallax: boolean;
  36188. /**
  36189. * Allows using the bump map in parallax occlusion mode.
  36190. */
  36191. useParallaxOcclusion: boolean;
  36192. /**
  36193. * Controls the scale bias of the parallax mode.
  36194. */
  36195. parallaxScaleBias: number;
  36196. /**
  36197. * If sets to true, disables all the lights affecting the material.
  36198. */
  36199. disableLighting: boolean;
  36200. /**
  36201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36202. */
  36203. forceIrradianceInFragment: boolean;
  36204. /**
  36205. * Number of Simultaneous lights allowed on the material.
  36206. */
  36207. maxSimultaneousLights: number;
  36208. /**
  36209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36210. */
  36211. invertNormalMapX: boolean;
  36212. /**
  36213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36214. */
  36215. invertNormalMapY: boolean;
  36216. /**
  36217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36218. */
  36219. twoSidedLighting: boolean;
  36220. /**
  36221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36222. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36223. */
  36224. useAlphaFresnel: boolean;
  36225. /**
  36226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36227. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36228. */
  36229. useLinearAlphaFresnel: boolean;
  36230. /**
  36231. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36232. * And/Or occlude the blended part.
  36233. */
  36234. environmentBRDFTexture: Nullable<BaseTexture>;
  36235. /**
  36236. * Force normal to face away from face.
  36237. */
  36238. forceNormalForward: boolean;
  36239. /**
  36240. * Enables specular anti aliasing in the PBR shader.
  36241. * It will both interacts on the Geometry for analytical and IBL lighting.
  36242. * It also prefilter the roughness map based on the bump values.
  36243. */
  36244. enableSpecularAntiAliasing: boolean;
  36245. /**
  36246. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36247. * makes the reflect vector face the model (under horizon).
  36248. */
  36249. useHorizonOcclusion: boolean;
  36250. /**
  36251. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36252. * too much the area relying on ambient texture to define their ambient occlusion.
  36253. */
  36254. useRadianceOcclusion: boolean;
  36255. /**
  36256. * If set to true, no lighting calculations will be applied.
  36257. */
  36258. unlit: boolean;
  36259. /**
  36260. * Gets the image processing configuration used either in this material.
  36261. */
  36262. /**
  36263. * Sets the Default image processing configuration used either in the this material.
  36264. *
  36265. * If sets to null, the scene one is in use.
  36266. */
  36267. imageProcessingConfiguration: ImageProcessingConfiguration;
  36268. /**
  36269. * Gets wether the color curves effect is enabled.
  36270. */
  36271. /**
  36272. * Sets wether the color curves effect is enabled.
  36273. */
  36274. cameraColorCurvesEnabled: boolean;
  36275. /**
  36276. * Gets wether the color grading effect is enabled.
  36277. */
  36278. /**
  36279. * Gets wether the color grading effect is enabled.
  36280. */
  36281. cameraColorGradingEnabled: boolean;
  36282. /**
  36283. * Gets wether tonemapping is enabled or not.
  36284. */
  36285. /**
  36286. * Sets wether tonemapping is enabled or not
  36287. */
  36288. cameraToneMappingEnabled: boolean;
  36289. /**
  36290. * The camera exposure used on this material.
  36291. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36292. * This corresponds to a photographic exposure.
  36293. */
  36294. /**
  36295. * The camera exposure used on this material.
  36296. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36297. * This corresponds to a photographic exposure.
  36298. */
  36299. cameraExposure: number;
  36300. /**
  36301. * Gets The camera contrast used on this material.
  36302. */
  36303. /**
  36304. * Sets The camera contrast used on this material.
  36305. */
  36306. cameraContrast: number;
  36307. /**
  36308. * Gets the Color Grading 2D Lookup Texture.
  36309. */
  36310. /**
  36311. * Sets the Color Grading 2D Lookup Texture.
  36312. */
  36313. cameraColorGradingTexture: Nullable<BaseTexture>;
  36314. /**
  36315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36317. * 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;
  36318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36319. */
  36320. /**
  36321. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36322. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36323. * 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;
  36324. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36325. */
  36326. cameraColorCurves: Nullable<ColorCurves>;
  36327. /**
  36328. * Instantiates a new PBRMaterial instance.
  36329. *
  36330. * @param name The material name
  36331. * @param scene The scene the material will be use in.
  36332. */
  36333. constructor(name: string, scene: Scene);
  36334. /**
  36335. * Returns the name of this material class.
  36336. */
  36337. getClassName(): string;
  36338. /**
  36339. * Returns an array of the actively used textures.
  36340. * @returns - Array of BaseTextures
  36341. */
  36342. getActiveTextures(): BaseTexture[];
  36343. /**
  36344. * Checks to see if a texture is used in the material.
  36345. * @param texture - Base texture to use.
  36346. * @returns - Boolean specifying if a texture is used in the material.
  36347. */
  36348. hasTexture(texture: BaseTexture): boolean;
  36349. /**
  36350. * Makes a duplicate of the current material.
  36351. * @param name - name to use for the new material.
  36352. */
  36353. clone(name: string): PBRMaterial;
  36354. /**
  36355. * Serializes this PBR Material.
  36356. * @returns - An object with the serialized material.
  36357. */
  36358. serialize(): any;
  36359. /**
  36360. * Parses a PBR Material from a serialized object.
  36361. * @param source - Serialized object.
  36362. * @param scene - BJS scene instance.
  36363. * @param rootUrl - url for the scene object
  36364. * @returns - PBRMaterial
  36365. */
  36366. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  36367. }
  36368. }
  36369. declare module BABYLON {
  36370. /**
  36371. * The PBR material of BJS following the metal roughness convention.
  36372. *
  36373. * This fits to the PBR convention in the GLTF definition:
  36374. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  36375. */
  36376. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  36377. /**
  36378. * The base color has two different interpretations depending on the value of metalness.
  36379. * When the material is a metal, the base color is the specific measured reflectance value
  36380. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  36381. * of the material.
  36382. */
  36383. baseColor: Color3;
  36384. /**
  36385. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  36386. * well as opacity information in the alpha channel.
  36387. */
  36388. baseTexture: BaseTexture;
  36389. /**
  36390. * Specifies the metallic scalar value of the material.
  36391. * Can also be used to scale the metalness values of the metallic texture.
  36392. */
  36393. metallic: number;
  36394. /**
  36395. * Specifies the roughness scalar value of the material.
  36396. * Can also be used to scale the roughness values of the metallic texture.
  36397. */
  36398. roughness: number;
  36399. /**
  36400. * Texture containing both the metallic value in the B channel and the
  36401. * roughness value in the G channel to keep better precision.
  36402. */
  36403. metallicRoughnessTexture: BaseTexture;
  36404. /**
  36405. * Instantiates a new PBRMetalRoughnessMaterial instance.
  36406. *
  36407. * @param name The material name
  36408. * @param scene The scene the material will be use in.
  36409. */
  36410. constructor(name: string, scene: Scene);
  36411. /**
  36412. * Return the currrent class name of the material.
  36413. */
  36414. getClassName(): string;
  36415. /**
  36416. * Return the active textures of the material.
  36417. */
  36418. getActiveTextures(): BaseTexture[];
  36419. /**
  36420. * Checks to see if a texture is used in the material.
  36421. * @param texture - Base texture to use.
  36422. * @returns - Boolean specifying if a texture is used in the material.
  36423. */
  36424. hasTexture(texture: BaseTexture): boolean;
  36425. /**
  36426. * Makes a duplicate of the current material.
  36427. * @param name - name to use for the new material.
  36428. */
  36429. clone(name: string): PBRMetallicRoughnessMaterial;
  36430. /**
  36431. * Serialize the material to a parsable JSON object.
  36432. */
  36433. serialize(): any;
  36434. /**
  36435. * Parses a JSON object correponding to the serialize function.
  36436. */
  36437. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  36438. }
  36439. }
  36440. declare module BABYLON {
  36441. /**
  36442. * The PBR material of BJS following the specular glossiness convention.
  36443. *
  36444. * This fits to the PBR convention in the GLTF definition:
  36445. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  36446. */
  36447. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  36448. /**
  36449. * Specifies the diffuse color of the material.
  36450. */
  36451. diffuseColor: Color3;
  36452. /**
  36453. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  36454. * channel.
  36455. */
  36456. diffuseTexture: BaseTexture;
  36457. /**
  36458. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  36459. */
  36460. specularColor: Color3;
  36461. /**
  36462. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  36463. */
  36464. glossiness: number;
  36465. /**
  36466. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  36467. */
  36468. specularGlossinessTexture: BaseTexture;
  36469. /**
  36470. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  36471. *
  36472. * @param name The material name
  36473. * @param scene The scene the material will be use in.
  36474. */
  36475. constructor(name: string, scene: Scene);
  36476. /**
  36477. * Return the currrent class name of the material.
  36478. */
  36479. getClassName(): string;
  36480. /**
  36481. * Return the active textures of the material.
  36482. */
  36483. getActiveTextures(): BaseTexture[];
  36484. /**
  36485. * Checks to see if a texture is used in the material.
  36486. * @param texture - Base texture to use.
  36487. * @returns - Boolean specifying if a texture is used in the material.
  36488. */
  36489. hasTexture(texture: BaseTexture): boolean;
  36490. /**
  36491. * Makes a duplicate of the current material.
  36492. * @param name - name to use for the new material.
  36493. */
  36494. clone(name: string): PBRSpecularGlossinessMaterial;
  36495. /**
  36496. * Serialize the material to a parsable JSON object.
  36497. */
  36498. serialize(): any;
  36499. /**
  36500. * Parses a JSON object correponding to the serialize function.
  36501. */
  36502. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  36503. }
  36504. }
  36505. declare module BABYLON {
  36506. class BaseTexture {
  36507. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36508. name: string;
  36509. private _hasAlpha;
  36510. hasAlpha: boolean;
  36511. getAlphaFromRGB: boolean;
  36512. level: number;
  36513. coordinatesIndex: number;
  36514. private _coordinatesMode;
  36515. /**
  36516. * How a texture is mapped.
  36517. *
  36518. * | Value | Type | Description |
  36519. * | ----- | ----------------------------------- | ----------- |
  36520. * | 0 | EXPLICIT_MODE | |
  36521. * | 1 | SPHERICAL_MODE | |
  36522. * | 2 | PLANAR_MODE | |
  36523. * | 3 | CUBIC_MODE | |
  36524. * | 4 | PROJECTION_MODE | |
  36525. * | 5 | SKYBOX_MODE | |
  36526. * | 6 | INVCUBIC_MODE | |
  36527. * | 7 | EQUIRECTANGULAR_MODE | |
  36528. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36529. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36530. */
  36531. coordinatesMode: number;
  36532. /**
  36533. * | Value | Type | Description |
  36534. * | ----- | ------------------ | ----------- |
  36535. * | 0 | CLAMP_ADDRESSMODE | |
  36536. * | 1 | WRAP_ADDRESSMODE | |
  36537. * | 2 | MIRROR_ADDRESSMODE | |
  36538. */
  36539. wrapU: number;
  36540. /**
  36541. * | Value | Type | Description |
  36542. * | ----- | ------------------ | ----------- |
  36543. * | 0 | CLAMP_ADDRESSMODE | |
  36544. * | 1 | WRAP_ADDRESSMODE | |
  36545. * | 2 | MIRROR_ADDRESSMODE | |
  36546. */
  36547. wrapV: number;
  36548. /**
  36549. * | Value | Type | Description |
  36550. * | ----- | ------------------ | ----------- |
  36551. * | 0 | CLAMP_ADDRESSMODE | |
  36552. * | 1 | WRAP_ADDRESSMODE | |
  36553. * | 2 | MIRROR_ADDRESSMODE | |
  36554. */
  36555. wrapR: number;
  36556. anisotropicFilteringLevel: number;
  36557. isCube: boolean;
  36558. is3D: boolean;
  36559. gammaSpace: boolean;
  36560. /**
  36561. * Gets whether or not the texture contains RGBD data.
  36562. */
  36563. readonly isRGBD: boolean;
  36564. invertZ: boolean;
  36565. lodLevelInAlpha: boolean;
  36566. lodGenerationOffset: number;
  36567. lodGenerationScale: number;
  36568. isRenderTarget: boolean;
  36569. readonly uid: string;
  36570. toString(): string;
  36571. getClassName(): string;
  36572. animations: Animation[];
  36573. /**
  36574. * An event triggered when the texture is disposed.
  36575. */
  36576. onDisposeObservable: Observable<BaseTexture>;
  36577. private _onDisposeObserver;
  36578. onDispose: () => void;
  36579. delayLoadState: number;
  36580. private _scene;
  36581. /** @hidden */
  36582. private _uid;
  36583. readonly isBlocking: boolean;
  36584. constructor(scene: Nullable<Scene>);
  36585. getScene(): Nullable<Scene>;
  36586. getTextureMatrix(): Matrix;
  36587. getReflectionTextureMatrix(): Matrix;
  36588. getInternalTexture(): Nullable<InternalTexture>;
  36589. isReadyOrNotBlocking(): boolean;
  36590. isReady(): boolean;
  36591. private _cachedSize;
  36592. getSize(): ISize;
  36593. getBaseSize(): ISize;
  36594. scale(ratio: number): void;
  36595. readonly canRescale: boolean;
  36596. /** @hidden */
  36597. /** @hidden */
  36598. delayLoad(): void;
  36599. clone(): Nullable<BaseTexture>;
  36600. readonly textureType: number;
  36601. readonly textureFormat: number;
  36602. /**
  36603. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  36604. * This will returns an RGBA array buffer containing either in values (0-255) or
  36605. * float values (0-1) depending of the underlying buffer type.
  36606. * @param faceIndex The face of the texture to read (in case of cube texture)
  36607. * @param level The LOD level of the texture to read (in case of Mip Maps)
  36608. * @returns The Array buffer containing the pixels data.
  36609. */
  36610. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  36611. releaseInternalTexture(): void;
  36612. sphericalPolynomial: Nullable<SphericalPolynomial>;
  36613. protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  36614. protected readonly _lodTextureMid: Nullable<BaseTexture>;
  36615. protected readonly _lodTextureLow: Nullable<BaseTexture>;
  36616. dispose(): void;
  36617. serialize(): any;
  36618. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  36619. }
  36620. }
  36621. declare module BABYLON {
  36622. /**
  36623. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  36624. * It can help converting any input color in a desired output one. This can then be used to create effects
  36625. * from sepia, black and white to sixties or futuristic rendering...
  36626. *
  36627. * The only supported format is currently 3dl.
  36628. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  36629. */
  36630. class ColorGradingTexture extends BaseTexture {
  36631. /**
  36632. * The current texture matrix. (will always be identity in color grading texture)
  36633. */
  36634. private _textureMatrix;
  36635. /**
  36636. * The texture URL.
  36637. */
  36638. url: string;
  36639. /**
  36640. * Empty line regex stored for GC.
  36641. */
  36642. private static _noneEmptyLineRegex;
  36643. private _engine;
  36644. /**
  36645. * Instantiates a ColorGradingTexture from the following parameters.
  36646. *
  36647. * @param url The location of the color gradind data (currently only supporting 3dl)
  36648. * @param scene The scene the texture will be used in
  36649. */
  36650. constructor(url: string, scene: Scene);
  36651. /**
  36652. * Returns the texture matrix used in most of the material.
  36653. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  36654. */
  36655. getTextureMatrix(): Matrix;
  36656. /**
  36657. * Occurs when the file being loaded is a .3dl LUT file.
  36658. */
  36659. private load3dlTexture;
  36660. /**
  36661. * Starts the loading process of the texture.
  36662. */
  36663. private loadTexture;
  36664. /**
  36665. * Clones the color gradind texture.
  36666. */
  36667. clone(): ColorGradingTexture;
  36668. /**
  36669. * Called during delayed load for textures.
  36670. */
  36671. delayLoad(): void;
  36672. /**
  36673. * Parses a color grading texture serialized by Babylon.
  36674. * @param parsedTexture The texture information being parsedTexture
  36675. * @param scene The scene to load the texture in
  36676. * @param rootUrl The root url of the data assets to load
  36677. * @return A color gradind texture
  36678. */
  36679. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  36680. /**
  36681. * Serializes the LUT texture to json format.
  36682. */
  36683. serialize(): any;
  36684. }
  36685. }
  36686. declare module BABYLON {
  36687. class CubeTexture extends BaseTexture {
  36688. url: string;
  36689. /**
  36690. * Gets or sets the center of the bounding box associated with the cube texture
  36691. * It must define where the camera used to render the texture was set
  36692. */
  36693. boundingBoxPosition: Vector3;
  36694. private _boundingBoxSize;
  36695. /**
  36696. * Gets or sets the size of the bounding box associated with the cube texture
  36697. * When defined, the cubemap will switch to local mode
  36698. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36699. * @example https://www.babylonjs-playground.com/#RNASML
  36700. */
  36701. boundingBoxSize: Vector3;
  36702. protected _rotationY: number;
  36703. /**
  36704. * Sets texture matrix rotation angle around Y axis in radians.
  36705. */
  36706. /**
  36707. * Gets texture matrix rotation angle around Y axis radians.
  36708. */
  36709. rotationY: number;
  36710. private _noMipmap;
  36711. private _files;
  36712. private _extensions;
  36713. private _textureMatrix;
  36714. private _format;
  36715. private _createPolynomials;
  36716. /** @hidden */
  36717. protected readonly _prefiltered: boolean;
  36718. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  36719. /**
  36720. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  36721. * @param url defines the url of the prefiltered texture
  36722. * @param scene defines the scene the texture is attached to
  36723. * @param forcedExtension defines the extension of the file if different from the url
  36724. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36725. * @return the prefiltered texture
  36726. */
  36727. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  36728. /**
  36729. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  36730. * as prefiltered data.
  36731. * @param rootUrl defines the url of the texture or the root name of the six images
  36732. * @param scene defines the scene the texture is attached to
  36733. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  36734. * @param noMipmap defines if mipmaps should be created or not
  36735. * @param files defines the six files to load for the different faces
  36736. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36737. * @param onError defines a callback triggered in case of error during load
  36738. * @param format defines the internal format to use for the texture once loaded
  36739. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36740. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36742. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36743. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36744. * @return the cube texture
  36745. */
  36746. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  36747. delayLoad(): void;
  36748. getReflectionTextureMatrix(): Matrix;
  36749. setReflectionTextureMatrix(value: Matrix): void;
  36750. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36751. clone(): CubeTexture;
  36752. }
  36753. }
  36754. declare module BABYLON {
  36755. /**
  36756. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36757. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36758. */
  36759. class DynamicTexture extends Texture {
  36760. private _generateMipMaps;
  36761. private _canvas;
  36762. private _context;
  36763. private _engine;
  36764. /**
  36765. * Creates a {BABYLON.DynamicTexture}
  36766. * @param name defines the name of the texture
  36767. * @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
  36768. * @param scene defines the scene where you want the texture
  36769. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36770. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36771. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36772. */
  36773. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36774. /**
  36775. * Gets the current state of canRescale
  36776. */
  36777. readonly canRescale: boolean;
  36778. private _recreate;
  36779. /**
  36780. * Scales the texture
  36781. * @param ratio the scale factor to apply to both width and height
  36782. */
  36783. scale(ratio: number): void;
  36784. /**
  36785. * Resizes the texture
  36786. * @param width the new width
  36787. * @param height the new height
  36788. */
  36789. scaleTo(width: number, height: number): void;
  36790. /**
  36791. * Gets the context of the canvas used by the texture
  36792. * @returns the canvas context of the dynamic texture
  36793. */
  36794. getContext(): CanvasRenderingContext2D;
  36795. /**
  36796. * Clears the texture
  36797. */
  36798. clear(): void;
  36799. /**
  36800. * Updates the texture
  36801. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36802. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  36803. */
  36804. update(invertY?: boolean, premulAlpha?: boolean): void;
  36805. /**
  36806. * Draws text onto the texture
  36807. * @param text defines the text to be drawn
  36808. * @param x defines the placement of the text from the left
  36809. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  36810. * @param font defines the font to be used with font-style, font-size, font-name
  36811. * @param color defines the color used for the text
  36812. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  36813. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36814. * @param update defines whether texture is immediately update (default is true)
  36815. */
  36816. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  36817. /**
  36818. * Clones the texture
  36819. * @returns the clone of the texture.
  36820. */
  36821. clone(): DynamicTexture;
  36822. /**
  36823. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  36824. * @returns a serialized dynamic texture object
  36825. */
  36826. serialize(): any;
  36827. /** @hidden */
  36828. }
  36829. }
  36830. declare module BABYLON {
  36831. /**
  36832. * This represents a texture coming from an HDR input.
  36833. *
  36834. * The only supported format is currently panorama picture stored in RGBE format.
  36835. * Example of such files can be found on HDRLib: http://hdrlib.com/
  36836. */
  36837. class HDRCubeTexture extends BaseTexture {
  36838. private static _facesMapping;
  36839. private _generateHarmonics;
  36840. private _noMipmap;
  36841. private _textureMatrix;
  36842. private _size;
  36843. private _onLoad;
  36844. private _onError;
  36845. /**
  36846. * The texture URL.
  36847. */
  36848. url: string;
  36849. /**
  36850. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  36851. */
  36852. coordinatesMode: number;
  36853. protected _isBlocking: boolean;
  36854. /**
  36855. * Sets wether or not the texture is blocking during loading.
  36856. */
  36857. /**
  36858. * Gets wether or not the texture is blocking during loading.
  36859. */
  36860. isBlocking: boolean;
  36861. protected _rotationY: number;
  36862. /**
  36863. * Sets texture matrix rotation angle around Y axis in radians.
  36864. */
  36865. /**
  36866. * Gets texture matrix rotation angle around Y axis radians.
  36867. */
  36868. rotationY: number;
  36869. /**
  36870. * Gets or sets the center of the bounding box associated with the cube texture
  36871. * It must define where the camera used to render the texture was set
  36872. */
  36873. boundingBoxPosition: Vector3;
  36874. private _boundingBoxSize;
  36875. /**
  36876. * Gets or sets the size of the bounding box associated with the cube texture
  36877. * When defined, the cubemap will switch to local mode
  36878. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36879. * @example https://www.babylonjs-playground.com/#RNASML
  36880. */
  36881. boundingBoxSize: Vector3;
  36882. /**
  36883. * Instantiates an HDRTexture from the following parameters.
  36884. *
  36885. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  36886. * @param scene The scene the texture will be used in
  36887. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  36888. * @param noMipmap Forces to not generate the mipmap if true
  36889. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  36890. * @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)
  36891. * @param reserved Reserved flag for internal use.
  36892. */
  36893. 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>);
  36894. /**
  36895. * Occurs when the file is raw .hdr file.
  36896. */
  36897. private loadTexture;
  36898. clone(): HDRCubeTexture;
  36899. delayLoad(): void;
  36900. getReflectionTextureMatrix(): Matrix;
  36901. setReflectionTextureMatrix(value: Matrix): void;
  36902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  36903. serialize(): any;
  36904. }
  36905. }
  36906. declare module BABYLON {
  36907. /**
  36908. * Class used to store data associated with WebGL texture data for the engine
  36909. * This class should not be used directly
  36910. */
  36911. class InternalTexture implements IInternalTextureTracker {
  36912. /**
  36913. * The source of the texture data is unknown
  36914. */
  36915. static DATASOURCE_UNKNOWN: number;
  36916. /**
  36917. * Texture data comes from an URL
  36918. */
  36919. static DATASOURCE_URL: number;
  36920. /**
  36921. * Texture data is only used for temporary storage
  36922. */
  36923. static DATASOURCE_TEMP: number;
  36924. /**
  36925. * Texture data comes from raw data (ArrayBuffer)
  36926. */
  36927. static DATASOURCE_RAW: number;
  36928. /**
  36929. * Texture content is dynamic (video or dynamic texture)
  36930. */
  36931. static DATASOURCE_DYNAMIC: number;
  36932. /**
  36933. * Texture content is generated by rendering to it
  36934. */
  36935. static DATASOURCE_RENDERTARGET: number;
  36936. /**
  36937. * Texture content is part of a multi render target process
  36938. */
  36939. static DATASOURCE_MULTIRENDERTARGET: number;
  36940. /**
  36941. * Texture data comes from a cube data file
  36942. */
  36943. static DATASOURCE_CUBE: number;
  36944. /**
  36945. * Texture data comes from a raw cube data
  36946. */
  36947. static DATASOURCE_CUBERAW: number;
  36948. /**
  36949. * Texture data come from a prefiltered cube data file
  36950. */
  36951. static DATASOURCE_CUBEPREFILTERED: number;
  36952. /**
  36953. * Texture content is raw 3D data
  36954. */
  36955. static DATASOURCE_RAW3D: number;
  36956. /**
  36957. * Texture content is a depth texture
  36958. */
  36959. static DATASOURCE_DEPTHTEXTURE: number;
  36960. /**
  36961. * Texture data comes from a raw cube data encoded with RGBD
  36962. */
  36963. static DATASOURCE_CUBERAW_RGBD: number;
  36964. /**
  36965. * Defines if the texture is ready
  36966. */
  36967. isReady: boolean;
  36968. /**
  36969. * Defines if the texture is a cube texture
  36970. */
  36971. isCube: boolean;
  36972. /**
  36973. * Defines if the texture contains 3D data
  36974. */
  36975. is3D: boolean;
  36976. /**
  36977. * Gets the URL used to load this texture
  36978. */
  36979. url: string;
  36980. /**
  36981. * Gets the sampling mode of the texture
  36982. */
  36983. samplingMode: number;
  36984. /**
  36985. * Gets a boolean indicating if the texture needs mipmaps generation
  36986. */
  36987. generateMipMaps: boolean;
  36988. /**
  36989. * Gets the number of samples used by the texture (WebGL2+ only)
  36990. */
  36991. samples: number;
  36992. /**
  36993. * Gets the type of the texture
  36994. */
  36995. type: number;
  36996. /**
  36997. * Gets the format of the texture
  36998. */
  36999. format: number;
  37000. /**
  37001. * Observable called when the texture is loaded
  37002. */
  37003. onLoadedObservable: Observable<InternalTexture>;
  37004. /**
  37005. * Gets the width of the texture
  37006. */
  37007. width: number;
  37008. /**
  37009. * Gets the height of the texture
  37010. */
  37011. height: number;
  37012. /**
  37013. * Gets the depth of the texture
  37014. */
  37015. depth: number;
  37016. /**
  37017. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37018. */
  37019. baseWidth: number;
  37020. /**
  37021. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37022. */
  37023. baseHeight: number;
  37024. /**
  37025. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37026. */
  37027. baseDepth: number;
  37028. /**
  37029. * Gets a boolean indicating if the texture is inverted on Y axis
  37030. */
  37031. invertY: boolean;
  37032. /**
  37033. * Gets or set the previous tracker in the list
  37034. */
  37035. previous: Nullable<IInternalTextureTracker>;
  37036. /**
  37037. * Gets or set the next tracker in the list
  37038. */
  37039. next: Nullable<IInternalTextureTracker>;
  37040. /** @hidden */
  37041. /** @hidden */
  37042. /** @hidden */
  37043. /** @hidden */
  37044. /** @hidden */
  37045. /** @hidden */
  37046. /** @hidden */
  37047. /** @hidden */
  37048. /** @hidden */
  37049. /** @hidden */
  37050. /** @hidden */
  37051. /** @hidden */
  37052. /** @hidden */
  37053. /** @hidden */
  37054. /** @hidden */
  37055. /** @hidden */
  37056. /** @hidden */
  37057. /** @hidden */
  37058. /** @hidden */
  37059. /** @hidden */
  37060. /** @hidden */
  37061. /** @hidden */
  37062. /** @hidden */
  37063. /** @hidden */
  37064. /** @hidden */
  37065. /** @hidden */
  37066. /** @hidden */
  37067. /** @hidden */
  37068. /** @hidden */
  37069. /** @hidden */
  37070. /** @hidden */
  37071. /** @hidden */
  37072. /** @hidden */
  37073. /** @hidden */
  37074. /** @hidden */
  37075. /** @hidden */
  37076. private _engine;
  37077. /**
  37078. * Gets the Engine the texture belongs to.
  37079. * @returns The babylon engine
  37080. */
  37081. getEngine(): Engine;
  37082. /**
  37083. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  37084. */
  37085. readonly dataSource: number;
  37086. /**
  37087. * Creates a new InternalTexture
  37088. * @param engine defines the engine to use
  37089. * @param dataSource defines the type of data that will be used
  37090. */
  37091. constructor(engine: Engine, dataSource: number);
  37092. /**
  37093. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  37094. */
  37095. incrementReferences(): void;
  37096. /**
  37097. * Change the size of the texture (not the size of the content)
  37098. * @param width defines the new width
  37099. * @param height defines the new height
  37100. * @param depth defines the new depth (1 by default)
  37101. */
  37102. updateSize(width: int, height: int, depth?: int): void;
  37103. /** @hidden */
  37104. /** @hidden */
  37105. /**
  37106. * Dispose the current allocated resources
  37107. */
  37108. dispose(): void;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * This represents the required contract to create a new type of texture loader.
  37114. */
  37115. interface IInternalTextureLoader {
  37116. /**
  37117. * Defines wether the loader supports cascade loading the different faces.
  37118. */
  37119. supportCascades: boolean;
  37120. /**
  37121. * This returns if the loader support the current file information.
  37122. * @param extension defines the file extension of the file being loaded
  37123. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37124. * @param fallback defines the fallback internal texture if any
  37125. * @param isBase64 defines whether the texture is encoded as a base64
  37126. * @param isBuffer defines whether the texture data are stored as a buffer
  37127. * @returns true if the loader can load the specified file
  37128. */
  37129. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  37130. /**
  37131. * Transform the url before loading if required.
  37132. * @param rootUrl the url of the texture
  37133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37134. * @returns the transformed texture
  37135. */
  37136. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  37137. /**
  37138. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  37139. * @param rootUrl the url of the texture
  37140. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37141. * @returns the fallback texture
  37142. */
  37143. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  37144. /**
  37145. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  37146. * @param data contains the texture data
  37147. * @param texture defines the BabylonJS internal texture
  37148. * @param createPolynomials will be true if polynomials have been requested
  37149. * @param onLoad defines the callback to trigger once the texture is ready
  37150. * @param onError defines the callback to trigger in case of error
  37151. */
  37152. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  37153. /**
  37154. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  37155. * @param data contains the texture data
  37156. * @param texture defines the BabylonJS internal texture
  37157. * @param callback defines the method to call once ready to upload
  37158. */
  37159. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  37160. }
  37161. }
  37162. declare module BABYLON {
  37163. /**
  37164. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  37165. */
  37166. interface IInternalTextureTracker {
  37167. /**
  37168. * Gets or set the previous tracker in the list
  37169. */
  37170. previous: Nullable<IInternalTextureTracker>;
  37171. /**
  37172. * Gets or set the next tracker in the list
  37173. */
  37174. next: Nullable<IInternalTextureTracker>;
  37175. }
  37176. /**
  37177. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  37178. */
  37179. class DummyInternalTextureTracker {
  37180. /**
  37181. * Gets or set the previous tracker in the list
  37182. */
  37183. previous: Nullable<IInternalTextureTracker>;
  37184. /**
  37185. * Gets or set the next tracker in the list
  37186. */
  37187. next: Nullable<IInternalTextureTracker>;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. class MirrorTexture extends RenderTargetTexture {
  37192. private scene;
  37193. mirrorPlane: Plane;
  37194. private _transformMatrix;
  37195. private _mirrorMatrix;
  37196. private _savedViewMatrix;
  37197. private _blurX;
  37198. private _blurY;
  37199. private _adaptiveBlurKernel;
  37200. private _blurKernelX;
  37201. private _blurKernelY;
  37202. private _blurRatio;
  37203. blurRatio: number;
  37204. adaptiveBlurKernel: number;
  37205. blurKernel: number;
  37206. blurKernelX: number;
  37207. blurKernelY: number;
  37208. private _autoComputeBlurKernel;
  37209. protected _onRatioRescale(): void;
  37210. private _updateGammaSpace;
  37211. private _imageProcessingConfigChangeObserver;
  37212. constructor(name: string, size: number | {
  37213. width: number;
  37214. height: number;
  37215. } | {
  37216. ratio: number;
  37217. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  37218. private _preparePostProcesses;
  37219. clone(): MirrorTexture;
  37220. serialize(): any;
  37221. dispose(): void;
  37222. }
  37223. }
  37224. declare module BABYLON {
  37225. interface IMultiRenderTargetOptions {
  37226. generateMipMaps?: boolean;
  37227. types?: number[];
  37228. samplingModes?: number[];
  37229. generateDepthBuffer?: boolean;
  37230. generateStencilBuffer?: boolean;
  37231. generateDepthTexture?: boolean;
  37232. textureCount?: number;
  37233. doNotChangeAspectRatio?: boolean;
  37234. defaultType?: number;
  37235. }
  37236. class MultiRenderTarget extends RenderTargetTexture {
  37237. private _internalTextures;
  37238. private _textures;
  37239. readonly isSupported: boolean;
  37240. private _multiRenderTargetOptions;
  37241. readonly textures: Texture[];
  37242. readonly depthTexture: Texture;
  37243. wrapU: number;
  37244. wrapV: number;
  37245. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  37246. /** @hidden */
  37247. private _createInternalTextures;
  37248. private _createTextures;
  37249. samples: number;
  37250. resize(size: any): void;
  37251. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37252. dispose(): void;
  37253. releaseInternalTextures(): void;
  37254. }
  37255. }
  37256. declare module BABYLON {
  37257. /**
  37258. * Raw cube texture where the raw buffers are passed in
  37259. */
  37260. class RawCubeTexture extends CubeTexture {
  37261. /**
  37262. * Creates a cube texture where the raw buffers are passed in.
  37263. * @param scene defines the scene the texture is attached to
  37264. * @param data defines the array of data to use to create each face
  37265. * @param size defines the size of the textures
  37266. * @param format defines the format of the data
  37267. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  37268. * @param generateMipMaps defines if the engine should generate the mip levels
  37269. * @param invertY defines if data must be stored with Y axis inverted
  37270. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  37271. * @param compression defines the compression used (null by default)
  37272. */
  37273. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  37274. /**
  37275. * Updates the raw cube texture.
  37276. * @param data defines the data to store
  37277. * @param format defines the data format
  37278. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  37279. * @param invertY defines if data must be stored with Y axis inverted
  37280. * @param compression defines the compression used (null by default)
  37281. * @param level defines which level of the texture to update
  37282. */
  37283. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  37284. /**
  37285. * Updates a raw cube texture with RGBD encoded data.
  37286. * @param data defines the array of data [mipmap][face] to use to create each face
  37287. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  37288. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37289. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37290. * @returns a promsie that resolves when the operation is complete
  37291. */
  37292. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  37293. /**
  37294. * Clones the raw cube texture.
  37295. * @return a new cube texture
  37296. */
  37297. clone(): CubeTexture;
  37298. /** @hidden */
  37299. private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  37300. }
  37301. }
  37302. declare module BABYLON {
  37303. class RawTexture extends Texture {
  37304. format: number;
  37305. private _engine;
  37306. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  37307. update(data: ArrayBufferView): void;
  37308. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37309. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37310. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37311. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37312. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37313. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37314. }
  37315. }
  37316. declare module BABYLON {
  37317. /**
  37318. * Class used to store 3D textures containing user data
  37319. */
  37320. class RawTexture3D extends Texture {
  37321. /** Gets or sets the texture format to use */
  37322. format: number;
  37323. private _engine;
  37324. /**
  37325. * Create a new RawTexture3D
  37326. * @param data defines the data of the texture
  37327. * @param width defines the width of the texture
  37328. * @param height defines the height of the texture
  37329. * @param depth defines the depth of the texture
  37330. * @param format defines the texture format to use
  37331. * @param scene defines the hosting scene
  37332. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  37333. * @param invertY defines if texture must be stored with Y axis inverted
  37334. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37335. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  37336. */
  37337. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  37338. /** Gets or sets the texture format to use */
  37339. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  37340. /**
  37341. * Update the texture with new data
  37342. * @param data defines the data to store in the texture
  37343. */
  37344. update(data: ArrayBufferView): void;
  37345. }
  37346. }
  37347. declare module BABYLON {
  37348. /**
  37349. * Creates a refraction texture used by refraction channel of the standard material.
  37350. * @param name the texture name
  37351. * @param size size of the underlying texture
  37352. * @param scene root scene
  37353. */
  37354. class RefractionTexture extends RenderTargetTexture {
  37355. refractionPlane: Plane;
  37356. depth: number;
  37357. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  37358. clone(): RefractionTexture;
  37359. serialize(): any;
  37360. }
  37361. }
  37362. declare module BABYLON {
  37363. class RenderTargetTexture extends Texture {
  37364. isCube: boolean;
  37365. private static _REFRESHRATE_RENDER_ONCE: number;
  37366. private static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37367. private static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37368. static readonly REFRESHRATE_RENDER_ONCE: number;
  37369. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37370. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37371. /**
  37372. * Use this predicate to dynamically define the list of mesh you want to render.
  37373. * If set, the renderList property will be overwritten.
  37374. */
  37375. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37376. private _renderList;
  37377. /**
  37378. * Use this list to define the list of mesh you want to render.
  37379. */
  37380. renderList: Nullable<Array<AbstractMesh>>;
  37381. private _hookArray;
  37382. renderParticles: boolean;
  37383. renderSprites: boolean;
  37384. coordinatesMode: number;
  37385. activeCamera: Nullable<Camera>;
  37386. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37387. useCameraPostProcesses: boolean;
  37388. ignoreCameraViewport: boolean;
  37389. private _postProcessManager;
  37390. private _postProcesses;
  37391. private _resizeObserver;
  37392. /**
  37393. * An event triggered when the texture is unbind.
  37394. */
  37395. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37396. /**
  37397. * An event triggered when the texture is unbind.
  37398. */
  37399. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37400. private _onAfterUnbindObserver;
  37401. onAfterUnbind: () => void;
  37402. /**
  37403. * An event triggered before rendering the texture
  37404. */
  37405. onBeforeRenderObservable: Observable<number>;
  37406. private _onBeforeRenderObserver;
  37407. onBeforeRender: (faceIndex: number) => void;
  37408. /**
  37409. * An event triggered after rendering the texture
  37410. */
  37411. onAfterRenderObservable: Observable<number>;
  37412. private _onAfterRenderObserver;
  37413. onAfterRender: (faceIndex: number) => void;
  37414. /**
  37415. * An event triggered after the texture clear
  37416. */
  37417. onClearObservable: Observable<Engine>;
  37418. private _onClearObserver;
  37419. onClear: (Engine: Engine) => void;
  37420. clearColor: Color4;
  37421. protected _size: number | {
  37422. width: number;
  37423. height: number;
  37424. };
  37425. protected _initialSizeParameter: number | {
  37426. width: number;
  37427. height: number;
  37428. } | {
  37429. ratio: number;
  37430. };
  37431. protected _sizeRatio: Nullable<number>;
  37432. /** @hidden */
  37433. protected _renderingManager: RenderingManager;
  37434. /** @hidden */
  37435. protected _doNotChangeAspectRatio: boolean;
  37436. protected _currentRefreshId: number;
  37437. protected _refreshRate: number;
  37438. protected _textureMatrix: Matrix;
  37439. protected _samples: number;
  37440. protected _renderTargetOptions: RenderTargetCreationOptions;
  37441. readonly renderTargetOptions: RenderTargetCreationOptions;
  37442. protected _engine: Engine;
  37443. protected _onRatioRescale(): void;
  37444. /**
  37445. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37446. * It must define where the camera used to render the texture is set
  37447. */
  37448. boundingBoxPosition: Vector3;
  37449. private _boundingBoxSize;
  37450. /**
  37451. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37452. * When defined, the cubemap will switch to local mode
  37453. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37454. * @example https://www.babylonjs-playground.com/#RNASML
  37455. */
  37456. boundingBoxSize: Vector3;
  37457. /**
  37458. * In case the RTT has been created with a depth texture, get the associated
  37459. * depth texture.
  37460. * Otherwise, return null.
  37461. */
  37462. depthStencilTexture: Nullable<InternalTexture>;
  37463. /**
  37464. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  37465. * or used a shadow, depth texture...
  37466. * @param name The friendly name of the texture
  37467. * @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)
  37468. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37469. * @param generateMipMaps True if mip maps need to be generated after render.
  37470. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37471. * @param type The type of the buffer in the RTT (int, half float, float...)
  37472. * @param isCube True if a cube texture needs to be created
  37473. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37474. * @param generateDepthBuffer True to generate a depth buffer
  37475. * @param generateStencilBuffer True to generate a stencil buffer
  37476. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37477. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37478. */
  37479. constructor(name: string, size: number | {
  37480. width: number;
  37481. height: number;
  37482. } | {
  37483. ratio: number;
  37484. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  37485. /**
  37486. * Creates a depth stencil texture.
  37487. * This is only available in WebGL 2 or with the depth texture extension available.
  37488. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37489. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37490. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37491. */
  37492. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37493. private _processSizeParameter;
  37494. samples: number;
  37495. resetRefreshCounter(): void;
  37496. refreshRate: number;
  37497. addPostProcess(postProcess: PostProcess): void;
  37498. clearPostProcesses(dispose?: boolean): void;
  37499. removePostProcess(postProcess: PostProcess): void;
  37500. /** @hidden */
  37501. getRenderSize(): number;
  37502. getRenderWidth(): number;
  37503. getRenderHeight(): number;
  37504. readonly canRescale: boolean;
  37505. scale(ratio: number): void;
  37506. getReflectionTextureMatrix(): Matrix;
  37507. resize(size: number | {
  37508. width: number;
  37509. height: number;
  37510. } | {
  37511. ratio: number;
  37512. }): void;
  37513. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37514. private _bestReflectionRenderTargetDimension;
  37515. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37516. private renderToTarget;
  37517. /**
  37518. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37519. * This allowed control for front to back rendering or reversly depending of the special needs.
  37520. *
  37521. * @param renderingGroupId The rendering group id corresponding to its index
  37522. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37523. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37524. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37525. */
  37526. 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;
  37527. /**
  37528. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37529. *
  37530. * @param renderingGroupId The rendering group id corresponding to its index
  37531. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37532. */
  37533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37534. clone(): RenderTargetTexture;
  37535. serialize(): any;
  37536. disposeFramebufferObjects(): void;
  37537. dispose(): void;
  37538. /** @hidden */
  37539. /**
  37540. * Clear the info related to rendering groups preventing retention point in material dispose.
  37541. */
  37542. freeRenderingGroups(): void;
  37543. }
  37544. }
  37545. declare module BABYLON {
  37546. class Texture extends BaseTexture {
  37547. static NEAREST_SAMPLINGMODE: number;
  37548. static NEAREST_NEAREST_MIPLINEAR: number;
  37549. static BILINEAR_SAMPLINGMODE: number;
  37550. static LINEAR_LINEAR_MIPNEAREST: number;
  37551. static TRILINEAR_SAMPLINGMODE: number;
  37552. static LINEAR_LINEAR_MIPLINEAR: number;
  37553. static NEAREST_NEAREST_MIPNEAREST: number;
  37554. static NEAREST_LINEAR_MIPNEAREST: number;
  37555. static NEAREST_LINEAR_MIPLINEAR: number;
  37556. static NEAREST_LINEAR: number;
  37557. static NEAREST_NEAREST: number;
  37558. static LINEAR_NEAREST_MIPNEAREST: number;
  37559. static LINEAR_NEAREST_MIPLINEAR: number;
  37560. static LINEAR_LINEAR: number;
  37561. static LINEAR_NEAREST: number;
  37562. static EXPLICIT_MODE: number;
  37563. static SPHERICAL_MODE: number;
  37564. static PLANAR_MODE: number;
  37565. static CUBIC_MODE: number;
  37566. static PROJECTION_MODE: number;
  37567. static SKYBOX_MODE: number;
  37568. static INVCUBIC_MODE: number;
  37569. static EQUIRECTANGULAR_MODE: number;
  37570. static FIXED_EQUIRECTANGULAR_MODE: number;
  37571. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37572. static readonly CLAMP_ADDRESSMODE: number;
  37573. static readonly WRAP_ADDRESSMODE: number;
  37574. static readonly MIRROR_ADDRESSMODE: number;
  37575. /**
  37576. * 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
  37577. */
  37578. static UseSerializedUrlIfAny: boolean;
  37579. url: Nullable<string>;
  37580. uOffset: number;
  37581. vOffset: number;
  37582. uScale: number;
  37583. vScale: number;
  37584. uAng: number;
  37585. vAng: number;
  37586. wAng: number;
  37587. /**
  37588. * Defines the center of rotation (U)
  37589. */
  37590. uRotationCenter: number;
  37591. /**
  37592. * Defines the center of rotation (V)
  37593. */
  37594. vRotationCenter: number;
  37595. /**
  37596. * Defines the center of rotation (W)
  37597. */
  37598. wRotationCenter: number;
  37599. readonly noMipmap: boolean;
  37600. private _noMipmap;
  37601. /** @hidden */
  37602. private _rowGenerationMatrix;
  37603. private _cachedTextureMatrix;
  37604. private _projectionModeMatrix;
  37605. private _t0;
  37606. private _t1;
  37607. private _t2;
  37608. private _cachedUOffset;
  37609. private _cachedVOffset;
  37610. private _cachedUScale;
  37611. private _cachedVScale;
  37612. private _cachedUAng;
  37613. private _cachedVAng;
  37614. private _cachedWAng;
  37615. private _cachedProjectionMatrixId;
  37616. private _cachedCoordinatesMode;
  37617. /** @hidden */
  37618. /** @hidden */
  37619. private _deleteBuffer;
  37620. protected _format: Nullable<number>;
  37621. private _delayedOnLoad;
  37622. private _delayedOnError;
  37623. protected _onLoadObservable: Nullable<Observable<Texture>>;
  37624. protected _isBlocking: boolean;
  37625. isBlocking: boolean;
  37626. readonly samplingMode: number;
  37627. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  37628. /**
  37629. * Update the url (and optional buffer) of this texture if url was null during construction.
  37630. * @param url the url of the texture
  37631. * @param buffer the buffer of the texture (defaults to null)
  37632. */
  37633. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  37634. delayLoad(): void;
  37635. /**
  37636. * Default is Trilinear mode.
  37637. *
  37638. * | Value | Type | Description |
  37639. * | ----- | ------------------ | ----------- |
  37640. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37641. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37642. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37643. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37644. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37645. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37646. * | 7 | NEAREST_LINEAR | |
  37647. * | 8 | NEAREST_NEAREST | |
  37648. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37649. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37650. * | 11 | LINEAR_LINEAR | |
  37651. * | 12 | LINEAR_NEAREST | |
  37652. *
  37653. * > _mag_: magnification filter (close to the viewer)
  37654. * > _min_: minification filter (far from the viewer)
  37655. * > _mip_: filter used between mip map levels
  37656. *
  37657. */
  37658. updateSamplingMode(samplingMode: number): void;
  37659. private _prepareRowForTextureGeneration;
  37660. getTextureMatrix(): Matrix;
  37661. getReflectionTextureMatrix(): Matrix;
  37662. clone(): Texture;
  37663. readonly onLoadObservable: Observable<Texture>;
  37664. serialize(): any;
  37665. getClassName(): string;
  37666. dispose(): void;
  37667. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  37668. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  37669. 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;
  37670. }
  37671. }
  37672. declare module BABYLON {
  37673. /**
  37674. * Settings for finer control over video usage
  37675. */
  37676. interface VideoTextureSettings {
  37677. /**
  37678. * Applies `autoplay` to video, if specified
  37679. */
  37680. autoPlay?: boolean;
  37681. /**
  37682. * Applies `loop` to video, if specified
  37683. */
  37684. loop?: boolean;
  37685. /**
  37686. * Automatically updates internal texture from video at every frame in the render loop
  37687. */
  37688. autoUpdateTexture: boolean;
  37689. /**
  37690. * Image src displayed during the video loading or until the user interacts with the video.
  37691. */
  37692. poster?: string;
  37693. }
  37694. class VideoTexture extends Texture {
  37695. /**
  37696. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  37697. */
  37698. readonly autoUpdateTexture: boolean;
  37699. /**
  37700. * The video instance used by the texture internally
  37701. */
  37702. readonly video: HTMLVideoElement;
  37703. private _onUserActionRequestedObservable;
  37704. readonly onUserActionRequestedObservable: Observable<Texture>;
  37705. private _generateMipMaps;
  37706. private _engine;
  37707. private _stillImageCaptured;
  37708. private _poster;
  37709. /**
  37710. * Creates a video texture.
  37711. * Sample : https://doc.babylonjs.com/how_to/video_texture
  37712. * @param {string | null} name optional name, will detect from video source, if not defined
  37713. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37714. * @param {BABYLON.Scene} scene is obviously the current scene.
  37715. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37716. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37717. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37718. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37719. */
  37720. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37721. private _getName;
  37722. private _getVideo;
  37723. private _createInternalTexture;
  37724. private reset;
  37725. /**
  37726. * @hidden Internal method to initiate `update`.
  37727. */
  37728. /**
  37729. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  37730. */
  37731. update(): void;
  37732. /**
  37733. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  37734. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  37735. */
  37736. updateTexture(isVisible: boolean): void;
  37737. protected _updateInternalTexture: (e?: Event | undefined) => void;
  37738. /**
  37739. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  37740. * @param url New url.
  37741. */
  37742. updateURL(url: string): void;
  37743. dispose(): void;
  37744. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  37745. minWidth: number;
  37746. maxWidth: number;
  37747. minHeight: number;
  37748. maxHeight: number;
  37749. deviceId: string;
  37750. }): void;
  37751. }
  37752. }
  37753. declare var DracoDecoderModule: any;
  37754. declare var WebAssembly: any;
  37755. declare module BABYLON {
  37756. /**
  37757. * Configuration for Draco compression
  37758. */
  37759. interface IDracoCompressionConfiguration {
  37760. /**
  37761. * Configuration for the decoder.
  37762. */
  37763. decoder?: {
  37764. /**
  37765. * The url to the WebAssembly module.
  37766. */
  37767. wasmUrl?: string;
  37768. /**
  37769. * The url to the WebAssembly binary.
  37770. */
  37771. wasmBinaryUrl?: string;
  37772. /**
  37773. * The url to the fallback JavaScript module.
  37774. */
  37775. fallbackUrl?: string;
  37776. };
  37777. }
  37778. /**
  37779. * Draco compression (https://google.github.io/draco/)
  37780. *
  37781. * This class wraps the Draco module.
  37782. *
  37783. * **Encoder**
  37784. *
  37785. * The encoder is not currently implemented.
  37786. *
  37787. * **Decoder**
  37788. *
  37789. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  37790. *
  37791. * To update the configuration, use the following code:
  37792. * ```javascript
  37793. * BABYLON.DracoCompression.Configuration = {
  37794. * decoder: {
  37795. * wasmUrl: "<url to the WebAssembly library>",
  37796. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  37797. * fallbackUrl: "<url to the fallback JavaScript library>",
  37798. * }
  37799. * };
  37800. * ```
  37801. *
  37802. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  37803. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  37804. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  37805. *
  37806. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  37807. * ```javascript
  37808. * var dracoCompression = new BABYLON.DracoCompression();
  37809. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  37810. * [BABYLON.VertexBuffer.PositionKind]: 0
  37811. * });
  37812. * ```
  37813. *
  37814. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  37815. */
  37816. class DracoCompression implements IDisposable {
  37817. private static _DecoderModulePromise;
  37818. /**
  37819. * The configuration. Defaults to the following urls:
  37820. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  37821. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  37822. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  37823. */
  37824. static Configuration: IDracoCompressionConfiguration;
  37825. /**
  37826. * Returns true if the decoder is available.
  37827. */
  37828. static readonly DecoderAvailable: boolean;
  37829. /**
  37830. * Constructor
  37831. */
  37832. constructor();
  37833. /**
  37834. * Stop all async operations and release resources.
  37835. */
  37836. dispose(): void;
  37837. /**
  37838. * Decode Draco compressed mesh data to vertex data.
  37839. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  37840. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37841. * @returns A promise that resolves with the decoded vertex data
  37842. */
  37843. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  37844. [kind: string]: number;
  37845. }): Promise<VertexData>;
  37846. private static _GetDecoderModule;
  37847. private static _LoadScriptAsync;
  37848. private static _LoadFileAsync;
  37849. }
  37850. }
  37851. declare module BABYLON {
  37852. class CannonJSPlugin implements IPhysicsEnginePlugin {
  37853. private _useDeltaForWorldStep;
  37854. world: any;
  37855. name: string;
  37856. private _physicsMaterials;
  37857. private _fixedTimeStep;
  37858. BJSCANNON: any;
  37859. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  37860. setGravity(gravity: Vector3): void;
  37861. setTimeStep(timeStep: number): void;
  37862. getTimeStep(): number;
  37863. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37864. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37865. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37866. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37867. private _processChildMeshes;
  37868. removePhysicsBody(impostor: PhysicsImpostor): void;
  37869. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37870. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37871. private _addMaterial;
  37872. private _checkWithEpsilon;
  37873. private _createShape;
  37874. private _createHeightmap;
  37875. private _minus90X;
  37876. private _plus90X;
  37877. private _tmpPosition;
  37878. private _tmpDeltaPosition;
  37879. private _tmpUnityRotation;
  37880. private _updatePhysicsBodyTransformation;
  37881. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37882. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37883. isSupported(): boolean;
  37884. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37885. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37886. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37887. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37888. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37889. getBodyMass(impostor: PhysicsImpostor): number;
  37890. getBodyFriction(impostor: PhysicsImpostor): number;
  37891. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37892. getBodyRestitution(impostor: PhysicsImpostor): number;
  37893. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37894. sleepBody(impostor: PhysicsImpostor): void;
  37895. wakeUpBody(impostor: PhysicsImpostor): void;
  37896. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37897. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  37898. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  37899. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37900. getRadius(impostor: PhysicsImpostor): number;
  37901. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37902. dispose(): void;
  37903. private _extendNamespace;
  37904. }
  37905. }
  37906. declare module BABYLON {
  37907. class OimoJSPlugin implements IPhysicsEnginePlugin {
  37908. world: any;
  37909. name: string;
  37910. BJSOIMO: any;
  37911. constructor(iterations?: number);
  37912. setGravity(gravity: Vector3): void;
  37913. setTimeStep(timeStep: number): void;
  37914. getTimeStep(): number;
  37915. private _tmpImpostorsArray;
  37916. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37917. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37918. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37919. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37920. private _tmpPositionVector;
  37921. removePhysicsBody(impostor: PhysicsImpostor): void;
  37922. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37923. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37924. isSupported(): boolean;
  37925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37926. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37930. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37931. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37932. getBodyMass(impostor: PhysicsImpostor): number;
  37933. getBodyFriction(impostor: PhysicsImpostor): number;
  37934. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37935. getBodyRestitution(impostor: PhysicsImpostor): number;
  37936. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37937. sleepBody(impostor: PhysicsImpostor): void;
  37938. wakeUpBody(impostor: PhysicsImpostor): void;
  37939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37940. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  37941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  37942. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37943. getRadius(impostor: PhysicsImpostor): number;
  37944. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37945. dispose(): void;
  37946. }
  37947. }
  37948. declare module BABYLON {
  37949. /**
  37950. * Particle emitter emitting particles from the inside of a box.
  37951. * It emits the particles randomly between 2 given directions.
  37952. */
  37953. class BoxParticleEmitter implements IParticleEmitterType {
  37954. /**
  37955. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37956. */
  37957. direction1: Vector3;
  37958. /**
  37959. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37960. */
  37961. direction2: Vector3;
  37962. /**
  37963. * 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.
  37964. */
  37965. minEmitBox: Vector3;
  37966. /**
  37967. * 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.
  37968. */
  37969. maxEmitBox: Vector3;
  37970. /**
  37971. * Creates a new instance BoxParticleEmitter
  37972. */
  37973. constructor();
  37974. /**
  37975. * Called by the particle System when the direction is computed for the created particle.
  37976. * @param worldMatrix is the world matrix of the particle system
  37977. * @param directionToUpdate is the direction vector to update with the result
  37978. * @param particle is the particle we are computed the direction for
  37979. */
  37980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37981. /**
  37982. * Called by the particle System when the position is computed for the created particle.
  37983. * @param worldMatrix is the world matrix of the particle system
  37984. * @param positionToUpdate is the position vector to update with the result
  37985. * @param particle is the particle we are computed the position for
  37986. */
  37987. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37988. /**
  37989. * Clones the current emitter and returns a copy of it
  37990. * @returns the new emitter
  37991. */
  37992. clone(): BoxParticleEmitter;
  37993. /**
  37994. * Called by the GPUParticleSystem to setup the update shader
  37995. * @param effect defines the update shader
  37996. */
  37997. applyToShader(effect: Effect): void;
  37998. /**
  37999. * Returns a string to use to update the GPU particles update shader
  38000. * @returns a string containng the defines string
  38001. */
  38002. getEffectDefines(): string;
  38003. /**
  38004. * Returns the string "BoxParticleEmitter"
  38005. * @returns a string containing the class name
  38006. */
  38007. getClassName(): string;
  38008. /**
  38009. * Serializes the particle system to a JSON object.
  38010. * @returns the JSON object
  38011. */
  38012. serialize(): any;
  38013. /**
  38014. * Parse properties from a JSON object
  38015. * @param serializationObject defines the JSON object
  38016. */
  38017. parse(serializationObject: any): void;
  38018. }
  38019. }
  38020. declare module BABYLON {
  38021. /**
  38022. * Particle emitter emitting particles from the inside of a cone.
  38023. * It emits the particles alongside the cone volume from the base to the particle.
  38024. * The emission direction might be randomized.
  38025. */
  38026. class ConeParticleEmitter implements IParticleEmitterType {
  38027. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38028. directionRandomizer: number;
  38029. private _radius;
  38030. private _angle;
  38031. private _height;
  38032. /**
  38033. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  38034. */
  38035. radiusRange: number;
  38036. /**
  38037. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  38038. */
  38039. heightRange: number;
  38040. /**
  38041. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  38042. */
  38043. emitFromSpawnPointOnly: boolean;
  38044. /**
  38045. * Gets or sets the radius of the emission cone
  38046. */
  38047. radius: number;
  38048. /**
  38049. * Gets or sets the angle of the emission cone
  38050. */
  38051. angle: number;
  38052. private _buildHeight;
  38053. /**
  38054. * Creates a new instance ConeParticleEmitter
  38055. * @param radius the radius of the emission cone (1 by default)
  38056. * @param angles the cone base angle (PI by default)
  38057. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  38058. */
  38059. constructor(radius?: number, angle?: number,
  38060. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38061. directionRandomizer?: number);
  38062. /**
  38063. * Called by the particle System when the direction is computed for the created particle.
  38064. * @param worldMatrix is the world matrix of the particle system
  38065. * @param directionToUpdate is the direction vector to update with the result
  38066. * @param particle is the particle we are computed the direction for
  38067. */
  38068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38069. /**
  38070. * Called by the particle System when the position is computed for the created particle.
  38071. * @param worldMatrix is the world matrix of the particle system
  38072. * @param positionToUpdate is the position vector to update with the result
  38073. * @param particle is the particle we are computed the position for
  38074. */
  38075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38076. /**
  38077. * Clones the current emitter and returns a copy of it
  38078. * @returns the new emitter
  38079. */
  38080. clone(): ConeParticleEmitter;
  38081. /**
  38082. * Called by the GPUParticleSystem to setup the update shader
  38083. * @param effect defines the update shader
  38084. */
  38085. applyToShader(effect: Effect): void;
  38086. /**
  38087. * Returns a string to use to update the GPU particles update shader
  38088. * @returns a string containng the defines string
  38089. */
  38090. getEffectDefines(): string;
  38091. /**
  38092. * Returns the string "ConeParticleEmitter"
  38093. * @returns a string containing the class name
  38094. */
  38095. getClassName(): string;
  38096. /**
  38097. * Serializes the particle system to a JSON object.
  38098. * @returns the JSON object
  38099. */
  38100. serialize(): any;
  38101. /**
  38102. * Parse properties from a JSON object
  38103. * @param serializationObject defines the JSON object
  38104. */
  38105. parse(serializationObject: any): void;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * Particle emitter emitting particles from the inside of a cylinder.
  38111. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  38112. */
  38113. class CylinderParticleEmitter implements IParticleEmitterType {
  38114. /**
  38115. * The radius of the emission cylinder.
  38116. */
  38117. radius: number;
  38118. /**
  38119. * The height of the emission cylinder.
  38120. */
  38121. height: number;
  38122. /**
  38123. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38124. */
  38125. radiusRange: number;
  38126. /**
  38127. * How much to randomize the particle direction [0-1].
  38128. */
  38129. directionRandomizer: number;
  38130. /**
  38131. * Creates a new instance CylinderParticleEmitter
  38132. * @param radius the radius of the emission cylinder (1 by default)
  38133. * @param height the height of the emission cylinder (1 by default)
  38134. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38135. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38136. */
  38137. constructor(
  38138. /**
  38139. * The radius of the emission cylinder.
  38140. */
  38141. radius?: number,
  38142. /**
  38143. * The height of the emission cylinder.
  38144. */
  38145. height?: number,
  38146. /**
  38147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38148. */
  38149. radiusRange?: number,
  38150. /**
  38151. * How much to randomize the particle direction [0-1].
  38152. */
  38153. directionRandomizer?: number);
  38154. /**
  38155. * Called by the particle System when the direction is computed for the created particle.
  38156. * @param worldMatrix is the world matrix of the particle system
  38157. * @param directionToUpdate is the direction vector to update with the result
  38158. * @param particle is the particle we are computed the direction for
  38159. */
  38160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38161. /**
  38162. * Called by the particle System when the position is computed for the created particle.
  38163. * @param worldMatrix is the world matrix of the particle system
  38164. * @param positionToUpdate is the position vector to update with the result
  38165. * @param particle is the particle we are computed the position for
  38166. */
  38167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38168. /**
  38169. * Clones the current emitter and returns a copy of it
  38170. * @returns the new emitter
  38171. */
  38172. clone(): CylinderParticleEmitter;
  38173. /**
  38174. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38175. * @param effect defines the update shader
  38176. */
  38177. applyToShader(effect: Effect): void;
  38178. /**
  38179. * Returns a string to use to update the GPU particles update shader
  38180. * @returns a string containng the defines string
  38181. */
  38182. getEffectDefines(): string;
  38183. /**
  38184. * Returns the string "CylinderParticleEmitter"
  38185. * @returns a string containing the class name
  38186. */
  38187. getClassName(): string;
  38188. /**
  38189. * Serializes the particle system to a JSON object.
  38190. * @returns the JSON object
  38191. */
  38192. serialize(): any;
  38193. /**
  38194. * Parse properties from a JSON object
  38195. * @param serializationObject defines the JSON object
  38196. */
  38197. parse(serializationObject: any): void;
  38198. }
  38199. /**
  38200. * Particle emitter emitting particles from the inside of a cylinder.
  38201. * It emits the particles randomly between two vectors.
  38202. */
  38203. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  38204. /**
  38205. * The min limit of the emission direction.
  38206. */
  38207. direction1: Vector3;
  38208. /**
  38209. * The max limit of the emission direction.
  38210. */
  38211. direction2: Vector3;
  38212. /**
  38213. * Creates a new instance CylinderDirectedParticleEmitter
  38214. * @param radius the radius of the emission cylinder (1 by default)
  38215. * @param height the height of the emission cylinder (1 by default)
  38216. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38217. * @param direction1 the min limit of the emission direction (up vector by default)
  38218. * @param direction2 the max limit of the emission direction (up vector by default)
  38219. */
  38220. constructor(radius?: number, height?: number, radiusRange?: number,
  38221. /**
  38222. * The min limit of the emission direction.
  38223. */
  38224. direction1?: Vector3,
  38225. /**
  38226. * The max limit of the emission direction.
  38227. */
  38228. direction2?: Vector3);
  38229. /**
  38230. * Called by the particle System when the direction is computed for the created particle.
  38231. * @param worldMatrix is the world matrix of the particle system
  38232. * @param directionToUpdate is the direction vector to update with the result
  38233. * @param particle is the particle we are computed the direction for
  38234. */
  38235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38236. /**
  38237. * Clones the current emitter and returns a copy of it
  38238. * @returns the new emitter
  38239. */
  38240. clone(): CylinderDirectedParticleEmitter;
  38241. /**
  38242. * Called by the GPUParticleSystem to setup the update shader
  38243. * @param effect defines the update shader
  38244. */
  38245. applyToShader(effect: Effect): void;
  38246. /**
  38247. * Returns a string to use to update the GPU particles update shader
  38248. * @returns a string containng the defines string
  38249. */
  38250. getEffectDefines(): string;
  38251. /**
  38252. * Returns the string "CylinderDirectedParticleEmitter"
  38253. * @returns a string containing the class name
  38254. */
  38255. getClassName(): string;
  38256. /**
  38257. * Serializes the particle system to a JSON object.
  38258. * @returns the JSON object
  38259. */
  38260. serialize(): any;
  38261. /**
  38262. * Parse properties from a JSON object
  38263. * @param serializationObject defines the JSON object
  38264. */
  38265. parse(serializationObject: any): void;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * Particle emitter emitting particles from the inside of a hemisphere.
  38271. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  38272. */
  38273. class HemisphericParticleEmitter implements IParticleEmitterType {
  38274. /**
  38275. * The radius of the emission hemisphere.
  38276. */
  38277. radius: number;
  38278. /**
  38279. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38280. */
  38281. radiusRange: number;
  38282. /**
  38283. * How much to randomize the particle direction [0-1].
  38284. */
  38285. directionRandomizer: number;
  38286. /**
  38287. * Creates a new instance HemisphericParticleEmitter
  38288. * @param radius the radius of the emission hemisphere (1 by default)
  38289. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38290. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38291. */
  38292. constructor(
  38293. /**
  38294. * The radius of the emission hemisphere.
  38295. */
  38296. radius?: number,
  38297. /**
  38298. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38299. */
  38300. radiusRange?: number,
  38301. /**
  38302. * How much to randomize the particle direction [0-1].
  38303. */
  38304. directionRandomizer?: number);
  38305. /**
  38306. * Called by the particle System when the direction is computed for the created particle.
  38307. * @param worldMatrix is the world matrix of the particle system
  38308. * @param directionToUpdate is the direction vector to update with the result
  38309. * @param particle is the particle we are computed the direction for
  38310. */
  38311. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38312. /**
  38313. * Called by the particle System when the position is computed for the created particle.
  38314. * @param worldMatrix is the world matrix of the particle system
  38315. * @param positionToUpdate is the position vector to update with the result
  38316. * @param particle is the particle we are computed the position for
  38317. */
  38318. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38319. /**
  38320. * Clones the current emitter and returns a copy of it
  38321. * @returns the new emitter
  38322. */
  38323. clone(): HemisphericParticleEmitter;
  38324. /**
  38325. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38326. * @param effect defines the update shader
  38327. */
  38328. applyToShader(effect: Effect): void;
  38329. /**
  38330. * Returns a string to use to update the GPU particles update shader
  38331. * @returns a string containng the defines string
  38332. */
  38333. getEffectDefines(): string;
  38334. /**
  38335. * Returns the string "HemisphericParticleEmitter"
  38336. * @returns a string containing the class name
  38337. */
  38338. getClassName(): string;
  38339. /**
  38340. * Serializes the particle system to a JSON object.
  38341. * @returns the JSON object
  38342. */
  38343. serialize(): any;
  38344. /**
  38345. * Parse properties from a JSON object
  38346. * @param serializationObject defines the JSON object
  38347. */
  38348. parse(serializationObject: any): void;
  38349. }
  38350. }
  38351. declare module BABYLON {
  38352. /**
  38353. * Particle emitter represents a volume emitting particles.
  38354. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  38355. */
  38356. interface IParticleEmitterType {
  38357. /**
  38358. * Called by the particle System when the direction is computed for the created particle.
  38359. * @param worldMatrix is the world matrix of the particle system
  38360. * @param directionToUpdate is the direction vector to update with the result
  38361. * @param particle is the particle we are computed the direction for
  38362. */
  38363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38364. /**
  38365. * Called by the particle System when the position is computed for the created particle.
  38366. * @param worldMatrix is the world matrix of the particle system
  38367. * @param positionToUpdate is the position vector to update with the result
  38368. * @param particle is the particle we are computed the position for
  38369. */
  38370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38371. /**
  38372. * Clones the current emitter and returns a copy of it
  38373. * @returns the new emitter
  38374. */
  38375. clone(): IParticleEmitterType;
  38376. /**
  38377. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38378. * @param effect defines the update shader
  38379. */
  38380. applyToShader(effect: Effect): void;
  38381. /**
  38382. * Returns a string to use to update the GPU particles update shader
  38383. * @returns the effect defines string
  38384. */
  38385. getEffectDefines(): string;
  38386. /**
  38387. * Returns a string representing the class name
  38388. * @returns a string containing the class name
  38389. */
  38390. getClassName(): string;
  38391. /**
  38392. * Serializes the particle system to a JSON object.
  38393. * @returns the JSON object
  38394. */
  38395. serialize(): any;
  38396. /**
  38397. * Parse properties from a JSON object
  38398. * @param serializationObject defines the JSON object
  38399. */
  38400. parse(serializationObject: any): void;
  38401. }
  38402. }
  38403. declare module BABYLON {
  38404. /**
  38405. * Particle emitter emitting particles from a point.
  38406. * It emits the particles randomly between 2 given directions.
  38407. */
  38408. class PointParticleEmitter implements IParticleEmitterType {
  38409. /**
  38410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38411. */
  38412. direction1: Vector3;
  38413. /**
  38414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38415. */
  38416. direction2: Vector3;
  38417. /**
  38418. * Creates a new instance PointParticleEmitter
  38419. */
  38420. constructor();
  38421. /**
  38422. * Called by the particle System when the direction is computed for the created particle.
  38423. * @param worldMatrix is the world matrix of the particle system
  38424. * @param directionToUpdate is the direction vector to update with the result
  38425. * @param particle is the particle we are computed the direction for
  38426. */
  38427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38428. /**
  38429. * Called by the particle System when the position is computed for the created particle.
  38430. * @param worldMatrix is the world matrix of the particle system
  38431. * @param positionToUpdate is the position vector to update with the result
  38432. * @param particle is the particle we are computed the position for
  38433. */
  38434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38435. /**
  38436. * Clones the current emitter and returns a copy of it
  38437. * @returns the new emitter
  38438. */
  38439. clone(): PointParticleEmitter;
  38440. /**
  38441. * Called by the GPUParticleSystem to setup the update shader
  38442. * @param effect defines the update shader
  38443. */
  38444. applyToShader(effect: Effect): void;
  38445. /**
  38446. * Returns a string to use to update the GPU particles update shader
  38447. * @returns a string containng the defines string
  38448. */
  38449. getEffectDefines(): string;
  38450. /**
  38451. * Returns the string "PointParticleEmitter"
  38452. * @returns a string containing the class name
  38453. */
  38454. getClassName(): string;
  38455. /**
  38456. * Serializes the particle system to a JSON object.
  38457. * @returns the JSON object
  38458. */
  38459. serialize(): any;
  38460. /**
  38461. * Parse properties from a JSON object
  38462. * @param serializationObject defines the JSON object
  38463. */
  38464. parse(serializationObject: any): void;
  38465. }
  38466. }
  38467. declare module BABYLON {
  38468. /**
  38469. * Particle emitter emitting particles from the inside of a sphere.
  38470. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  38471. */
  38472. class SphereParticleEmitter implements IParticleEmitterType {
  38473. /**
  38474. * The radius of the emission sphere.
  38475. */
  38476. radius: number;
  38477. /**
  38478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38479. */
  38480. radiusRange: number;
  38481. /**
  38482. * How much to randomize the particle direction [0-1].
  38483. */
  38484. directionRandomizer: number;
  38485. /**
  38486. * Creates a new instance SphereParticleEmitter
  38487. * @param radius the radius of the emission sphere (1 by default)
  38488. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38490. */
  38491. constructor(
  38492. /**
  38493. * The radius of the emission sphere.
  38494. */
  38495. radius?: number,
  38496. /**
  38497. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38498. */
  38499. radiusRange?: number,
  38500. /**
  38501. * How much to randomize the particle direction [0-1].
  38502. */
  38503. directionRandomizer?: number);
  38504. /**
  38505. * Called by the particle System when the direction is computed for the created particle.
  38506. * @param worldMatrix is the world matrix of the particle system
  38507. * @param directionToUpdate is the direction vector to update with the result
  38508. * @param particle is the particle we are computed the direction for
  38509. */
  38510. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38511. /**
  38512. * Called by the particle System when the position is computed for the created particle.
  38513. * @param worldMatrix is the world matrix of the particle system
  38514. * @param positionToUpdate is the position vector to update with the result
  38515. * @param particle is the particle we are computed the position for
  38516. */
  38517. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38518. /**
  38519. * Clones the current emitter and returns a copy of it
  38520. * @returns the new emitter
  38521. */
  38522. clone(): SphereParticleEmitter;
  38523. /**
  38524. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38525. * @param effect defines the update shader
  38526. */
  38527. applyToShader(effect: Effect): void;
  38528. /**
  38529. * Returns a string to use to update the GPU particles update shader
  38530. * @returns a string containng the defines string
  38531. */
  38532. getEffectDefines(): string;
  38533. /**
  38534. * Returns the string "SphereParticleEmitter"
  38535. * @returns a string containing the class name
  38536. */
  38537. getClassName(): string;
  38538. /**
  38539. * Serializes the particle system to a JSON object.
  38540. * @returns the JSON object
  38541. */
  38542. serialize(): any;
  38543. /**
  38544. * Parse properties from a JSON object
  38545. * @param serializationObject defines the JSON object
  38546. */
  38547. parse(serializationObject: any): void;
  38548. }
  38549. /**
  38550. * Particle emitter emitting particles from the inside of a sphere.
  38551. * It emits the particles randomly between two vectors.
  38552. */
  38553. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  38554. /**
  38555. * The min limit of the emission direction.
  38556. */
  38557. direction1: Vector3;
  38558. /**
  38559. * The max limit of the emission direction.
  38560. */
  38561. direction2: Vector3;
  38562. /**
  38563. * Creates a new instance SphereDirectedParticleEmitter
  38564. * @param radius the radius of the emission sphere (1 by default)
  38565. * @param direction1 the min limit of the emission direction (up vector by default)
  38566. * @param direction2 the max limit of the emission direction (up vector by default)
  38567. */
  38568. constructor(radius?: number,
  38569. /**
  38570. * The min limit of the emission direction.
  38571. */
  38572. direction1?: Vector3,
  38573. /**
  38574. * The max limit of the emission direction.
  38575. */
  38576. direction2?: Vector3);
  38577. /**
  38578. * Called by the particle System when the direction is computed for the created particle.
  38579. * @param worldMatrix is the world matrix of the particle system
  38580. * @param directionToUpdate is the direction vector to update with the result
  38581. * @param particle is the particle we are computed the direction for
  38582. */
  38583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38584. /**
  38585. * Clones the current emitter and returns a copy of it
  38586. * @returns the new emitter
  38587. */
  38588. clone(): SphereDirectedParticleEmitter;
  38589. /**
  38590. * Called by the GPUParticleSystem to setup the update shader
  38591. * @param effect defines the update shader
  38592. */
  38593. applyToShader(effect: Effect): void;
  38594. /**
  38595. * Returns a string to use to update the GPU particles update shader
  38596. * @returns a string containng the defines string
  38597. */
  38598. getEffectDefines(): string;
  38599. /**
  38600. * Returns the string "SphereDirectedParticleEmitter"
  38601. * @returns a string containing the class name
  38602. */
  38603. getClassName(): string;
  38604. /**
  38605. * Serializes the particle system to a JSON object.
  38606. * @returns the JSON object
  38607. */
  38608. serialize(): any;
  38609. /**
  38610. * Parse properties from a JSON object
  38611. * @param serializationObject defines the JSON object
  38612. */
  38613. parse(serializationObject: any): void;
  38614. }
  38615. }
  38616. declare module BABYLON {
  38617. /**
  38618. * This represents a set of one or more post processes in Babylon.
  38619. * A post process can be used to apply a shader to a texture after it is rendered.
  38620. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38621. */
  38622. class PostProcessRenderEffect {
  38623. private _postProcesses;
  38624. private _getPostProcesses;
  38625. private _singleInstance;
  38626. private _cameras;
  38627. private _indicesForCamera;
  38628. /**
  38629. * Name of the effect
  38630. * @hidden
  38631. */
  38632. /**
  38633. * Instantiates a post process render effect.
  38634. * A post process can be used to apply a shader to a texture after it is rendered.
  38635. * @param engine The engine the effect is tied to
  38636. * @param name The name of the effect
  38637. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  38638. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  38639. */
  38640. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  38641. /**
  38642. * Checks if all the post processes in the effect are supported.
  38643. */
  38644. readonly isSupported: boolean;
  38645. /**
  38646. * Updates the current state of the effect
  38647. * @hidden
  38648. */
  38649. /**
  38650. * Attaches the effect on cameras
  38651. * @param cameras The camera to attach to.
  38652. * @hidden
  38653. */
  38654. /**
  38655. * Attaches the effect on cameras
  38656. * @param cameras The camera to attach to.
  38657. * @hidden
  38658. */
  38659. /**
  38660. * Detatches the effect on cameras
  38661. * @param cameras The camera to detatch from.
  38662. * @hidden
  38663. */
  38664. /**
  38665. * Detatches the effect on cameras
  38666. * @param cameras The camera to detatch from.
  38667. * @hidden
  38668. */
  38669. /**
  38670. * Enables the effect on given cameras
  38671. * @param cameras The camera to enable.
  38672. * @hidden
  38673. */
  38674. /**
  38675. * Enables the effect on given cameras
  38676. * @param cameras The camera to enable.
  38677. * @hidden
  38678. */
  38679. /**
  38680. * Disables the effect on the given cameras
  38681. * @param cameras The camera to disable.
  38682. * @hidden
  38683. */
  38684. /**
  38685. * Disables the effect on the given cameras
  38686. * @param cameras The camera to disable.
  38687. * @hidden
  38688. */
  38689. /**
  38690. * Gets a list of the post processes contained in the effect.
  38691. * @param camera The camera to get the post processes on.
  38692. * @returns The list of the post processes in the effect.
  38693. */
  38694. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  38695. }
  38696. }
  38697. declare module BABYLON {
  38698. class PostProcessRenderPipeline {
  38699. private engine;
  38700. private _renderEffects;
  38701. private _renderEffectsForIsolatedPass;
  38702. protected _cameras: Camera[];
  38703. /** @hidden */
  38704. constructor(engine: Engine, name: string);
  38705. getClassName(): string;
  38706. readonly isSupported: boolean;
  38707. addEffect(renderEffect: PostProcessRenderEffect): void;
  38708. /** @hidden */
  38709. /** @hidden */
  38710. /** @hidden */
  38711. /** @hidden */
  38712. /** @hidden */
  38713. /** @hidden */
  38714. /** @hidden */
  38715. /** @hidden */
  38716. /** @hidden */
  38717. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  38718. dispose(): void;
  38719. }
  38720. }
  38721. declare module BABYLON {
  38722. class PostProcessRenderPipelineManager {
  38723. private _renderPipelines;
  38724. constructor();
  38725. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  38726. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  38727. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  38728. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  38729. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  38730. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38731. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38732. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38733. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38734. update(): void;
  38735. /** @hidden */
  38736. dispose(): void;
  38737. }
  38738. }
  38739. declare module BABYLON {
  38740. interface Scene {
  38741. /** @hidden (Backing field) */
  38742. /**
  38743. * Gets the postprocess render pipeline manager
  38744. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38745. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38746. */
  38747. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38748. }
  38749. /**
  38750. * Defines the Render Pipeline scene component responsible to rendering pipelines
  38751. */
  38752. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  38753. /**
  38754. * The component name helpfull to identify the component in the list of scene components.
  38755. */
  38756. readonly name: string;
  38757. /**
  38758. * The scene the component belongs to.
  38759. */
  38760. scene: Scene;
  38761. /**
  38762. * Creates a new instance of the component for the given scene
  38763. * @param scene Defines the scene to register the component in
  38764. */
  38765. constructor(scene: Scene);
  38766. /**
  38767. * Registers the component in a given scene
  38768. */
  38769. register(): void;
  38770. /**
  38771. * Rebuilds the elements related to this component in case of
  38772. * context lost for instance.
  38773. */
  38774. rebuild(): void;
  38775. /**
  38776. * Disposes the component and the associated ressources
  38777. */
  38778. dispose(): void;
  38779. private _gatherRenderTargets;
  38780. }
  38781. }
  38782. declare module BABYLON {
  38783. /**
  38784. * Helper class dealing with the extraction of spherical polynomial dataArray
  38785. * from a cube map.
  38786. */
  38787. class CubeMapToSphericalPolynomialTools {
  38788. private static FileFaces;
  38789. /**
  38790. * Converts a texture to the according Spherical Polynomial data.
  38791. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38792. *
  38793. * @param texture The texture to extract the information from.
  38794. * @return The Spherical Polynomial data.
  38795. */
  38796. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  38797. /**
  38798. * Converts a cubemap to the according Spherical Polynomial data.
  38799. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38800. *
  38801. * @param cubeInfo The Cube map to extract the information from.
  38802. * @return The Spherical Polynomial data.
  38803. */
  38804. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  38805. }
  38806. }
  38807. declare module BABYLON {
  38808. /**
  38809. * Header information of HDR texture files.
  38810. */
  38811. interface HDRInfo {
  38812. /**
  38813. * The height of the texture in pixels.
  38814. */
  38815. height: number;
  38816. /**
  38817. * The width of the texture in pixels.
  38818. */
  38819. width: number;
  38820. /**
  38821. * The index of the beginning of the data in the binary file.
  38822. */
  38823. dataPosition: number;
  38824. }
  38825. /**
  38826. * This groups tools to convert HDR texture to native colors array.
  38827. */
  38828. class HDRTools {
  38829. private static Ldexp;
  38830. private static Rgbe2float;
  38831. private static readStringLine;
  38832. /**
  38833. * Reads header information from an RGBE texture stored in a native array.
  38834. * More information on this format are available here:
  38835. * https://en.wikipedia.org/wiki/RGBE_image_format
  38836. *
  38837. * @param uint8array The binary file stored in native array.
  38838. * @return The header information.
  38839. */
  38840. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  38841. /**
  38842. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  38843. * This RGBE texture needs to store the information as a panorama.
  38844. *
  38845. * More information on this format are available here:
  38846. * https://en.wikipedia.org/wiki/RGBE_image_format
  38847. *
  38848. * @param buffer The binary file stored in an array buffer.
  38849. * @param size The expected size of the extracted cubemap.
  38850. * @return The Cube Map information.
  38851. */
  38852. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  38853. /**
  38854. * Returns the pixels data extracted from an RGBE texture.
  38855. * This pixels will be stored left to right up to down in the R G B order in one array.
  38856. *
  38857. * More information on this format are available here:
  38858. * https://en.wikipedia.org/wiki/RGBE_image_format
  38859. *
  38860. * @param uint8array The binary file stored in an array buffer.
  38861. * @param hdrInfo The header information of the file.
  38862. * @return The pixels data in RGB right to left up to down order.
  38863. */
  38864. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  38865. private static RGBE_ReadPixels_RLE;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  38871. */
  38872. interface CubeMapInfo {
  38873. /**
  38874. * The pixel array for the front face.
  38875. * This is stored in format, left to right, up to down format.
  38876. */
  38877. front: Nullable<ArrayBufferView>;
  38878. /**
  38879. * The pixel array for the back face.
  38880. * This is stored in format, left to right, up to down format.
  38881. */
  38882. back: Nullable<ArrayBufferView>;
  38883. /**
  38884. * The pixel array for the left face.
  38885. * This is stored in format, left to right, up to down format.
  38886. */
  38887. left: Nullable<ArrayBufferView>;
  38888. /**
  38889. * The pixel array for the right face.
  38890. * This is stored in format, left to right, up to down format.
  38891. */
  38892. right: Nullable<ArrayBufferView>;
  38893. /**
  38894. * The pixel array for the up face.
  38895. * This is stored in format, left to right, up to down format.
  38896. */
  38897. up: Nullable<ArrayBufferView>;
  38898. /**
  38899. * The pixel array for the down face.
  38900. * This is stored in format, left to right, up to down format.
  38901. */
  38902. down: Nullable<ArrayBufferView>;
  38903. /**
  38904. * The size of the cubemap stored.
  38905. *
  38906. * Each faces will be size * size pixels.
  38907. */
  38908. size: number;
  38909. /**
  38910. * The format of the texture.
  38911. *
  38912. * RGBA, RGB.
  38913. */
  38914. format: number;
  38915. /**
  38916. * The type of the texture data.
  38917. *
  38918. * UNSIGNED_INT, FLOAT.
  38919. */
  38920. type: number;
  38921. /**
  38922. * Specifies whether the texture is in gamma space.
  38923. */
  38924. gammaSpace: boolean;
  38925. }
  38926. /**
  38927. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  38928. */
  38929. class PanoramaToCubeMapTools {
  38930. private static FACE_FRONT;
  38931. private static FACE_BACK;
  38932. private static FACE_RIGHT;
  38933. private static FACE_LEFT;
  38934. private static FACE_DOWN;
  38935. private static FACE_UP;
  38936. /**
  38937. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  38938. *
  38939. * @param float32Array The source data.
  38940. * @param inputWidth The width of the input panorama.
  38941. * @param inputhHeight The height of the input panorama.
  38942. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  38943. * @return The cubemap data
  38944. */
  38945. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  38946. private static CreateCubemapTexture;
  38947. private static CalcProjectionSpherical;
  38948. }
  38949. }
  38950. declare module BABYLON {
  38951. class CustomProceduralTexture extends ProceduralTexture {
  38952. private _animate;
  38953. private _time;
  38954. private _config;
  38955. private _texturePath;
  38956. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38957. private loadJson;
  38958. isReady(): boolean;
  38959. render(useCameraPostProcess?: boolean): void;
  38960. updateTextures(): void;
  38961. updateShaderUniforms(): void;
  38962. animate: boolean;
  38963. }
  38964. }
  38965. declare module BABYLON {
  38966. /**
  38967. * Class used to generate noise procedural textures
  38968. */
  38969. class NoiseProceduralTexture extends ProceduralTexture {
  38970. private _time;
  38971. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  38972. brightness: number;
  38973. /** Defines the number of octaves to process */
  38974. octaves: number;
  38975. /** Defines the level of persistence (0.8 by default) */
  38976. persistence: number;
  38977. /** Gets or sets animation speed factor (default is 1) */
  38978. animationSpeedFactor: number;
  38979. /**
  38980. * Creates a new NoiseProceduralTexture
  38981. * @param name defines the name fo the texture
  38982. * @param size defines the size of the texture (default is 256)
  38983. * @param scene defines the hosting scene
  38984. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  38985. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  38986. */
  38987. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38988. private _updateShaderUniforms;
  38989. protected _getDefines(): string;
  38990. /** Generate the current state of the procedural texture */
  38991. render(useCameraPostProcess?: boolean): void;
  38992. /**
  38993. * Serializes this noise procedural texture
  38994. * @returns a serialized noise procedural texture object
  38995. */
  38996. serialize(): any;
  38997. /**
  38998. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  38999. * @param parsedTexture defines parsed texture data
  39000. * @param scene defines the current scene
  39001. * @param rootUrl defines the root URL containing noise procedural texture information
  39002. * @returns a parsed NoiseProceduralTexture
  39003. */
  39004. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39005. }
  39006. }
  39007. declare module BABYLON {
  39008. class ProceduralTexture extends Texture {
  39009. isCube: boolean;
  39010. private _size;
  39011. /** @hidden */
  39012. isEnabled: boolean;
  39013. private _currentRefreshId;
  39014. private _refreshRate;
  39015. onGenerated: () => void;
  39016. private _vertexBuffers;
  39017. private _indexBuffer;
  39018. private _effect;
  39019. private _uniforms;
  39020. private _samplers;
  39021. private _fragment;
  39022. /** @hidden */
  39023. ;
  39024. private _floats;
  39025. private _ints;
  39026. private _floatsArrays;
  39027. private _colors3;
  39028. private _colors4;
  39029. private _vectors2;
  39030. private _vectors3;
  39031. private _matrices;
  39032. private _fallbackTexture;
  39033. private _fallbackTextureUsed;
  39034. private _engine;
  39035. private _cachedDefines;
  39036. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39037. private _createIndexBuffer;
  39038. /** @hidden */
  39039. reset(): void;
  39040. protected _getDefines(): string;
  39041. isReady(): boolean;
  39042. resetRefreshCounter(): void;
  39043. setFragment(fragment: any): void;
  39044. refreshRate: number;
  39045. /** @hidden */
  39046. getRenderSize(): number;
  39047. resize(size: number, generateMipMaps: boolean): void;
  39048. private _checkUniform;
  39049. setTexture(name: string, texture: Texture): ProceduralTexture;
  39050. setFloat(name: string, value: number): ProceduralTexture;
  39051. /**
  39052. * Set the value of an uniform to an integer value
  39053. * @param name defines the name of the uniform
  39054. * @param value defines the value to set
  39055. * @returns the current procedural texture
  39056. */
  39057. setInt(name: string, value: number): ProceduralTexture;
  39058. setFloats(name: string, value: number[]): ProceduralTexture;
  39059. setColor3(name: string, value: Color3): ProceduralTexture;
  39060. setColor4(name: string, value: Color4): ProceduralTexture;
  39061. setVector2(name: string, value: Vector2): ProceduralTexture;
  39062. setVector3(name: string, value: Vector3): ProceduralTexture;
  39063. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39064. render(useCameraPostProcess?: boolean): void;
  39065. clone(): ProceduralTexture;
  39066. dispose(): void;
  39067. }
  39068. }
  39069. declare module BABYLON {
  39070. interface AbstractScene {
  39071. /**
  39072. * The list of procedural textures added to the scene
  39073. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  39074. */
  39075. proceduralTextures: Array<ProceduralTexture>;
  39076. }
  39077. /**
  39078. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  39079. * in a given scene.
  39080. */
  39081. class ProceduralTextureSceneComponent implements ISceneComponent {
  39082. /**
  39083. * The component name helpfull to identify the component in the list of scene components.
  39084. */
  39085. readonly name: string;
  39086. /**
  39087. * The scene the component belongs to.
  39088. */
  39089. scene: Scene;
  39090. /**
  39091. * Creates a new instance of the component for the given scene
  39092. * @param scene Defines the scene to register the component in
  39093. */
  39094. constructor(scene: Scene);
  39095. /**
  39096. * Registers the component in a given scene
  39097. */
  39098. register(): void;
  39099. /**
  39100. * Rebuilds the elements related to this component in case of
  39101. * context lost for instance.
  39102. */
  39103. rebuild(): void;
  39104. /**
  39105. * Disposes the component and the associated ressources.
  39106. */
  39107. dispose(): void;
  39108. private _beforeClear;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. }
  39113. declare module BABYLON {
  39114. }
  39115. declare module BABYLON {
  39116. }
  39117. declare module BABYLON {
  39118. }
  39119. declare module BABYLON {
  39120. /**
  39121. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  39122. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39123. */
  39124. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39125. private _scene;
  39126. private _camerasToBeAttached;
  39127. /**
  39128. * ID of the sharpen post process,
  39129. */
  39130. private readonly SharpenPostProcessId;
  39131. /**
  39132. * ID of the image processing post process;
  39133. */
  39134. readonly ImageProcessingPostProcessId: string;
  39135. /**
  39136. * ID of the Fast Approximate Anti-Aliasing post process;
  39137. */
  39138. readonly FxaaPostProcessId: string;
  39139. /**
  39140. * ID of the chromatic aberration post process,
  39141. */
  39142. private readonly ChromaticAberrationPostProcessId;
  39143. /**
  39144. * ID of the grain post process
  39145. */
  39146. private readonly GrainPostProcessId;
  39147. /**
  39148. * Sharpen post process which will apply a sharpen convolution to enhance edges
  39149. */
  39150. sharpen: SharpenPostProcess;
  39151. private _sharpenEffect;
  39152. private bloom;
  39153. /**
  39154. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  39155. */
  39156. depthOfField: DepthOfFieldEffect;
  39157. /**
  39158. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39159. */
  39160. fxaa: FxaaPostProcess;
  39161. /**
  39162. * Image post processing pass used to perform operations such as tone mapping or color grading.
  39163. */
  39164. imageProcessing: ImageProcessingPostProcess;
  39165. /**
  39166. * Chromatic aberration post process which will shift rgb colors in the image
  39167. */
  39168. chromaticAberration: ChromaticAberrationPostProcess;
  39169. private _chromaticAberrationEffect;
  39170. /**
  39171. * Grain post process which add noise to the image
  39172. */
  39173. grain: GrainPostProcess;
  39174. private _grainEffect;
  39175. /**
  39176. * Glow post process which adds a glow to emmisive areas of the image
  39177. */
  39178. private _glowLayer;
  39179. /**
  39180. * Animations which can be used to tweak settings over a period of time
  39181. */
  39182. animations: Animation[];
  39183. private _imageProcessingConfigurationObserver;
  39184. private _sharpenEnabled;
  39185. private _bloomEnabled;
  39186. private _depthOfFieldEnabled;
  39187. private _depthOfFieldBlurLevel;
  39188. private _fxaaEnabled;
  39189. private _imageProcessingEnabled;
  39190. private _defaultPipelineTextureType;
  39191. private _bloomScale;
  39192. private _chromaticAberrationEnabled;
  39193. private _grainEnabled;
  39194. private _buildAllowed;
  39195. /**
  39196. * Enable or disable the sharpen process from the pipeline
  39197. */
  39198. sharpenEnabled: boolean;
  39199. private _resizeObserver;
  39200. private _hardwareScaleLevel;
  39201. private _bloomKernel;
  39202. /**
  39203. * Specifies the size of the bloom blur kernel, relative to the final output size
  39204. */
  39205. bloomKernel: number;
  39206. /**
  39207. * Specifies the weight of the bloom in the final rendering
  39208. */
  39209. private _bloomWeight;
  39210. /**
  39211. * Specifies the luma threshold for the area that will be blurred by the bloom
  39212. */
  39213. private _bloomThreshold;
  39214. private _hdr;
  39215. /**
  39216. * The strength of the bloom.
  39217. */
  39218. bloomWeight: number;
  39219. /**
  39220. * The strength of the bloom.
  39221. */
  39222. bloomThreshold: number;
  39223. /**
  39224. * The scale of the bloom, lower value will provide better performance.
  39225. */
  39226. bloomScale: number;
  39227. /**
  39228. * Enable or disable the bloom from the pipeline
  39229. */
  39230. bloomEnabled: boolean;
  39231. private _rebuildBloom;
  39232. /**
  39233. * If the depth of field is enabled.
  39234. */
  39235. depthOfFieldEnabled: boolean;
  39236. /**
  39237. * Blur level of the depth of field effect. (Higher blur will effect performance)
  39238. */
  39239. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  39240. /**
  39241. * If the anti aliasing is enabled.
  39242. */
  39243. fxaaEnabled: boolean;
  39244. private _samples;
  39245. /**
  39246. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  39247. */
  39248. samples: number;
  39249. /**
  39250. * If image processing is enabled.
  39251. */
  39252. imageProcessingEnabled: boolean;
  39253. /**
  39254. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  39255. */
  39256. glowLayerEnabled: boolean;
  39257. /**
  39258. * Enable or disable the chromaticAberration process from the pipeline
  39259. */
  39260. chromaticAberrationEnabled: boolean;
  39261. /**
  39262. * Enable or disable the grain process from the pipeline
  39263. */
  39264. grainEnabled: boolean;
  39265. /**
  39266. * @constructor
  39267. * @param {string} name - The rendering pipeline name (default: "")
  39268. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  39269. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  39270. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  39271. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  39272. */
  39273. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  39274. /**
  39275. * Force the compilation of the entire pipeline.
  39276. */
  39277. prepare(): void;
  39278. private _hasCleared;
  39279. private _prevPostProcess;
  39280. private _prevPrevPostProcess;
  39281. private _setAutoClearAndTextureSharing;
  39282. private _buildPipeline;
  39283. private _disposePostProcesses;
  39284. /**
  39285. * Adds a camera to the pipeline
  39286. * @param camera the camera to be added
  39287. */
  39288. addCamera(camera: Camera): void;
  39289. /**
  39290. * Removes a camera from the pipeline
  39291. * @param camera the camera to remove
  39292. */
  39293. removeCamera(camera: Camera): void;
  39294. /**
  39295. * Dispose of the pipeline and stop all post processes
  39296. */
  39297. dispose(): void;
  39298. /**
  39299. * Serialize the rendering pipeline (Used when exporting)
  39300. * @returns the serialized object
  39301. */
  39302. serialize(): any;
  39303. /**
  39304. * Parse the serialized pipeline
  39305. * @param source Source pipeline.
  39306. * @param scene The scene to load the pipeline to.
  39307. * @param rootUrl The URL of the serialized pipeline.
  39308. * @returns An instantiated pipeline from the serialized object.
  39309. */
  39310. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  39311. }
  39312. }
  39313. declare module BABYLON {
  39314. class LensRenderingPipeline extends PostProcessRenderPipeline {
  39315. /**
  39316. * The chromatic aberration PostProcess id in the pipeline
  39317. */
  39318. LensChromaticAberrationEffect: string;
  39319. /**
  39320. * The highlights enhancing PostProcess id in the pipeline
  39321. */
  39322. HighlightsEnhancingEffect: string;
  39323. /**
  39324. * The depth-of-field PostProcess id in the pipeline
  39325. */
  39326. LensDepthOfFieldEffect: string;
  39327. private _scene;
  39328. private _depthTexture;
  39329. private _grainTexture;
  39330. private _chromaticAberrationPostProcess;
  39331. private _highlightsPostProcess;
  39332. private _depthOfFieldPostProcess;
  39333. private _edgeBlur;
  39334. private _grainAmount;
  39335. private _chromaticAberration;
  39336. private _distortion;
  39337. private _highlightsGain;
  39338. private _highlightsThreshold;
  39339. private _dofDistance;
  39340. private _dofAperture;
  39341. private _dofDarken;
  39342. private _dofPentagon;
  39343. private _blurNoise;
  39344. /**
  39345. * @constructor
  39346. *
  39347. * Effect parameters are as follow:
  39348. * {
  39349. * chromatic_aberration: number; // from 0 to x (1 for realism)
  39350. * edge_blur: number; // from 0 to x (1 for realism)
  39351. * distortion: number; // from 0 to x (1 for realism)
  39352. * grain_amount: number; // from 0 to 1
  39353. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  39354. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  39355. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  39356. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  39357. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  39358. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  39359. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  39360. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  39361. * }
  39362. * Note: if an effect parameter is unset, effect is disabled
  39363. *
  39364. * @param {string} name - The rendering pipeline name
  39365. * @param {object} parameters - An object containing all parameters (see above)
  39366. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39367. * @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)
  39368. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39369. */
  39370. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  39371. setEdgeBlur(amount: number): void;
  39372. disableEdgeBlur(): void;
  39373. setGrainAmount(amount: number): void;
  39374. disableGrain(): void;
  39375. setChromaticAberration(amount: number): void;
  39376. disableChromaticAberration(): void;
  39377. setEdgeDistortion(amount: number): void;
  39378. disableEdgeDistortion(): void;
  39379. setFocusDistance(amount: number): void;
  39380. disableDepthOfField(): void;
  39381. setAperture(amount: number): void;
  39382. setDarkenOutOfFocus(amount: number): void;
  39383. enablePentagonBokeh(): void;
  39384. disablePentagonBokeh(): void;
  39385. enableNoiseBlur(): void;
  39386. disableNoiseBlur(): void;
  39387. setHighlightsGain(amount: number): void;
  39388. setHighlightsThreshold(amount: number): void;
  39389. disableHighlights(): void;
  39390. /**
  39391. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  39392. */
  39393. dispose(disableDepthRender?: boolean): void;
  39394. private _createChromaticAberrationPostProcess;
  39395. private _createHighlightsPostProcess;
  39396. private _createDepthOfFieldPostProcess;
  39397. private _createGrainTexture;
  39398. }
  39399. }
  39400. declare module BABYLON {
  39401. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  39402. /**
  39403. * The PassPostProcess id in the pipeline that contains the original scene color
  39404. */
  39405. SSAOOriginalSceneColorEffect: string;
  39406. /**
  39407. * The SSAO PostProcess id in the pipeline
  39408. */
  39409. SSAORenderEffect: string;
  39410. /**
  39411. * The horizontal blur PostProcess id in the pipeline
  39412. */
  39413. SSAOBlurHRenderEffect: string;
  39414. /**
  39415. * The vertical blur PostProcess id in the pipeline
  39416. */
  39417. SSAOBlurVRenderEffect: string;
  39418. /**
  39419. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39420. */
  39421. SSAOCombineRenderEffect: string;
  39422. /**
  39423. * The output strength of the SSAO post-process. Default value is 1.0.
  39424. */
  39425. totalStrength: number;
  39426. /**
  39427. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  39428. */
  39429. maxZ: number;
  39430. /**
  39431. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  39432. */
  39433. minZAspect: number;
  39434. private _samples;
  39435. /**
  39436. * Number of samples used for the SSAO calculations. Default value is 8
  39437. */
  39438. samples: number;
  39439. private _textureSamples;
  39440. /**
  39441. * Number of samples to use for antialiasing
  39442. */
  39443. textureSamples: number;
  39444. /**
  39445. * Ratio object used for SSAO ratio and blur ratio
  39446. */
  39447. private _ratio;
  39448. /**
  39449. * Dynamically generated sphere sampler.
  39450. */
  39451. private _sampleSphere;
  39452. /**
  39453. * Blur filter offsets
  39454. */
  39455. private _samplerOffsets;
  39456. /**
  39457. * Are we using bilateral blur ?
  39458. */
  39459. private _expensiveBlur;
  39460. expensiveBlur: boolean;
  39461. /**
  39462. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39463. */
  39464. radius: number;
  39465. /**
  39466. * The base color of the SSAO post-process
  39467. * The final result is "base + ssao" between [0, 1]
  39468. */
  39469. base: number;
  39470. /**
  39471. * Support test.
  39472. */
  39473. static readonly IsSupported: boolean;
  39474. private _scene;
  39475. private _depthTexture;
  39476. private _normalTexture;
  39477. private _randomTexture;
  39478. private _originalColorPostProcess;
  39479. private _ssaoPostProcess;
  39480. private _blurHPostProcess;
  39481. private _blurVPostProcess;
  39482. private _ssaoCombinePostProcess;
  39483. private _firstUpdate;
  39484. /**
  39485. * @constructor
  39486. * @param {string} name - The rendering pipeline name
  39487. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39488. * @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 }
  39489. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39490. */
  39491. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39492. /**
  39493. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39494. */
  39495. dispose(disableGeometryBufferRenderer?: boolean): void;
  39496. private _createBlurPostProcess;
  39497. /** @hidden */
  39498. private _bits;
  39499. private _radicalInverse_VdC;
  39500. private _hammersley;
  39501. private _hemisphereSample_uniform;
  39502. private _generateHemisphere;
  39503. private _createSSAOPostProcess;
  39504. private _createSSAOCombinePostProcess;
  39505. private _createRandomTexture;
  39506. /**
  39507. * Serialize the rendering pipeline (Used when exporting)
  39508. * @returns the serialized object
  39509. */
  39510. serialize(): any;
  39511. /**
  39512. * Parse the serialized pipeline
  39513. * @param source Source pipeline.
  39514. * @param scene The scene to load the pipeline to.
  39515. * @param rootUrl The URL of the serialized pipeline.
  39516. * @returns An instantiated pipeline from the serialized object.
  39517. */
  39518. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39519. }
  39520. }
  39521. declare module BABYLON {
  39522. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39523. /**
  39524. * The PassPostProcess id in the pipeline that contains the original scene color
  39525. */
  39526. SSAOOriginalSceneColorEffect: string;
  39527. /**
  39528. * The SSAO PostProcess id in the pipeline
  39529. */
  39530. SSAORenderEffect: string;
  39531. /**
  39532. * The horizontal blur PostProcess id in the pipeline
  39533. */
  39534. SSAOBlurHRenderEffect: string;
  39535. /**
  39536. * The vertical blur PostProcess id in the pipeline
  39537. */
  39538. SSAOBlurVRenderEffect: string;
  39539. /**
  39540. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39541. */
  39542. SSAOCombineRenderEffect: string;
  39543. /**
  39544. * The output strength of the SSAO post-process. Default value is 1.0.
  39545. */
  39546. totalStrength: number;
  39547. /**
  39548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39549. */
  39550. radius: number;
  39551. /**
  39552. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39553. * Must not be equal to fallOff and superior to fallOff.
  39554. * Default value is 0.975
  39555. */
  39556. area: number;
  39557. /**
  39558. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39559. * Must not be equal to area and inferior to area.
  39560. * Default value is 0.0
  39561. */
  39562. fallOff: number;
  39563. /**
  39564. * The base color of the SSAO post-process
  39565. * The final result is "base + ssao" between [0, 1]
  39566. */
  39567. base: number;
  39568. private _scene;
  39569. private _depthTexture;
  39570. private _randomTexture;
  39571. private _originalColorPostProcess;
  39572. private _ssaoPostProcess;
  39573. private _blurHPostProcess;
  39574. private _blurVPostProcess;
  39575. private _ssaoCombinePostProcess;
  39576. private _firstUpdate;
  39577. /**
  39578. * @constructor
  39579. * @param {string} name - The rendering pipeline name
  39580. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39581. * @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 }
  39582. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39583. */
  39584. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39585. /**
  39586. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39587. */
  39588. dispose(disableDepthRender?: boolean): void;
  39589. private _createBlurPostProcess;
  39590. /** @hidden */
  39591. private _createSSAOPostProcess;
  39592. private _createSSAOCombinePostProcess;
  39593. private _createRandomTexture;
  39594. }
  39595. }
  39596. declare module BABYLON {
  39597. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39598. /**
  39599. * Public members
  39600. */
  39601. /**
  39602. * Post-process which contains the original scene color before the pipeline applies all the effects
  39603. */
  39604. originalPostProcess: Nullable<PostProcess>;
  39605. /**
  39606. * Post-process used to down scale an image x4
  39607. */
  39608. downSampleX4PostProcess: Nullable<PostProcess>;
  39609. /**
  39610. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  39611. */
  39612. brightPassPostProcess: Nullable<PostProcess>;
  39613. /**
  39614. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  39615. */
  39616. blurHPostProcesses: PostProcess[];
  39617. /**
  39618. * Post-process array storing all the vertical blur post-processes used by the pipeline
  39619. */
  39620. blurVPostProcesses: PostProcess[];
  39621. /**
  39622. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  39623. */
  39624. textureAdderPostProcess: Nullable<PostProcess>;
  39625. /**
  39626. * Post-process used to create volumetric lighting effect
  39627. */
  39628. volumetricLightPostProcess: Nullable<PostProcess>;
  39629. /**
  39630. * Post-process used to smooth the previous volumetric light post-process on the X axis
  39631. */
  39632. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  39633. /**
  39634. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  39635. */
  39636. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  39637. /**
  39638. * Post-process used to merge the volumetric light effect and the real scene color
  39639. */
  39640. volumetricLightMergePostProces: Nullable<PostProcess>;
  39641. /**
  39642. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  39643. */
  39644. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  39645. /**
  39646. * Base post-process used to calculate the average luminance of the final image for HDR
  39647. */
  39648. luminancePostProcess: Nullable<PostProcess>;
  39649. /**
  39650. * Post-processes used to create down sample post-processes in order to get
  39651. * the average luminance of the final image for HDR
  39652. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  39653. */
  39654. luminanceDownSamplePostProcesses: PostProcess[];
  39655. /**
  39656. * Post-process used to create a HDR effect (light adaptation)
  39657. */
  39658. hdrPostProcess: Nullable<PostProcess>;
  39659. /**
  39660. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  39661. */
  39662. textureAdderFinalPostProcess: Nullable<PostProcess>;
  39663. /**
  39664. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  39665. */
  39666. lensFlareFinalPostProcess: Nullable<PostProcess>;
  39667. /**
  39668. * Post-process used to merge the final HDR post-process and the real scene color
  39669. */
  39670. hdrFinalPostProcess: Nullable<PostProcess>;
  39671. /**
  39672. * Post-process used to create a lens flare effect
  39673. */
  39674. lensFlarePostProcess: Nullable<PostProcess>;
  39675. /**
  39676. * Post-process that merges the result of the lens flare post-process and the real scene color
  39677. */
  39678. lensFlareComposePostProcess: Nullable<PostProcess>;
  39679. /**
  39680. * Post-process used to create a motion blur effect
  39681. */
  39682. motionBlurPostProcess: Nullable<PostProcess>;
  39683. /**
  39684. * Post-process used to create a depth of field effect
  39685. */
  39686. depthOfFieldPostProcess: Nullable<PostProcess>;
  39687. /**
  39688. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39689. */
  39690. fxaaPostProcess: Nullable<FxaaPostProcess>;
  39691. /**
  39692. * Represents the brightness threshold in order to configure the illuminated surfaces
  39693. */
  39694. brightThreshold: number;
  39695. /**
  39696. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  39697. */
  39698. blurWidth: number;
  39699. /**
  39700. * Sets if the blur for highlighted surfaces must be only horizontal
  39701. */
  39702. horizontalBlur: boolean;
  39703. /**
  39704. * Sets the overall exposure used by the pipeline
  39705. */
  39706. exposure: number;
  39707. /**
  39708. * Texture used typically to simulate "dirty" on camera lens
  39709. */
  39710. lensTexture: Nullable<Texture>;
  39711. /**
  39712. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  39713. */
  39714. volumetricLightCoefficient: number;
  39715. /**
  39716. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  39717. */
  39718. volumetricLightPower: number;
  39719. /**
  39720. * Used the set the blur intensity to smooth the volumetric lights
  39721. */
  39722. volumetricLightBlurScale: number;
  39723. /**
  39724. * Light (spot or directional) used to generate the volumetric lights rays
  39725. * The source light must have a shadow generate so the pipeline can get its
  39726. * depth map
  39727. */
  39728. sourceLight: Nullable<SpotLight | DirectionalLight>;
  39729. /**
  39730. * For eye adaptation, represents the minimum luminance the eye can see
  39731. */
  39732. hdrMinimumLuminance: number;
  39733. /**
  39734. * For eye adaptation, represents the decrease luminance speed
  39735. */
  39736. hdrDecreaseRate: number;
  39737. /**
  39738. * For eye adaptation, represents the increase luminance speed
  39739. */
  39740. hdrIncreaseRate: number;
  39741. /**
  39742. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  39743. */
  39744. lensColorTexture: Nullable<Texture>;
  39745. /**
  39746. * The overall strengh for the lens flare effect
  39747. */
  39748. lensFlareStrength: number;
  39749. /**
  39750. * Dispersion coefficient for lens flare ghosts
  39751. */
  39752. lensFlareGhostDispersal: number;
  39753. /**
  39754. * Main lens flare halo width
  39755. */
  39756. lensFlareHaloWidth: number;
  39757. /**
  39758. * Based on the lens distortion effect, defines how much the lens flare result
  39759. * is distorted
  39760. */
  39761. lensFlareDistortionStrength: number;
  39762. /**
  39763. * Lens star texture must be used to simulate rays on the flares and is available
  39764. * in the documentation
  39765. */
  39766. lensStarTexture: Nullable<Texture>;
  39767. /**
  39768. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  39769. * flare effect by taking account of the dirt texture
  39770. */
  39771. lensFlareDirtTexture: Nullable<Texture>;
  39772. /**
  39773. * Represents the focal length for the depth of field effect
  39774. */
  39775. depthOfFieldDistance: number;
  39776. /**
  39777. * Represents the blur intensity for the blurred part of the depth of field effect
  39778. */
  39779. depthOfFieldBlurWidth: number;
  39780. /**
  39781. * For motion blur, defines how much the image is blurred by the movement
  39782. */
  39783. motionStrength: number;
  39784. /**
  39785. * List of animations for the pipeline (IAnimatable implementation)
  39786. */
  39787. animations: Animation[];
  39788. /**
  39789. * Private members
  39790. */
  39791. private _scene;
  39792. private _currentDepthOfFieldSource;
  39793. private _basePostProcess;
  39794. private _hdrCurrentLuminance;
  39795. private _floatTextureType;
  39796. private _ratio;
  39797. private _bloomEnabled;
  39798. private _depthOfFieldEnabled;
  39799. private _vlsEnabled;
  39800. private _lensFlareEnabled;
  39801. private _hdrEnabled;
  39802. private _motionBlurEnabled;
  39803. private _fxaaEnabled;
  39804. private _motionBlurSamples;
  39805. private _volumetricLightStepsCount;
  39806. private _samples;
  39807. /**
  39808. * Specifies if the bloom pipeline is enabled
  39809. */
  39810. BloomEnabled: boolean;
  39811. /**
  39812. * Specifies if the depth of field pipeline is enabed
  39813. */
  39814. DepthOfFieldEnabled: boolean;
  39815. /**
  39816. * Specifies if the lens flare pipeline is enabed
  39817. */
  39818. LensFlareEnabled: boolean;
  39819. /**
  39820. * Specifies if the HDR pipeline is enabled
  39821. */
  39822. HDREnabled: boolean;
  39823. /**
  39824. * Specifies if the volumetric lights scattering effect is enabled
  39825. */
  39826. VLSEnabled: boolean;
  39827. /**
  39828. * Specifies if the motion blur effect is enabled
  39829. */
  39830. MotionBlurEnabled: boolean;
  39831. /**
  39832. * Specifies if anti-aliasing is enabled
  39833. */
  39834. fxaaEnabled: boolean;
  39835. /**
  39836. * Specifies the number of steps used to calculate the volumetric lights
  39837. * Typically in interval [50, 200]
  39838. */
  39839. volumetricLightStepsCount: number;
  39840. /**
  39841. * Specifies the number of samples used for the motion blur effect
  39842. * Typically in interval [16, 64]
  39843. */
  39844. motionBlurSamples: number;
  39845. /**
  39846. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  39847. */
  39848. samples: number;
  39849. /**
  39850. * @constructor
  39851. * @param {string} name - The rendering pipeline name
  39852. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39853. * @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)
  39854. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  39855. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39856. */
  39857. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  39858. private _buildPipeline;
  39859. private _createDownSampleX4PostProcess;
  39860. private _createBrightPassPostProcess;
  39861. private _createBlurPostProcesses;
  39862. private _createTextureAdderPostProcess;
  39863. private _createVolumetricLightPostProcess;
  39864. private _createLuminancePostProcesses;
  39865. private _createHdrPostProcess;
  39866. private _createLensFlarePostProcess;
  39867. private _createDepthOfFieldPostProcess;
  39868. private _createMotionBlurPostProcess;
  39869. private _getDepthTexture;
  39870. private _disposePostProcesses;
  39871. /**
  39872. * Dispose of the pipeline and stop all post processes
  39873. */
  39874. dispose(): void;
  39875. /**
  39876. * Serialize the rendering pipeline (Used when exporting)
  39877. * @returns the serialized object
  39878. */
  39879. serialize(): any;
  39880. /**
  39881. * Parse the serialized pipeline
  39882. * @param source Source pipeline.
  39883. * @param scene The scene to load the pipeline to.
  39884. * @param rootUrl The URL of the serialized pipeline.
  39885. * @returns An instantiated pipeline from the serialized object.
  39886. */
  39887. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  39888. static LuminanceSteps: number;
  39889. }
  39890. }
  39891. /*BabylonJS GUI*/
  39892. // Dependencies for this module:
  39893. // ../../../../Tools/Gulp/babylonjs
  39894. declare module BABYLON.GUI {
  39895. }
  39896. declare module BABYLON.GUI {
  39897. }
  39898. declare module BABYLON.GUI {
  39899. }
  39900. declare module BABYLON.GUI {
  39901. }
  39902. declare module BABYLON.GUI {
  39903. /**
  39904. * Interface used to define a control that can receive focus
  39905. */
  39906. export interface IFocusableControl {
  39907. /**
  39908. * Function called when the control receives the focus
  39909. */
  39910. onFocus(): void;
  39911. /**
  39912. * Function called when the control loses the focus
  39913. */
  39914. onBlur(): void;
  39915. /**
  39916. * Function called to let the control handle keyboard events
  39917. * @param evt defines the current keyboard event
  39918. */
  39919. processKeyboard(evt: KeyboardEvent): void;
  39920. }
  39921. /**
  39922. * Class used to create texture to support 2D GUI elements
  39923. * @see http://doc.babylonjs.com/how_to/gui
  39924. */
  39925. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  39926. /** @hidden */
  39927. /** @hidden */
  39928. /** @hidden */ ;
  39929. /** @hidden */ ;
  39930. /** @hidden */ ;
  39931. /** @hidden */
  39932. /** @hidden */
  39933. /** @hidden */
  39934. /**
  39935. * Gets or sets a boolean defining if alpha is stored as premultiplied
  39936. */
  39937. premulAlpha: boolean;
  39938. /**
  39939. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  39940. * Useful when you want more antialiasing
  39941. */
  39942. renderScale: number;
  39943. /** Gets or sets the background color */
  39944. background: string;
  39945. /**
  39946. * Gets or sets the ideal width used to design controls.
  39947. * The GUI will then rescale everything accordingly
  39948. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  39949. */
  39950. idealWidth: number;
  39951. /**
  39952. * Gets or sets the ideal height used to design controls.
  39953. * The GUI will then rescale everything accordingly
  39954. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  39955. */
  39956. idealHeight: number;
  39957. /**
  39958. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  39959. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  39960. */
  39961. useSmallestIdeal: boolean;
  39962. /**
  39963. * Gets or sets a boolean indicating if adaptive scaling must be used
  39964. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  39965. */
  39966. renderAtIdealSize: boolean;
  39967. /**
  39968. * Gets the underlying layer used to render the texture when in fullscreen mode
  39969. */
  39970. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  39971. /**
  39972. * Gets the root container control
  39973. */
  39974. readonly rootContainer: Container;
  39975. /**
  39976. * Gets or sets the current focused control
  39977. */
  39978. focusedControl: BABYLON.Nullable<IFocusableControl>;
  39979. /**
  39980. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  39981. */
  39982. isForeground: boolean;
  39983. /**
  39984. * Creates a new AdvancedDynamicTexture
  39985. * @param name defines the name of the texture
  39986. * @param width defines the width of the texture
  39987. * @param height defines the height of the texture
  39988. * @param scene defines the hosting scene
  39989. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  39990. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39991. */
  39992. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  39993. /**
  39994. * Function used to execute a function on all controls
  39995. * @param func defines the function to execute
  39996. * @param container defines the container where controls belong. If null the root container will be used
  39997. */
  39998. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  39999. /**
  40000. * Marks the texture as dirty forcing a complete update
  40001. */
  40002. markAsDirty(): void;
  40003. /**
  40004. * Helper function used to create a new style
  40005. * @returns a new style
  40006. * @see http://doc.babylonjs.com/how_to/gui#styles
  40007. */
  40008. createStyle(): Style;
  40009. /**
  40010. * Adds a new control to the root container
  40011. * @param control defines the control to add
  40012. * @returns the current texture
  40013. */
  40014. addControl(control: Control): AdvancedDynamicTexture;
  40015. /**
  40016. * Removes a control from the root container
  40017. * @param control defines the control to remove
  40018. * @returns the current texture
  40019. */
  40020. removeControl(control: Control): AdvancedDynamicTexture;
  40021. /**
  40022. * Release all resources
  40023. */
  40024. dispose(): void;
  40025. /** @hidden */
  40026. /**
  40027. * Get screen coordinates for a vector3
  40028. * @param position defines the position to project
  40029. * @param worldMatrix defines the world matrix to use
  40030. * @returns the projected position
  40031. */
  40032. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  40033. /** @hidden */
  40034. /** @hidden */ , control: Control): void;
  40035. /** @hidden */
  40036. /** Attach to all scene events required to support pointer events */
  40037. attach(): void;
  40038. /**
  40039. * Connect the texture to a hosting mesh to enable interactions
  40040. * @param mesh defines the mesh to attach to
  40041. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  40042. */
  40043. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  40044. /**
  40045. * Move the focus to a specific control
  40046. * @param control defines the control which will receive the focus
  40047. */
  40048. moveFocusToControl(control: IFocusableControl): void;
  40049. /**
  40050. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  40051. * @param mesh defines the mesh which will receive the texture
  40052. * @param width defines the texture width (1024 by default)
  40053. * @param height defines the texture height (1024 by default)
  40054. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  40055. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  40056. * @returns a new AdvancedDynamicTexture
  40057. */
  40058. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  40059. /**
  40060. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  40061. * In this mode the texture will rely on a layer for its rendering.
  40062. * This allows it to be treated like any other layer.
  40063. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  40064. * LayerMask is set through advancedTexture.layer.layerMask
  40065. * @param name defines name for the texture
  40066. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  40067. * @param scene defines the hsoting scene
  40068. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  40069. * @returns a new AdvancedDynamicTexture
  40070. */
  40071. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  40072. }
  40073. }
  40074. declare module BABYLON.GUI {
  40075. /**
  40076. * Class used to transport BABYLON.Vector2 information for pointer events
  40077. */
  40078. export class Vector2WithInfo extends BABYLON.Vector2 {
  40079. /** defines the current mouse button index */
  40080. buttonIndex: number;
  40081. /**
  40082. * Creates a new Vector2WithInfo
  40083. * @param source defines the vector2 data to transport
  40084. * @param buttonIndex defines the current mouse button index
  40085. */
  40086. constructor(source: BABYLON.Vector2,
  40087. /** defines the current mouse button index */
  40088. buttonIndex?: number);
  40089. }
  40090. /** Class used to provide 2D matrix features */
  40091. export class Matrix2D {
  40092. /** Gets the internal array of 6 floats used to store matrix data */
  40093. m: Float32Array;
  40094. /**
  40095. * Creates a new matrix
  40096. * @param m00 defines value for (0, 0)
  40097. * @param m01 defines value for (0, 1)
  40098. * @param m10 defines value for (1, 0)
  40099. * @param m11 defines value for (1, 1)
  40100. * @param m20 defines value for (2, 0)
  40101. * @param m21 defines value for (2, 1)
  40102. */
  40103. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  40104. /**
  40105. * Fills the matrix from direct values
  40106. * @param m00 defines value for (0, 0)
  40107. * @param m01 defines value for (0, 1)
  40108. * @param m10 defines value for (1, 0)
  40109. * @param m11 defines value for (1, 1)
  40110. * @param m20 defines value for (2, 0)
  40111. * @param m21 defines value for (2, 1)
  40112. * @returns the current modified matrix
  40113. */
  40114. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  40115. /**
  40116. * Gets matrix determinant
  40117. * @returns the determinant
  40118. */
  40119. determinant(): number;
  40120. /**
  40121. * Inverses the matrix and stores it in a target matrix
  40122. * @param result defines the target matrix
  40123. * @returns the current matrix
  40124. */
  40125. invertToRef(result: Matrix2D): Matrix2D;
  40126. /**
  40127. * Multiplies the current matrix with another one
  40128. * @param other defines the second operand
  40129. * @param result defines the target matrix
  40130. * @returns the current matrix
  40131. */
  40132. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  40133. /**
  40134. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  40135. * @param x defines the x coordinate to transform
  40136. * @param y defines the x coordinate to transform
  40137. * @param result defines the target vector2
  40138. * @returns the current matrix
  40139. */
  40140. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  40141. /**
  40142. * Creates an identity matrix
  40143. * @returns a new matrix
  40144. */
  40145. static Identity(): Matrix2D;
  40146. /**
  40147. * Creates a translation matrix and stores it in a target matrix
  40148. * @param x defines the x coordinate of the translation
  40149. * @param y defines the y coordinate of the translation
  40150. * @param result defines the target matrix
  40151. */
  40152. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  40153. /**
  40154. * Creates a scaling matrix and stores it in a target matrix
  40155. * @param x defines the x coordinate of the scaling
  40156. * @param y defines the y coordinate of the scaling
  40157. * @param result defines the target matrix
  40158. */
  40159. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  40160. /**
  40161. * Creates a rotation matrix and stores it in a target matrix
  40162. * @param angle defines the rotation angle
  40163. * @param result defines the target matrix
  40164. */
  40165. static RotationToRef(angle: number, result: Matrix2D): void;
  40166. /**
  40167. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  40168. * @param tx defines the x coordinate of the translation
  40169. * @param ty defines the y coordinate of the translation
  40170. * @param angle defines the rotation angle
  40171. * @param scaleX defines the x coordinate of the scaling
  40172. * @param scaleY defines the y coordinate of the scaling
  40173. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  40174. * @param result defines the target matrix
  40175. */
  40176. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  40177. }
  40178. }
  40179. declare module BABYLON.GUI {
  40180. /**
  40181. * Class used to store 2D control sizes
  40182. */
  40183. export class Measure {
  40184. /** defines left coordinate */
  40185. left: number;
  40186. /** defines top coordinate */
  40187. top: number;
  40188. /** defines width dimension */
  40189. width: number;
  40190. /** defines height dimension */
  40191. height: number;
  40192. /**
  40193. * Creates a new measure
  40194. * @param left defines left coordinate
  40195. * @param top defines top coordinate
  40196. * @param width defines width dimension
  40197. * @param height defines height dimension
  40198. */
  40199. constructor(
  40200. /** defines left coordinate */
  40201. left: number,
  40202. /** defines top coordinate */
  40203. top: number,
  40204. /** defines width dimension */
  40205. width: number,
  40206. /** defines height dimension */
  40207. height: number);
  40208. /**
  40209. * Copy from another measure
  40210. * @param other defines the other measure to copy from
  40211. */
  40212. copyFrom(other: Measure): void;
  40213. /**
  40214. * Check equality between this measure and another one
  40215. * @param other defines the other measures
  40216. * @returns true if both measures are equals
  40217. */
  40218. isEqualsTo(other: Measure): boolean;
  40219. /**
  40220. * Creates an empty measure
  40221. * @returns a new measure
  40222. */
  40223. static Empty(): Measure;
  40224. }
  40225. }
  40226. declare module BABYLON.GUI {
  40227. /**
  40228. * Class used to store a point for a MultiLine object.
  40229. * The point can be pure 2D coordinates, a mesh or a control
  40230. */
  40231. export class MultiLinePoint {
  40232. /** @hidden */
  40233. /**
  40234. * Creates a new MultiLinePoint
  40235. * @param multiLine defines the source MultiLine object
  40236. */
  40237. constructor(multiLine: MultiLine);
  40238. /** Gets or sets x coordinate */
  40239. x: string | number;
  40240. /** Gets or sets y coordinate */
  40241. y: string | number;
  40242. /** Gets or sets the control associated with this point */
  40243. control: BABYLON.Nullable<Control>;
  40244. /** Gets or sets the mesh associated with this point */
  40245. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  40246. /**
  40247. * Gets a translation vector
  40248. * @returns the translation vector
  40249. */
  40250. translate(): BABYLON.Vector2;
  40251. /** Release associated resources */
  40252. dispose(): void;
  40253. }
  40254. }
  40255. declare module BABYLON.GUI {
  40256. /**
  40257. * Define a style used by control to automatically setup properties based on a template.
  40258. * Only support font related properties so far
  40259. */
  40260. export class Style implements BABYLON.IDisposable {
  40261. /** @hidden */
  40262. /** @hidden */
  40263. /**
  40264. * BABYLON.Observable raised when the style values are changed
  40265. */
  40266. onChangedObservable: BABYLON.Observable<Style>;
  40267. /**
  40268. * Creates a new style object
  40269. * @param host defines the AdvancedDynamicTexture which hosts this style
  40270. */
  40271. constructor(host: AdvancedDynamicTexture);
  40272. /**
  40273. * Gets or sets the font size
  40274. */
  40275. fontSize: string | number;
  40276. /**
  40277. * Gets or sets the font family
  40278. */
  40279. fontFamily: string;
  40280. /**
  40281. * Gets or sets the font style
  40282. */
  40283. fontStyle: string;
  40284. /** Gets or sets font weight */
  40285. fontWeight: string;
  40286. /** Dispose all associated resources */
  40287. dispose(): void;
  40288. }
  40289. }
  40290. declare module BABYLON.GUI {
  40291. /**
  40292. * Class used to specific a value and its associated unit
  40293. */
  40294. export class ValueAndUnit {
  40295. /** defines the unit to store */
  40296. unit: number;
  40297. /** defines a boolean indicating if the value can be negative */
  40298. negativeValueAllowed: boolean;
  40299. /**
  40300. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  40301. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  40302. */
  40303. ignoreAdaptiveScaling: boolean;
  40304. /**
  40305. * Creates a new ValueAndUnit
  40306. * @param value defines the value to store
  40307. * @param unit defines the unit to store
  40308. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  40309. */
  40310. constructor(value: number,
  40311. /** defines the unit to store */
  40312. unit?: number,
  40313. /** defines a boolean indicating if the value can be negative */
  40314. negativeValueAllowed?: boolean);
  40315. /** Gets a boolean indicating if the value is a percentage */
  40316. readonly isPercentage: boolean;
  40317. /** Gets a boolean indicating if the value is store as pixel */
  40318. readonly isPixel: boolean;
  40319. /** Gets direct internal value */
  40320. readonly internalValue: number;
  40321. /**
  40322. * Gets value as pixel
  40323. * @param host defines the root host
  40324. * @param refValue defines the reference value for percentages
  40325. * @returns the value as pixel
  40326. */
  40327. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  40328. /**
  40329. * Gets the value accordingly to its unit
  40330. * @param host defines the root host
  40331. * @returns the value
  40332. */
  40333. getValue(host: AdvancedDynamicTexture): number;
  40334. /**
  40335. * Gets a string representation of the value
  40336. * @param host defines the root host
  40337. * @returns a string
  40338. */
  40339. toString(host: AdvancedDynamicTexture): string;
  40340. /**
  40341. * Store a value parsed from a string
  40342. * @param source defines the source string
  40343. * @returns true if the value was successfully parsed
  40344. */
  40345. fromString(source: string | number): boolean;
  40346. /** UNITMODE_PERCENTAGE */
  40347. static readonly UNITMODE_PERCENTAGE: number;
  40348. /** UNITMODE_PIXEL */
  40349. static readonly UNITMODE_PIXEL: number;
  40350. }
  40351. }
  40352. declare module BABYLON.GUI {
  40353. }
  40354. declare module BABYLON.GUI {
  40355. }
  40356. declare module BABYLON.GUI {
  40357. /**
  40358. * Class used to manage 3D user interface
  40359. * @see http://doc.babylonjs.com/how_to/gui3d
  40360. */
  40361. export class GUI3DManager implements BABYLON.IDisposable {
  40362. /** @hidden */
  40363. /** @hidden */ ;
  40364. /** @hidden */ ;
  40365. /**
  40366. * BABYLON.Observable raised when the point picked by the pointer events changed
  40367. */
  40368. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  40369. /** @hidden */ ;
  40370. /** Gets the hosting scene */
  40371. readonly scene: BABYLON.Scene;
  40372. /** Gets associated utility layer */
  40373. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  40374. /**
  40375. * Creates a new GUI3DManager
  40376. * @param scene
  40377. */
  40378. constructor(scene?: BABYLON.Scene);
  40379. /**
  40380. * Gets the root container
  40381. */
  40382. readonly rootContainer: Container3D;
  40383. /**
  40384. * Gets a boolean indicating if the given control is in the root child list
  40385. * @param control defines the control to check
  40386. * @returns true if the control is in the root child list
  40387. */
  40388. containsControl(control: Control3D): boolean;
  40389. /**
  40390. * Adds a control to the root child list
  40391. * @param control defines the control to add
  40392. * @returns the current manager
  40393. */
  40394. addControl(control: Control3D): GUI3DManager;
  40395. /**
  40396. * Removes a control from the root child list
  40397. * @param control defines the control to remove
  40398. * @returns the current container
  40399. */
  40400. removeControl(control: Control3D): GUI3DManager;
  40401. /**
  40402. * Releases all associated resources
  40403. */
  40404. dispose(): void;
  40405. }
  40406. }
  40407. declare module BABYLON.GUI {
  40408. /**
  40409. * Class used to transport BABYLON.Vector3 information for pointer events
  40410. */
  40411. export class Vector3WithInfo extends BABYLON.Vector3 {
  40412. /** defines the current mouse button index */
  40413. buttonIndex: number;
  40414. /**
  40415. * Creates a new Vector3WithInfo
  40416. * @param source defines the vector3 data to transport
  40417. * @param buttonIndex defines the current mouse button index
  40418. */
  40419. constructor(source: BABYLON.Vector3,
  40420. /** defines the current mouse button index */
  40421. buttonIndex?: number);
  40422. }
  40423. }
  40424. declare module BABYLON.GUI {
  40425. /**
  40426. * Class used to create 2D buttons
  40427. */
  40428. export class Button extends Rectangle {
  40429. name?: string | undefined;
  40430. /**
  40431. * Function called to generate a pointer enter animation
  40432. */
  40433. pointerEnterAnimation: () => void;
  40434. /**
  40435. * Function called to generate a pointer out animation
  40436. */
  40437. pointerOutAnimation: () => void;
  40438. /**
  40439. * Function called to generate a pointer down animation
  40440. */
  40441. pointerDownAnimation: () => void;
  40442. /**
  40443. * Function called to generate a pointer up animation
  40444. */
  40445. pointerUpAnimation: () => void;
  40446. /**
  40447. * Creates a new Button
  40448. * @param name defines the name of the button
  40449. */
  40450. constructor(name?: string | undefined);
  40451. protected _getTypeName(): string;
  40452. /** @hidden */
  40453. /** @hidden */
  40454. /** @hidden */
  40455. /** @hidden */
  40456. /** @hidden */
  40457. /**
  40458. * Creates a new button made with an image and a text
  40459. * @param name defines the name of the button
  40460. * @param text defines the text of the button
  40461. * @param imageUrl defines the url of the image
  40462. * @returns a new Button
  40463. */
  40464. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  40465. /**
  40466. * Creates a new button made with an image
  40467. * @param name defines the name of the button
  40468. * @param imageUrl defines the url of the image
  40469. * @returns a new Button
  40470. */
  40471. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  40472. /**
  40473. * Creates a new button made with a text
  40474. * @param name defines the name of the button
  40475. * @param text defines the text of the button
  40476. * @returns a new Button
  40477. */
  40478. static CreateSimpleButton(name: string, text: string): Button;
  40479. /**
  40480. * Creates a new button made with an image and a centered text
  40481. * @param name defines the name of the button
  40482. * @param text defines the text of the button
  40483. * @param imageUrl defines the url of the image
  40484. * @returns a new Button
  40485. */
  40486. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  40487. }
  40488. }
  40489. declare module BABYLON.GUI {
  40490. /**
  40491. * Class used to represent a 2D checkbox
  40492. */
  40493. export class Checkbox extends Control {
  40494. name?: string | undefined;
  40495. /** Gets or sets border thickness */
  40496. thickness: number;
  40497. /**
  40498. * BABYLON.Observable raised when isChecked property changes
  40499. */
  40500. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  40501. /** Gets or sets a value indicating the ratio between overall size and check size */
  40502. checkSizeRatio: number;
  40503. /** Gets or sets background color */
  40504. background: string;
  40505. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  40506. isChecked: boolean;
  40507. /**
  40508. * Creates a new CheckBox
  40509. * @param name defines the control name
  40510. */
  40511. constructor(name?: string | undefined);
  40512. protected _getTypeName(): string;
  40513. /** @hidden */
  40514. /** @hidden */
  40515. /**
  40516. * Utility function to easily create a checkbox with a header
  40517. * @param title defines the label to use for the header
  40518. * @param onValueChanged defines the callback to call when value changes
  40519. * @returns a StackPanel containing the checkbox and a textBlock
  40520. */
  40521. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  40522. }
  40523. }
  40524. declare module BABYLON.GUI {
  40525. /** Class used to create color pickers */
  40526. export class ColorPicker extends Control {
  40527. name?: string | undefined;
  40528. /**
  40529. * BABYLON.Observable raised when the value changes
  40530. */
  40531. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  40532. /** Gets or sets the color of the color picker */
  40533. value: BABYLON.Color3;
  40534. /** Gets or sets control width */
  40535. width: string | number;
  40536. /** Gets or sets control height */
  40537. height: string | number;
  40538. /** Gets or sets control size */
  40539. size: string | number;
  40540. /**
  40541. * Creates a new ColorPicker
  40542. * @param name defines the control name
  40543. */
  40544. constructor(name?: string | undefined);
  40545. protected _getTypeName(): string;
  40546. /** @hidden */
  40547. }
  40548. }
  40549. declare module BABYLON.GUI {
  40550. /**
  40551. * Root class for 2D containers
  40552. * @see http://doc.babylonjs.com/how_to/gui#containers
  40553. */
  40554. export class Container extends Control {
  40555. name?: string | undefined;
  40556. /** @hidden */
  40557. protected _children: Control[];
  40558. /** @hidden */
  40559. protected _measureForChildren: Measure;
  40560. /** @hidden */
  40561. protected _background: string;
  40562. /** @hidden */
  40563. protected _adaptWidthToChildren: boolean;
  40564. /** @hidden */
  40565. protected _adaptHeightToChildren: boolean;
  40566. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  40567. adaptHeightToChildren: boolean;
  40568. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  40569. adaptWidthToChildren: boolean;
  40570. /** Gets or sets background color */
  40571. background: string;
  40572. /** Gets the list of children */
  40573. readonly children: Control[];
  40574. /**
  40575. * Creates a new Container
  40576. * @param name defines the name of the container
  40577. */
  40578. constructor(name?: string | undefined);
  40579. protected _getTypeName(): string;
  40580. /**
  40581. * Gets a child using its name
  40582. * @param name defines the child name to look for
  40583. * @returns the child control if found
  40584. */
  40585. getChildByName(name: string): BABYLON.Nullable<Control>;
  40586. /**
  40587. * Gets a child using its type and its name
  40588. * @param name defines the child name to look for
  40589. * @param type defines the child type to look for
  40590. * @returns the child control if found
  40591. */
  40592. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  40593. /**
  40594. * Search for a specific control in children
  40595. * @param control defines the control to look for
  40596. * @returns true if the control is in child list
  40597. */
  40598. containsControl(control: Control): boolean;
  40599. /**
  40600. * Adds a new control to the current container
  40601. * @param control defines the control to add
  40602. * @returns the current container
  40603. */
  40604. addControl(control: BABYLON.Nullable<Control>): Container;
  40605. /**
  40606. * Removes all controls from the current container
  40607. * @returns the current container
  40608. */
  40609. clearControls(): Container;
  40610. /**
  40611. * Removes a control from the current container
  40612. * @param control defines the control to remove
  40613. * @returns the current container
  40614. */
  40615. removeControl(control: Control): Container;
  40616. /** @hidden */
  40617. /** @hidden */
  40618. /** @hidden */
  40619. /** @hidden */
  40620. protected _localDraw(context: CanvasRenderingContext2D): void;
  40621. /** @hidden */
  40622. /** @hidden */
  40623. /** @hidden */
  40624. /** @hidden */
  40625. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  40626. /** @hidden */
  40627. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  40628. /** Releases associated resources */
  40629. dispose(): void;
  40630. }
  40631. }
  40632. declare module BABYLON.GUI {
  40633. /**
  40634. * Root class used for all 2D controls
  40635. * @see http://doc.babylonjs.com/how_to/gui#controls
  40636. */
  40637. export class Control {
  40638. /** defines the name of the control */
  40639. name?: string | undefined;
  40640. /** @hidden */
  40641. /** @hidden */
  40642. /** Gets or sets the control parent */
  40643. parent: BABYLON.Nullable<Container>;
  40644. /** @hidden */
  40645. /** @hidden */
  40646. /** @hidden */
  40647. /** @hidden */
  40648. protected _fontOffset: {
  40649. ascent: number;
  40650. height: number;
  40651. descent: number;
  40652. };
  40653. /** @hidden */
  40654. protected _horizontalAlignment: number;
  40655. /** @hidden */
  40656. protected _verticalAlignment: number;
  40657. /** @hidden */
  40658. /** @hidden */
  40659. protected _cachedParentMeasure: Measure;
  40660. /** @hidden */
  40661. /** @hidden */
  40662. /** @hidden */
  40663. protected _invertTransformMatrix: Matrix2D;
  40664. /** @hidden */
  40665. protected _transformedPosition: BABYLON.Vector2;
  40666. /** @hidden */
  40667. protected _isEnabled: boolean;
  40668. protected _disabledColor: string;
  40669. /** @hidden */
  40670. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  40671. isHitTestVisible: boolean;
  40672. /** Gets or sets a boolean indicating if the control can block pointer events */
  40673. isPointerBlocker: boolean;
  40674. /** Gets or sets a boolean indicating if the control can be focusable */
  40675. isFocusInvisible: boolean;
  40676. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  40677. shadowOffsetX: number;
  40678. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  40679. shadowOffsetY: number;
  40680. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  40681. shadowBlur: number;
  40682. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  40683. shadowColor: string;
  40684. /** Gets or sets the cursor to use when the control is hovered */
  40685. hoverCursor: string;
  40686. /** @hidden */
  40687. protected _linkOffsetX: ValueAndUnit;
  40688. /** @hidden */
  40689. protected _linkOffsetY: ValueAndUnit;
  40690. /** Gets the control type name */
  40691. readonly typeName: string;
  40692. /**
  40693. * An event triggered when the pointer move over the control.
  40694. */
  40695. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  40696. /**
  40697. * An event triggered when the pointer move out of the control.
  40698. */
  40699. onPointerOutObservable: BABYLON.Observable<Control>;
  40700. /**
  40701. * An event triggered when the pointer taps the control
  40702. */
  40703. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  40704. /**
  40705. * An event triggered when pointer up
  40706. */
  40707. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  40708. /**
  40709. * An event triggered when a control is clicked on
  40710. */
  40711. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  40712. /**
  40713. * An event triggered when pointer enters the control
  40714. */
  40715. onPointerEnterObservable: BABYLON.Observable<Control>;
  40716. /**
  40717. * An event triggered when the control is marked as dirty
  40718. */
  40719. onDirtyObservable: BABYLON.Observable<Control>;
  40720. /**
  40721. * An event triggered after the control is drawn
  40722. */
  40723. onAfterDrawObservable: BABYLON.Observable<Control>;
  40724. /** Gets or set information about font offsets (used to render and align text) */
  40725. fontOffset: {
  40726. ascent: number;
  40727. height: number;
  40728. descent: number;
  40729. };
  40730. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  40731. alpha: number;
  40732. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  40733. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  40734. */
  40735. scaleX: number;
  40736. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  40737. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  40738. */
  40739. scaleY: number;
  40740. /** Gets or sets the rotation angle (0 by default)
  40741. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  40742. */
  40743. rotation: number;
  40744. /** Gets or sets the transformation center on Y axis (0 by default)
  40745. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  40746. */
  40747. transformCenterY: number;
  40748. /** Gets or sets the transformation center on X axis (0 by default)
  40749. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  40750. */
  40751. transformCenterX: number;
  40752. /**
  40753. * Gets or sets the horizontal alignment
  40754. * @see http://doc.babylonjs.com/how_to/gui#alignments
  40755. */
  40756. horizontalAlignment: number;
  40757. /**
  40758. * Gets or sets the vertical alignment
  40759. * @see http://doc.babylonjs.com/how_to/gui#alignments
  40760. */
  40761. verticalAlignment: number;
  40762. /**
  40763. * Gets or sets control width
  40764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40765. */
  40766. width: string | number;
  40767. /**
  40768. * Gets control width in pixel
  40769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40770. */
  40771. readonly widthInPixels: number;
  40772. /**
  40773. * Gets or sets control height
  40774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40775. */
  40776. height: string | number;
  40777. /**
  40778. * Gets control height in pixel
  40779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40780. */
  40781. readonly heightInPixels: number;
  40782. /** Gets or set font family */
  40783. fontFamily: string;
  40784. /** Gets or sets font style */
  40785. fontStyle: string;
  40786. /** Gets or sets font weight */
  40787. fontWeight: string;
  40788. /**
  40789. * Gets or sets style
  40790. * @see http://doc.babylonjs.com/how_to/gui#styles
  40791. */
  40792. style: BABYLON.Nullable<Style>;
  40793. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  40794. /** Gets font size in pixels */
  40795. readonly fontSizeInPixels: number;
  40796. /** Gets or sets font size */
  40797. fontSize: string | number;
  40798. /** Gets or sets foreground color */
  40799. color: string;
  40800. /** Gets or sets z index which is used to reorder controls on the z axis */
  40801. zIndex: number;
  40802. /** Gets or sets a boolean indicating if the control can be rendered */
  40803. notRenderable: boolean;
  40804. /** Gets or sets a boolean indicating if the control is visible */
  40805. isVisible: boolean;
  40806. /** Gets a boolean indicating that the control needs to update its rendering */
  40807. readonly isDirty: boolean;
  40808. /**
  40809. * Gets or sets a value indicating the padding to use on the left of the control
  40810. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40811. */
  40812. paddingLeft: string | number;
  40813. /**
  40814. * Gets a value indicating the padding in pixels to use on the left of the control
  40815. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40816. */
  40817. readonly paddingLeftInPixels: number;
  40818. /**
  40819. * Gets or sets a value indicating the padding to use on the right of the control
  40820. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40821. */
  40822. paddingRight: string | number;
  40823. /**
  40824. * Gets a value indicating the padding in pixels to use on the right of the control
  40825. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40826. */
  40827. readonly paddingRightInPixels: number;
  40828. /**
  40829. * Gets or sets a value indicating the padding to use on the top of the control
  40830. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40831. */
  40832. paddingTop: string | number;
  40833. /**
  40834. * Gets a value indicating the padding in pixels to use on the top of the control
  40835. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40836. */
  40837. readonly paddingTopInPixels: number;
  40838. /**
  40839. * Gets or sets a value indicating the padding to use on the bottom of the control
  40840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40841. */
  40842. paddingBottom: string | number;
  40843. /**
  40844. * Gets a value indicating the padding in pixels to use on the bottom of the control
  40845. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40846. */
  40847. readonly paddingBottomInPixels: number;
  40848. /**
  40849. * Gets or sets a value indicating the left coordinate of the control
  40850. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40851. */
  40852. left: string | number;
  40853. /**
  40854. * Gets a value indicating the left coordinate in pixels of the control
  40855. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40856. */
  40857. readonly leftInPixels: number;
  40858. /**
  40859. * Gets or sets a value indicating the top coordinate of the control
  40860. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40861. */
  40862. top: string | number;
  40863. /**
  40864. * Gets a value indicating the top coordinate in pixels of the control
  40865. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  40866. */
  40867. readonly topInPixels: number;
  40868. /**
  40869. * Gets or sets a value indicating the offset on X axis to the linked mesh
  40870. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  40871. */
  40872. linkOffsetX: string | number;
  40873. /**
  40874. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  40875. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  40876. */
  40877. readonly linkOffsetXInPixels: number;
  40878. /**
  40879. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  40880. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  40881. */
  40882. linkOffsetY: string | number;
  40883. /**
  40884. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  40885. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  40886. */
  40887. readonly linkOffsetYInPixels: number;
  40888. /** Gets the center coordinate on X axis */
  40889. readonly centerX: number;
  40890. /** Gets the center coordinate on Y axis */
  40891. readonly centerY: number;
  40892. /** Gets or sets if control is Enabled*/
  40893. isEnabled: boolean;
  40894. /** Gets or sets background color of control if it's disabled*/
  40895. disabledColor: string;
  40896. /**
  40897. * Creates a new control
  40898. * @param name defines the name of the control
  40899. */
  40900. constructor(
  40901. /** defines the name of the control */
  40902. name?: string | undefined);
  40903. /** @hidden */
  40904. protected _getTypeName(): string;
  40905. /** @hidden */
  40906. /**
  40907. * Gets coordinates in local control space
  40908. * @param globalCoordinates defines the coordinates to transform
  40909. * @returns the new coordinates in local space
  40910. */
  40911. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  40912. /**
  40913. * Gets coordinates in local control space
  40914. * @param globalCoordinates defines the coordinates to transform
  40915. * @param result defines the target vector2 where to store the result
  40916. * @returns the current control
  40917. */
  40918. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  40919. /**
  40920. * Gets coordinates in parent local control space
  40921. * @param globalCoordinates defines the coordinates to transform
  40922. * @returns the new coordinates in parent local space
  40923. */
  40924. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  40925. /**
  40926. * Move the current control to a vector3 position projected onto the screen.
  40927. * @param position defines the target position
  40928. * @param scene defines the hosting scene
  40929. */
  40930. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  40931. /**
  40932. * Link current control with a target mesh
  40933. * @param mesh defines the mesh to link with
  40934. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  40935. */
  40936. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  40937. /** @hidden */
  40938. /** @hidden */
  40939. /** @hidden */
  40940. /** @hidden */
  40941. /** @hidden */
  40942. /** @hidden */
  40943. protected _transform(context: CanvasRenderingContext2D): void;
  40944. /** @hidden */
  40945. protected _applyStates(context: CanvasRenderingContext2D): void;
  40946. /** @hidden */
  40947. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  40948. /** @hidden */
  40949. protected _clip(context: CanvasRenderingContext2D): void;
  40950. /** @hidden */
  40951. /** @hidden */
  40952. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  40953. /** @hidden */
  40954. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  40955. /** @hidden */
  40956. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  40957. /** @hidden */
  40958. /**
  40959. * Tests if a given coordinates belong to the current control
  40960. * @param x defines x coordinate to test
  40961. * @param y defines y coordinate to test
  40962. * @returns true if the coordinates are inside the control
  40963. */
  40964. contains(x: number, y: number): boolean;
  40965. /** @hidden */
  40966. /** @hidden */
  40967. /** @hidden */
  40968. /** @hidden */
  40969. /** @hidden */
  40970. /** @hidden */
  40971. /** @hidden */
  40972. /** @hidden */
  40973. /** Releases associated resources */
  40974. dispose(): void;
  40975. /** HORIZONTAL_ALIGNMENT_LEFT */
  40976. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  40977. /** HORIZONTAL_ALIGNMENT_RIGHT */
  40978. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  40979. /** HORIZONTAL_ALIGNMENT_CENTER */
  40980. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  40981. /** VERTICAL_ALIGNMENT_TOP */
  40982. static readonly VERTICAL_ALIGNMENT_TOP: number;
  40983. /** VERTICAL_ALIGNMENT_BOTTOM */
  40984. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  40985. /** VERTICAL_ALIGNMENT_CENTER */
  40986. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  40987. /** @hidden */ private static _GetFontOffset(font: string): {
  40988. ascent: number;
  40989. height: number;
  40990. descent: number;
  40991. };
  40992. /**
  40993. * Creates a stack panel that can be used to render headers
  40994. * @param control defines the control to associate with the header
  40995. * @param text defines the text of the header
  40996. * @param size defines the size of the header
  40997. * @param options defines options used to configure the header
  40998. * @returns a new StackPanel
  40999. * @ignore
  41000. * @hidden
  41001. */
  41002. static AddHeader: (control: Control, text: string, size: string | number, options: {
  41003. isHorizontal: boolean;
  41004. controlFirst: boolean;
  41005. }) => any;
  41006. /** @hidden */
  41007. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  41008. }
  41009. }
  41010. declare module BABYLON.GUI {
  41011. /** Class used to create 2D ellipse containers */
  41012. export class Ellipse extends Container {
  41013. name?: string | undefined;
  41014. /** Gets or sets border thickness */
  41015. thickness: number;
  41016. /**
  41017. * Creates a new Ellipse
  41018. * @param name defines the control name
  41019. */
  41020. constructor(name?: string | undefined);
  41021. protected _getTypeName(): string;
  41022. protected _localDraw(context: CanvasRenderingContext2D): void;
  41023. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41024. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  41025. }
  41026. }
  41027. declare module BABYLON.GUI {
  41028. /**
  41029. * Class used to create a 2D grid container
  41030. */
  41031. export class Grid extends Container {
  41032. name?: string | undefined;
  41033. /** Gets the list of children */
  41034. readonly children: Control[];
  41035. /**
  41036. * Adds a new row to the grid
  41037. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  41038. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  41039. * @returns the current grid
  41040. */
  41041. addRowDefinition(height: number, isPixel?: boolean): Grid;
  41042. /**
  41043. * Adds a new column to the grid
  41044. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  41045. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  41046. * @returns the current grid
  41047. */
  41048. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  41049. /**
  41050. * Update a row definition
  41051. * @param index defines the index of the row to update
  41052. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  41053. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  41054. * @returns the current grid
  41055. */
  41056. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  41057. /**
  41058. * Update a column definition
  41059. * @param index defines the index of the column to update
  41060. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  41061. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  41062. * @returns the current grid
  41063. */
  41064. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  41065. /**
  41066. * Remove a column definition at specified index
  41067. * @param index defines the index of the column to remove
  41068. * @returns the current grid
  41069. */
  41070. removeColumnDefinition(index: number): Grid;
  41071. /**
  41072. * Remove a row definition at specified index
  41073. * @param index defines the index of the row to remove
  41074. * @returns the current grid
  41075. */
  41076. removeRowDefinition(index: number): Grid;
  41077. /**
  41078. * Adds a new control to the current grid
  41079. * @param control defines the control to add
  41080. * @param row defines the row where to add the control (0 by default)
  41081. * @param column defines the column where to add the control (0 by default)
  41082. * @returns the current grid
  41083. */
  41084. addControl(control: Control, row?: number, column?: number): Grid;
  41085. /**
  41086. * Removes a control from the current container
  41087. * @param control defines the control to remove
  41088. * @returns the current container
  41089. */
  41090. removeControl(control: Control): Container;
  41091. /**
  41092. * Creates a new Grid
  41093. * @param name defines control name
  41094. */
  41095. constructor(name?: string | undefined);
  41096. protected _getTypeName(): string;
  41097. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41098. /** Releases associated resources */
  41099. dispose(): void;
  41100. }
  41101. }
  41102. declare module BABYLON.GUI {
  41103. /**
  41104. * Class used to create 2D images
  41105. */
  41106. export class Image extends Control {
  41107. name?: string | undefined;
  41108. /**
  41109. * Gets or sets the left coordinate in the source image
  41110. */
  41111. sourceLeft: number;
  41112. /**
  41113. * Gets or sets the top coordinate in the source image
  41114. */
  41115. sourceTop: number;
  41116. /**
  41117. * Gets or sets the width to capture in the source image
  41118. */
  41119. sourceWidth: number;
  41120. /**
  41121. * Gets or sets the height to capture in the source image
  41122. */
  41123. sourceHeight: number;
  41124. /**
  41125. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  41126. * @see http://doc.babylonjs.com/how_to/gui#image
  41127. */
  41128. autoScale: boolean;
  41129. /** Gets or sets the streching mode used by the image */
  41130. stretch: number;
  41131. /**
  41132. * Gets or sets the internal DOM image used to render the control
  41133. */
  41134. domImage: HTMLImageElement;
  41135. /**
  41136. * Gets or sets image source url
  41137. */
  41138. source: BABYLON.Nullable<string>;
  41139. /**
  41140. * Gets or sets the cell width to use when animation sheet is enabled
  41141. * @see http://doc.babylonjs.com/how_to/gui#image
  41142. */
  41143. cellWidth: number;
  41144. /**
  41145. * Gets or sets the cell height to use when animation sheet is enabled
  41146. * @see http://doc.babylonjs.com/how_to/gui#image
  41147. */
  41148. cellHeight: number;
  41149. /**
  41150. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  41151. * @see http://doc.babylonjs.com/how_to/gui#image
  41152. */
  41153. cellId: number;
  41154. /**
  41155. * Creates a new Image
  41156. * @param name defines the control name
  41157. * @param url defines the image url
  41158. */
  41159. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  41160. protected _getTypeName(): string;
  41161. /** Force the control to synchronize with its content */
  41162. synchronizeSizeWithContent(): void;
  41163. /** STRETCH_NONE */
  41164. static readonly STRETCH_NONE: number;
  41165. /** STRETCH_FILL */
  41166. static readonly STRETCH_FILL: number;
  41167. /** STRETCH_UNIFORM */
  41168. static readonly STRETCH_UNIFORM: number;
  41169. /** STRETCH_EXTEND */
  41170. static readonly STRETCH_EXTEND: number;
  41171. }
  41172. }
  41173. declare module BABYLON.GUI {
  41174. /**
  41175. * Class used to create input text control
  41176. */
  41177. export class InputText extends Control implements IFocusableControl {
  41178. name?: string | undefined;
  41179. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  41180. promptMessage: string;
  41181. /** BABYLON.Observable raised when the text changes */
  41182. onTextChangedObservable: BABYLON.Observable<InputText>;
  41183. /** BABYLON.Observable raised just before an entered character is to be added */
  41184. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  41185. /** BABYLON.Observable raised when the control gets the focus */
  41186. onFocusObservable: BABYLON.Observable<InputText>;
  41187. /** BABYLON.Observable raised when the control loses the focus */
  41188. onBlurObservable: BABYLON.Observable<InputText>;
  41189. /** Gets or sets the maximum width allowed by the control */
  41190. maxWidth: string | number;
  41191. /** Gets the maximum width allowed by the control in pixels */
  41192. readonly maxWidthInPixels: number;
  41193. /** Gets or sets control margin */
  41194. margin: string;
  41195. /** Gets control margin in pixels */
  41196. readonly marginInPixels: number;
  41197. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  41198. autoStretchWidth: boolean;
  41199. /** Gets or sets border thickness */
  41200. thickness: number;
  41201. /** Gets or sets the background color when focused */
  41202. focusedBackground: string;
  41203. /** Gets or sets the background color */
  41204. background: string;
  41205. /** Gets or sets the placeholder color */
  41206. placeholderColor: string;
  41207. /** Gets or sets the text displayed when the control is empty */
  41208. placeholderText: string;
  41209. /** Gets or sets the dead key flag */
  41210. deadKey: boolean;
  41211. /** Gets or sets if the current key should be added */
  41212. addKey: boolean;
  41213. /** Gets or sets the value of the current key being entered */
  41214. currentKey: string;
  41215. /** Gets or sets the text displayed in the control */
  41216. text: string;
  41217. /** Gets or sets control width */
  41218. width: string | number;
  41219. /**
  41220. * Creates a new InputText
  41221. * @param name defines the control name
  41222. * @param text defines the text of the control
  41223. */
  41224. constructor(name?: string | undefined, text?: string);
  41225. /** @hidden */
  41226. onBlur(): void;
  41227. /** @hidden */
  41228. onFocus(): void;
  41229. protected _getTypeName(): string;
  41230. /** @hidden */
  41231. processKey(keyCode: number, key?: string): void;
  41232. /** @hidden */
  41233. processKeyboard(evt: KeyboardEvent): void;
  41234. protected _beforeRenderText(text: string): string;
  41235. dispose(): void;
  41236. }
  41237. }
  41238. declare module BABYLON.GUI {
  41239. /**
  41240. * Class used to create a password control
  41241. */
  41242. export class InputPassword extends InputText {
  41243. protected _beforeRenderText(text: string): string;
  41244. }
  41245. }
  41246. declare module BABYLON.GUI {
  41247. /** Class used to render 2D lines */
  41248. export class Line extends Control {
  41249. name?: string | undefined;
  41250. /** Gets or sets the dash pattern */
  41251. dash: Array<number>;
  41252. /** Gets or sets the control connected with the line end */
  41253. connectedControl: Control;
  41254. /** Gets or sets start coordinates on X axis */
  41255. x1: string | number;
  41256. /** Gets or sets start coordinates on Y axis */
  41257. y1: string | number;
  41258. /** Gets or sets end coordinates on X axis */
  41259. x2: string | number;
  41260. /** Gets or sets end coordinates on Y axis */
  41261. y2: string | number;
  41262. /** Gets or sets line width */
  41263. lineWidth: number;
  41264. /** Gets or sets horizontal alignment */
  41265. horizontalAlignment: number;
  41266. /** Gets or sets vertical alignment */
  41267. verticalAlignment: number;
  41268. /**
  41269. * Creates a new Line
  41270. * @param name defines the control name
  41271. */
  41272. constructor(name?: string | undefined);
  41273. protected _getTypeName(): string;
  41274. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41275. /**
  41276. * Move one end of the line given 3D cartesian coordinates.
  41277. * @param position Targeted world position
  41278. * @param scene BABYLON.Scene
  41279. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  41280. */
  41281. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  41282. /**
  41283. * Move one end of the line to a position in screen absolute space.
  41284. * @param projectedPosition Position in screen absolute space (X, Y)
  41285. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  41286. */
  41287. }
  41288. }
  41289. declare module BABYLON.GUI {
  41290. /**
  41291. * Class used to create multi line control
  41292. */
  41293. export class MultiLine extends Control {
  41294. name?: string | undefined;
  41295. /**
  41296. * Creates a new MultiLine
  41297. * @param name defines the control name
  41298. */
  41299. constructor(name?: string | undefined);
  41300. /** Gets or sets dash pattern */
  41301. dash: Array<number>;
  41302. /**
  41303. * Gets point stored at specified index
  41304. * @param index defines the index to look for
  41305. * @returns the requested point if found
  41306. */
  41307. getAt(index: number): MultiLinePoint;
  41308. /** Function called when a point is updated */
  41309. onPointUpdate: () => void;
  41310. /**
  41311. * Adds new points to the point collection
  41312. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  41313. * @returns the list of created MultiLinePoint
  41314. */
  41315. add(...items: (AbstractMesh | Control | {
  41316. x: string | number;
  41317. y: string | number;
  41318. })[]): MultiLinePoint[];
  41319. /**
  41320. * Adds a new point to the point collection
  41321. * @param item defines the item (mesh, control or 2d coordiantes) to add
  41322. * @returns the created MultiLinePoint
  41323. */
  41324. push(item?: (AbstractMesh | Control | {
  41325. x: string | number;
  41326. y: string | number;
  41327. })): MultiLinePoint;
  41328. /**
  41329. * Remove a specific value or point from the active point collection
  41330. * @param value defines the value or point to remove
  41331. */
  41332. remove(value: number | MultiLinePoint): void;
  41333. /** Gets or sets line width */
  41334. lineWidth: number;
  41335. horizontalAlignment: number;
  41336. verticalAlignment: number;
  41337. protected _getTypeName(): string;
  41338. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41339. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41340. dispose(): void;
  41341. }
  41342. }
  41343. declare module BABYLON.GUI {
  41344. /**
  41345. * Class used to create radio button controls
  41346. */
  41347. export class RadioButton extends Control {
  41348. name?: string | undefined;
  41349. /** Gets or sets border thickness */
  41350. thickness: number;
  41351. /** Gets or sets group name */
  41352. group: string;
  41353. /** BABYLON.Observable raised when isChecked is changed */
  41354. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  41355. /** Gets or sets a value indicating the ratio between overall size and check size */
  41356. checkSizeRatio: number;
  41357. /** Gets or sets background color */
  41358. background: string;
  41359. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  41360. isChecked: boolean;
  41361. /**
  41362. * Creates a new RadioButton
  41363. * @param name defines the control name
  41364. */
  41365. constructor(name?: string | undefined);
  41366. protected _getTypeName(): string;
  41367. /**
  41368. * Utility function to easily create a radio button with a header
  41369. * @param title defines the label to use for the header
  41370. * @param group defines the group to use for the radio button
  41371. * @param isChecked defines the initial state of the radio button
  41372. * @param onValueChanged defines the callback to call when value changes
  41373. * @returns a StackPanel containing the radio button and a textBlock
  41374. */
  41375. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  41376. }
  41377. }
  41378. declare module BABYLON.GUI {
  41379. /**
  41380. * Class used to create a 2D stack panel container
  41381. */
  41382. export class StackPanel extends Container {
  41383. name?: string | undefined;
  41384. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  41385. isVertical: boolean;
  41386. /** Gets or sets panel width */
  41387. width: string | number;
  41388. /** Gets or sets panel height */
  41389. height: string | number;
  41390. /**
  41391. * Creates a new StackPanel
  41392. * @param name defines control name
  41393. */
  41394. constructor(name?: string | undefined);
  41395. protected _getTypeName(): string;
  41396. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41397. }
  41398. }
  41399. declare module BABYLON.GUI {
  41400. /** Class used to create a RadioGroup
  41401. * which contains groups of radio buttons
  41402. */
  41403. export class SelectorGroup {
  41404. /** name of SelectorGroup */
  41405. name: string;
  41406. /**
  41407. * Creates a new SelectorGroup
  41408. * @param name of group, used as a group heading
  41409. */
  41410. constructor(
  41411. /** name of SelectorGroup */
  41412. name: string);
  41413. /** Gets the groupPanel of the SelectorGroup */
  41414. readonly groupPanel: StackPanel;
  41415. /** Gets the selectors array */
  41416. readonly selectors: StackPanel[];
  41417. /** Gets and sets the group header */
  41418. header: string;
  41419. /** @hidden*/
  41420. /** Removes the selector at the given position
  41421. * @param selectorNb the position of the selector within the group
  41422. */
  41423. removeSelector(selectorNb: number): void;
  41424. }
  41425. /** Class used to create a CheckboxGroup
  41426. * which contains groups of checkbox buttons
  41427. */
  41428. export class CheckboxGroup extends SelectorGroup {
  41429. /** Adds a checkbox as a control
  41430. * @param text is the label for the selector
  41431. * @param func is the function called when the Selector is checked
  41432. * @param checked is true when Selector is checked
  41433. */
  41434. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  41435. /** @hidden */
  41436. /** @hidden */
  41437. /** @hidden */
  41438. /** @hidden */
  41439. }
  41440. /** Class used to create a RadioGroup
  41441. * which contains groups of radio buttons
  41442. */
  41443. export class RadioGroup extends SelectorGroup {
  41444. /** Adds a radio button as a control
  41445. * @param label is the label for the selector
  41446. * @param func is the function called when the Selector is checked
  41447. * @param checked is true when Selector is checked
  41448. */
  41449. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  41450. /** @hidden */
  41451. /** @hidden */
  41452. /** @hidden */
  41453. /** @hidden */
  41454. }
  41455. /** Class used to create a SliderGroup
  41456. * which contains groups of slider buttons
  41457. */
  41458. export class SliderGroup extends SelectorGroup {
  41459. /**
  41460. * Adds a slider to the SelectorGroup
  41461. * @param label is the label for the SliderBar
  41462. * @param func is the function called when the Slider moves
  41463. * @param unit is a string describing the units used, eg degrees or metres
  41464. * @param min is the minimum value for the Slider
  41465. * @param max is the maximum value for the Slider
  41466. * @param value is the start value for the Slider between min and max
  41467. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  41468. */
  41469. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  41470. /** @hidden */
  41471. /** @hidden */
  41472. /** @hidden */
  41473. /** @hidden */
  41474. }
  41475. /** Class used to hold the controls for the checkboxes, radio buttons and sliders */
  41476. export class SelectionPanel extends Rectangle {
  41477. /** name of SelectionPanel */
  41478. name: string;
  41479. /** an array of SelectionGroups */
  41480. groups: SelectorGroup[];
  41481. /**
  41482. * Creates a new SelectionPanel
  41483. * @param name of SelectionPanel
  41484. * @param groups is an array of SelectionGroups
  41485. */
  41486. constructor(
  41487. /** name of SelectionPanel */
  41488. name: string,
  41489. /** an array of SelectionGroups */
  41490. groups?: SelectorGroup[]);
  41491. protected _getTypeName(): string;
  41492. /** Gets or sets the headerColor */
  41493. headerColor: string;
  41494. /** Gets or sets the button color */
  41495. buttonColor: string;
  41496. /** Gets or sets the label color */
  41497. labelColor: string;
  41498. /** Gets or sets the button background */
  41499. buttonBackground: string;
  41500. /** Gets or sets the color of separator bar */
  41501. barColor: string;
  41502. /** Add a group to the selection panel
  41503. * @param group is the selector group to add
  41504. */
  41505. addGroup(group: SelectorGroup): void;
  41506. /** Remove the group from the given position
  41507. * @param groupNb is the position of the group in the list
  41508. */
  41509. removeGroup(groupNb: number): void;
  41510. /** Change a group header label
  41511. * @param label is the new group header label
  41512. * @param groupNb is the number of the group to relabel
  41513. * */
  41514. setHeaderName(label: string, groupNb: number): void;
  41515. /** Change selector label to the one given
  41516. * @param label is the new selector label
  41517. * @param groupNb is the number of the groupcontaining the selector
  41518. * @param selectorNb is the number of the selector within a group to relabel
  41519. * */
  41520. relabel(label: string, groupNb: number, selectorNb: number): void;
  41521. /** For a given group position remove the selector at the given position
  41522. * @param groupNb is the number of the group to remove the selector from
  41523. * @param selectorNb is the number of the selector within the group
  41524. */
  41525. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  41526. /** For a given group position of correct type add a checkbox button
  41527. * @param groupNb is the number of the group to remove the selector from
  41528. * @param label is the label for the selector
  41529. * @param func is the function called when the Selector is checked
  41530. * @param checked is true when Selector is checked
  41531. */
  41532. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  41533. /** For a given group position of correct type add a radio button
  41534. * @param groupNb is the number of the group to remove the selector from
  41535. * @param label is the label for the selector
  41536. * @param func is the function called when the Selector is checked
  41537. * @param checked is true when Selector is checked
  41538. */
  41539. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  41540. /**
  41541. * For a given slider group add a slider
  41542. * @param groupNb is the number of the group to add the slider to
  41543. * @param label is the label for the Slider
  41544. * @param func is the function called when the Slider moves
  41545. * @param unit is a string describing the units used, eg degrees or metres
  41546. * @param min is the minimum value for the Slider
  41547. * @param max is the maximum value for the Slider
  41548. * @param value is the start value for the Slider between min and max
  41549. * @param onVal is the function used to format the value displayed, eg radians to degrees
  41550. */
  41551. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  41552. }
  41553. }
  41554. declare module BABYLON.GUI {
  41555. /**
  41556. * Enum that determines the text-wrapping mode to use.
  41557. */
  41558. export enum TextWrapping {
  41559. /**
  41560. * Clip the text when it's larger than Control.width; this is the default mode.
  41561. */
  41562. Clip = 0,
  41563. /**
  41564. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  41565. */
  41566. WordWrap = 1,
  41567. /**
  41568. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  41569. */
  41570. Ellipsis = 2
  41571. }
  41572. /**
  41573. * Class used to create text block control
  41574. */
  41575. export class TextBlock extends Control {
  41576. /**
  41577. * Defines the name of the control
  41578. */
  41579. name?: string | undefined;
  41580. /**
  41581. * An event triggered after the text is changed
  41582. */
  41583. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  41584. /**
  41585. * An event triggered after the text was broken up into lines
  41586. */
  41587. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  41588. /**
  41589. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  41590. */
  41591. readonly lines: any[];
  41592. /**
  41593. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  41594. */
  41595. resizeToFit: boolean;
  41596. /**
  41597. * Gets or sets a boolean indicating if text must be wrapped
  41598. */
  41599. textWrapping: TextWrapping | boolean;
  41600. /**
  41601. * Gets or sets text to display
  41602. */
  41603. text: string;
  41604. /**
  41605. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  41606. */
  41607. textHorizontalAlignment: number;
  41608. /**
  41609. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  41610. */
  41611. textVerticalAlignment: number;
  41612. /**
  41613. * Gets or sets line spacing value
  41614. */
  41615. lineSpacing: string | number;
  41616. /**
  41617. * Gets or sets outlineWidth of the text to display
  41618. */
  41619. outlineWidth: number;
  41620. /**
  41621. * Gets or sets outlineColor of the text to display
  41622. */
  41623. outlineColor: string;
  41624. /**
  41625. * Creates a new TextBlock object
  41626. * @param name defines the name of the control
  41627. * @param text defines the text to display (emptry string by default)
  41628. */
  41629. constructor(
  41630. /**
  41631. * Defines the name of the control
  41632. */
  41633. name?: string | undefined, text?: string);
  41634. protected _getTypeName(): string;
  41635. /** @hidden */
  41636. protected _applyStates(context: CanvasRenderingContext2D): void;
  41637. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41638. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  41639. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  41640. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  41641. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  41642. protected _renderLines(context: CanvasRenderingContext2D): void;
  41643. /**
  41644. * Given a width constraint applied on the text block, find the expected height
  41645. * @returns expected height
  41646. */
  41647. computeExpectedHeight(): number;
  41648. dispose(): void;
  41649. }
  41650. }
  41651. declare module BABYLON.GUI {
  41652. /**
  41653. * Class used to store key control properties
  41654. */
  41655. export class KeyPropertySet {
  41656. /** Width */
  41657. width?: string;
  41658. /** Height */
  41659. height?: string;
  41660. /** Left padding */
  41661. paddingLeft?: string;
  41662. /** Right padding */
  41663. paddingRight?: string;
  41664. /** Top padding */
  41665. paddingTop?: string;
  41666. /** Bottom padding */
  41667. paddingBottom?: string;
  41668. /** Foreground color */
  41669. color?: string;
  41670. /** Background color */
  41671. background?: string;
  41672. }
  41673. /**
  41674. * Class used to create virtual keyboard
  41675. */
  41676. export class VirtualKeyboard extends StackPanel {
  41677. /** BABYLON.Observable raised when a key is pressed */
  41678. onKeyPressObservable: BABYLON.Observable<string>;
  41679. /** Gets or sets default key button width */
  41680. defaultButtonWidth: string;
  41681. /** Gets or sets default key button height */
  41682. defaultButtonHeight: string;
  41683. /** Gets or sets default key button left padding */
  41684. defaultButtonPaddingLeft: string;
  41685. /** Gets or sets default key button right padding */
  41686. defaultButtonPaddingRight: string;
  41687. /** Gets or sets default key button top padding */
  41688. defaultButtonPaddingTop: string;
  41689. /** Gets or sets default key button bottom padding */
  41690. defaultButtonPaddingBottom: string;
  41691. /** Gets or sets default key button foreground color */
  41692. defaultButtonColor: string;
  41693. /** Gets or sets default key button background color */
  41694. defaultButtonBackground: string;
  41695. /** Gets or sets shift button foreground color */
  41696. shiftButtonColor: string;
  41697. /** Gets or sets shift button thickness*/
  41698. selectedShiftThickness: number;
  41699. /** Gets shift key state */
  41700. shiftState: number;
  41701. protected _getTypeName(): string;
  41702. /**
  41703. * Adds a new row of keys
  41704. * @param keys defines the list of keys to add
  41705. * @param propertySets defines the associated property sets
  41706. */
  41707. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  41708. /**
  41709. * Set the shift key to a specific state
  41710. * @param shiftState defines the new shift state
  41711. */
  41712. applyShiftState(shiftState: number): void;
  41713. /** Gets the input text control attached with the keyboard */
  41714. readonly connectedInputText: BABYLON.Nullable<InputText>;
  41715. /**
  41716. * Connects the keyboard with an input text control
  41717. * @param input defines the target control
  41718. */
  41719. connect(input: InputText): void;
  41720. /**
  41721. * Disconnects the keyboard from an input text control
  41722. */
  41723. disconnect(): void;
  41724. /**
  41725. * Creates a new keyboard using a default layout
  41726. * @returns a new VirtualKeyboard
  41727. */
  41728. static CreateDefaultLayout(): VirtualKeyboard;
  41729. }
  41730. }
  41731. declare module BABYLON.GUI {
  41732. /**
  41733. * Class used to create slider controls
  41734. */
  41735. export class Slider extends Control {
  41736. name?: string | undefined;
  41737. /** BABYLON.Observable raised when the sldier value changes */
  41738. onValueChangedObservable: BABYLON.Observable<number>;
  41739. /** Gets or sets border color */
  41740. borderColor: string;
  41741. /** Gets or sets background color */
  41742. background: string;
  41743. /** Gets or sets main bar offset */
  41744. barOffset: string | number;
  41745. /** Gets main bar offset in pixels*/
  41746. readonly barOffsetInPixels: number;
  41747. /** Gets or sets thumb width */
  41748. thumbWidth: string | number;
  41749. /** Gets thumb width in pixels */
  41750. readonly thumbWidthInPixels: number;
  41751. /** Gets or sets minimum value */
  41752. minimum: number;
  41753. /** Gets or sets maximum value */
  41754. maximum: number;
  41755. /** Gets or sets current value */
  41756. value: number;
  41757. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  41758. isVertical: boolean;
  41759. /** Gets or sets a boolean indicating if the thumb should be round or square */
  41760. isThumbCircle: boolean;
  41761. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  41762. isThumbClamped: boolean;
  41763. /**
  41764. * Creates a new Slider
  41765. * @param name defines the control name
  41766. */
  41767. constructor(name?: string | undefined);
  41768. protected _getTypeName(): string;
  41769. protected _getThumbThickness(type: string, backgroundLength: number): number;
  41770. }
  41771. }
  41772. declare module BABYLON.GUI {
  41773. /** Class used to create rectangle container */
  41774. export class Rectangle extends Container {
  41775. name?: string | undefined;
  41776. /** Gets or sets border thickness */
  41777. thickness: number;
  41778. /** Gets or sets the corner radius angle */
  41779. cornerRadius: number;
  41780. /**
  41781. * Creates a new Rectangle
  41782. * @param name defines the control name
  41783. */
  41784. constructor(name?: string | undefined);
  41785. protected _getTypeName(): string;
  41786. protected _localDraw(context: CanvasRenderingContext2D): void;
  41787. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  41788. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  41789. }
  41790. }
  41791. declare module BABYLON.GUI {
  41792. /** Class used to render a grid */
  41793. export class DisplayGrid extends Control {
  41794. name?: string | undefined;
  41795. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  41796. displayMinorLines: boolean;
  41797. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  41798. displayMajorLines: boolean;
  41799. /** Gets or sets background color (Black by default) */
  41800. background: string;
  41801. /** Gets or sets the width of each cell (20 by default) */
  41802. cellWidth: number;
  41803. /** Gets or sets the height of each cell (20 by default) */
  41804. cellHeight: number;
  41805. /** Gets or sets the tickness of minor lines (1 by default) */
  41806. minorLineTickness: number;
  41807. /** Gets or sets the color of minor lines (DarkGray by default) */
  41808. minorLineColor: string;
  41809. /** Gets or sets the tickness of major lines (2 by default) */
  41810. majorLineTickness: number;
  41811. /** Gets or sets the color of major lines (White by default) */
  41812. majorLineColor: string;
  41813. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  41814. majorLineFrequency: number;
  41815. /**
  41816. * Creates a new GridDisplayRectangle
  41817. * @param name defines the control name
  41818. */
  41819. constructor(name?: string | undefined);
  41820. protected _getTypeName(): string;
  41821. }
  41822. }
  41823. declare module BABYLON.GUI {
  41824. /**
  41825. * Forcing an export so that this code will execute
  41826. * @hidden
  41827. */
  41828. const name = "Statics";
  41829. }
  41830. declare module BABYLON.GUI {
  41831. /**
  41832. * Class used as a root to all buttons
  41833. */
  41834. export class AbstractButton3D extends Control3D {
  41835. /**
  41836. * Creates a new button
  41837. * @param name defines the control name
  41838. */
  41839. constructor(name?: string);
  41840. protected _getTypeName(): string;
  41841. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  41842. }
  41843. }
  41844. declare module BABYLON.GUI {
  41845. /**
  41846. * Class used to create a button in 3D
  41847. */
  41848. export class Button3D extends AbstractButton3D {
  41849. /** @hidden */
  41850. protected _currentMaterial: BABYLON.Material;
  41851. /**
  41852. * Gets or sets the texture resolution used to render content (512 by default)
  41853. */
  41854. contentResolution: BABYLON.int;
  41855. /**
  41856. * Gets or sets the texture scale ratio used to render content (2 by default)
  41857. */
  41858. contentScaleRatio: number;
  41859. protected _disposeFacadeTexture(): void;
  41860. protected _resetContent(): void;
  41861. /**
  41862. * Creates a new button
  41863. * @param name defines the control name
  41864. */
  41865. constructor(name?: string);
  41866. /**
  41867. * Gets or sets the GUI 2D content used to display the button's facade
  41868. */
  41869. content: Control;
  41870. /**
  41871. * Apply the facade texture (created from the content property).
  41872. * This function can be overloaded by child classes
  41873. * @param facadeTexture defines the AdvancedDynamicTexture to use
  41874. */
  41875. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  41876. protected _getTypeName(): string;
  41877. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  41878. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  41879. /**
  41880. * Releases all associated resources
  41881. */
  41882. dispose(): void;
  41883. }
  41884. }
  41885. declare module BABYLON.GUI {
  41886. /**
  41887. * Class used to create containers for controls
  41888. */
  41889. export class Container3D extends Control3D {
  41890. /**
  41891. * Gets the list of child controls
  41892. */
  41893. protected _children: Control3D[];
  41894. /**
  41895. * Gets the list of child controls
  41896. */
  41897. readonly children: Array<Control3D>;
  41898. /**
  41899. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  41900. * This is helpful to optimize layout operation when adding multiple children in a row
  41901. */
  41902. blockLayout: boolean;
  41903. /**
  41904. * Creates a new container
  41905. * @param name defines the container name
  41906. */
  41907. constructor(name?: string);
  41908. /**
  41909. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  41910. * @returns the current container
  41911. */
  41912. updateLayout(): Container3D;
  41913. /**
  41914. * Gets a boolean indicating if the given control is in the children of this control
  41915. * @param control defines the control to check
  41916. * @returns true if the control is in the child list
  41917. */
  41918. containsControl(control: Control3D): boolean;
  41919. /**
  41920. * Adds a control to the children of this control
  41921. * @param control defines the control to add
  41922. * @returns the current container
  41923. */
  41924. addControl(control: Control3D): Container3D;
  41925. /**
  41926. * This function will be called everytime a new control is added
  41927. */
  41928. protected _arrangeChildren(): void;
  41929. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  41930. /**
  41931. * Removes a control from the children of this control
  41932. * @param control defines the control to remove
  41933. * @returns the current container
  41934. */
  41935. removeControl(control: Control3D): Container3D;
  41936. protected _getTypeName(): string;
  41937. /**
  41938. * Releases all associated resources
  41939. */
  41940. dispose(): void;
  41941. /** Control rotation will remain unchanged */
  41942. static readonly UNSET_ORIENTATION: number;
  41943. /** Control will rotate to make it look at sphere central axis */
  41944. static readonly FACEORIGIN_ORIENTATION: number;
  41945. /** Control will rotate to make it look back at sphere central axis */
  41946. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  41947. /** Control will rotate to look at z axis (0, 0, 1) */
  41948. static readonly FACEFORWARD_ORIENTATION: number;
  41949. /** Control will rotate to look at negative z axis (0, 0, -1) */
  41950. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  41951. }
  41952. }
  41953. declare module BABYLON.GUI {
  41954. /**
  41955. * Class used as base class for controls
  41956. */
  41957. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  41958. /** Defines the control name */
  41959. name?: string | undefined;
  41960. /** @hidden */
  41961. /** Gets or sets the control position in world space */
  41962. position: BABYLON.Vector3;
  41963. /** Gets or sets the control scaling in world space */
  41964. scaling: BABYLON.Vector3;
  41965. /** Callback used to start pointer enter animation */
  41966. pointerEnterAnimation: () => void;
  41967. /** Callback used to start pointer out animation */
  41968. pointerOutAnimation: () => void;
  41969. /** Callback used to start pointer down animation */
  41970. pointerDownAnimation: () => void;
  41971. /** Callback used to start pointer up animation */
  41972. pointerUpAnimation: () => void;
  41973. /**
  41974. * An event triggered when the pointer move over the control
  41975. */
  41976. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  41977. /**
  41978. * An event triggered when the pointer move out of the control
  41979. */
  41980. onPointerOutObservable: BABYLON.Observable<Control3D>;
  41981. /**
  41982. * An event triggered when the pointer taps the control
  41983. */
  41984. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  41985. /**
  41986. * An event triggered when pointer is up
  41987. */
  41988. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  41989. /**
  41990. * An event triggered when a control is clicked on (with a mouse)
  41991. */
  41992. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  41993. /**
  41994. * An event triggered when pointer enters the control
  41995. */
  41996. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  41997. /**
  41998. * Gets or sets the parent container
  41999. */
  42000. parent: BABYLON.Nullable<Container3D>;
  42001. /**
  42002. * Gets the list of attached behaviors
  42003. * @see http://doc.babylonjs.com/features/behaviour
  42004. */
  42005. readonly behaviors: BABYLON.Behavior<Control3D>[];
  42006. /**
  42007. * Attach a behavior to the control
  42008. * @see http://doc.babylonjs.com/features/behaviour
  42009. * @param behavior defines the behavior to attach
  42010. * @returns the current control
  42011. */
  42012. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  42013. /**
  42014. * Remove an attached behavior
  42015. * @see http://doc.babylonjs.com/features/behaviour
  42016. * @param behavior defines the behavior to attach
  42017. * @returns the current control
  42018. */
  42019. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  42020. /**
  42021. * Gets an attached behavior by name
  42022. * @param name defines the name of the behavior to look for
  42023. * @see http://doc.babylonjs.com/features/behaviour
  42024. * @returns null if behavior was not found else the requested behavior
  42025. */
  42026. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  42027. /** Gets or sets a boolean indicating if the control is visible */
  42028. isVisible: boolean;
  42029. /**
  42030. * Creates a new control
  42031. * @param name defines the control name
  42032. */
  42033. constructor(
  42034. /** Defines the control name */
  42035. name?: string | undefined);
  42036. /**
  42037. * Gets a string representing the class name
  42038. */
  42039. readonly typeName: string;
  42040. protected _getTypeName(): string;
  42041. /**
  42042. * Gets the transform node used by this control
  42043. */
  42044. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  42045. /**
  42046. * Gets the mesh used to render this control
  42047. */
  42048. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  42049. /**
  42050. * Link the control as child of the given node
  42051. * @param node defines the node to link to. Use null to unlink the control
  42052. * @returns the current control
  42053. */
  42054. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  42055. /** @hidden **/
  42056. /**
  42057. * Node creation.
  42058. * Can be overriden by children
  42059. * @param scene defines the scene where the node must be attached
  42060. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  42061. */
  42062. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  42063. /**
  42064. * Affect a material to the given mesh
  42065. * @param mesh defines the mesh which will represent the control
  42066. */
  42067. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  42068. /** @hidden */
  42069. /** @hidden */
  42070. /** @hidden */
  42071. /** @hidden */
  42072. /** @hidden */
  42073. /** @hidden */
  42074. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  42075. /** @hidden */
  42076. /** @hidden */
  42077. /**
  42078. * Releases all associated resources
  42079. */
  42080. dispose(): void;
  42081. }
  42082. }
  42083. declare module BABYLON.GUI {
  42084. /**
  42085. * Class used to create a container panel deployed on the surface of a cylinder
  42086. */
  42087. export class CylinderPanel extends VolumeBasedPanel {
  42088. /**
  42089. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  42090. */
  42091. radius: BABYLON.float;
  42092. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  42093. }
  42094. }
  42095. declare module BABYLON.GUI {
  42096. /**
  42097. * Class used to create a holographic button in 3D
  42098. */
  42099. export class HolographicButton extends Button3D {
  42100. /**
  42101. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  42102. */
  42103. tooltipText: BABYLON.Nullable<string>;
  42104. /**
  42105. * Gets or sets text for the button
  42106. */
  42107. text: string;
  42108. /**
  42109. * Gets or sets the image url for the button
  42110. */
  42111. imageUrl: string;
  42112. /**
  42113. * Gets the back material used by this button
  42114. */
  42115. readonly backMaterial: FluentMaterial;
  42116. /**
  42117. * Gets the front material used by this button
  42118. */
  42119. readonly frontMaterial: FluentMaterial;
  42120. /**
  42121. * Gets the plate material used by this button
  42122. */
  42123. readonly plateMaterial: BABYLON.StandardMaterial;
  42124. /**
  42125. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  42126. */
  42127. readonly shareMaterials: boolean;
  42128. /**
  42129. * Creates a new button
  42130. * @param name defines the control name
  42131. */
  42132. constructor(name?: string, shareMaterials?: boolean);
  42133. protected _getTypeName(): string;
  42134. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  42135. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  42136. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  42137. /**
  42138. * Releases all associated resources
  42139. */
  42140. dispose(): void;
  42141. }
  42142. }
  42143. declare module BABYLON.GUI {
  42144. /**
  42145. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  42146. */
  42147. export class MeshButton3D extends Button3D {
  42148. /** @hidden */
  42149. protected _currentMesh: BABYLON.Mesh;
  42150. /**
  42151. * Creates a new 3D button based on a mesh
  42152. * @param mesh mesh to become a 3D button
  42153. * @param name defines the control name
  42154. */
  42155. constructor(mesh: BABYLON.Mesh, name?: string);
  42156. protected _getTypeName(): string;
  42157. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  42158. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  42159. }
  42160. }
  42161. declare module BABYLON.GUI {
  42162. /**
  42163. * Class used to create a container panel deployed on the surface of a plane
  42164. */
  42165. export class PlanePanel extends VolumeBasedPanel {
  42166. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  42167. }
  42168. }
  42169. declare module BABYLON.GUI {
  42170. /**
  42171. * Class used to create a container panel where items get randomized planar mapping
  42172. */
  42173. export class ScatterPanel extends VolumeBasedPanel {
  42174. /**
  42175. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  42176. */
  42177. iteration: BABYLON.float;
  42178. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  42179. protected _finalProcessing(): void;
  42180. }
  42181. }
  42182. declare module BABYLON.GUI {
  42183. /**
  42184. * Class used to create a container panel deployed on the surface of a sphere
  42185. */
  42186. export class SpherePanel extends VolumeBasedPanel {
  42187. /**
  42188. * Gets or sets the radius of the sphere where to project controls (5 by default)
  42189. */
  42190. radius: BABYLON.float;
  42191. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  42192. }
  42193. }
  42194. declare module BABYLON.GUI {
  42195. /**
  42196. * Class used to create a stack panel in 3D on XY plane
  42197. */
  42198. export class StackPanel3D extends Container3D {
  42199. /**
  42200. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  42201. */
  42202. isVertical: boolean;
  42203. /**
  42204. * Gets or sets the distance between elements
  42205. */
  42206. margin: number;
  42207. /**
  42208. * Creates new StackPanel
  42209. * @param isVertical
  42210. */
  42211. constructor(isVertical?: boolean);
  42212. protected _arrangeChildren(): void;
  42213. }
  42214. }
  42215. declare module BABYLON.GUI {
  42216. /**
  42217. * Abstract class used to create a container panel deployed on the surface of a volume
  42218. */
  42219. export abstract class VolumeBasedPanel extends Container3D {
  42220. protected _cellWidth: number;
  42221. protected _cellHeight: number;
  42222. /**
  42223. * Gets or sets the distance between elements
  42224. */
  42225. margin: number;
  42226. /**
  42227. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  42228. * | Value | Type | Description |
  42229. * | ----- | ----------------------------------- | ----------- |
  42230. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  42231. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  42232. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  42233. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  42234. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  42235. */
  42236. orientation: number;
  42237. /**
  42238. * Gets or sets the number of columns requested (10 by default).
  42239. * The panel will automatically compute the number of rows based on number of child controls.
  42240. */
  42241. columns: BABYLON.int;
  42242. /**
  42243. * Gets or sets a the number of rows requested.
  42244. * The panel will automatically compute the number of columns based on number of child controls.
  42245. */
  42246. rows: BABYLON.int;
  42247. /**
  42248. * Creates new VolumeBasedPanel
  42249. */
  42250. constructor();
  42251. protected _arrangeChildren(): void;
  42252. /** Child classes must implement this function to provide correct control positioning */
  42253. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  42254. /** Child classes can implement this function to provide additional processing */
  42255. protected _finalProcessing(): void;
  42256. }
  42257. }
  42258. declare module BABYLON.GUI {
  42259. /** @hidden */
  42260. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  42261. INNERGLOW: boolean;
  42262. BORDER: boolean;
  42263. HOVERLIGHT: boolean;
  42264. TEXTURE: boolean;
  42265. constructor();
  42266. }
  42267. /**
  42268. * Class used to render controls with fluent desgin
  42269. */
  42270. export class FluentMaterial extends BABYLON.PushMaterial {
  42271. /**
  42272. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  42273. */
  42274. innerGlowColorIntensity: number;
  42275. /**
  42276. * Gets or sets the inner glow color (white by default)
  42277. */
  42278. innerGlowColor: BABYLON.Color3;
  42279. /**
  42280. * Gets or sets alpha value (default is 1.0)
  42281. */
  42282. alpha: number;
  42283. /**
  42284. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  42285. */
  42286. albedoColor: BABYLON.Color3;
  42287. /**
  42288. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  42289. */
  42290. renderBorders: boolean;
  42291. /**
  42292. * Gets or sets border width (default is 0.5)
  42293. */
  42294. borderWidth: number;
  42295. /**
  42296. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  42297. */
  42298. edgeSmoothingValue: number;
  42299. /**
  42300. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  42301. */
  42302. borderMinValue: number;
  42303. /**
  42304. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  42305. */
  42306. renderHoverLight: boolean;
  42307. /**
  42308. * Gets or sets the radius used to render the hover light (default is 1.0)
  42309. */
  42310. hoverRadius: number;
  42311. /**
  42312. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  42313. */
  42314. hoverColor: BABYLON.Color4;
  42315. /**
  42316. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  42317. */
  42318. hoverPosition: BABYLON.Vector3;
  42319. /** Gets or sets the texture to use for albedo color */
  42320. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  42321. /**
  42322. * Creates a new Fluent material
  42323. * @param name defines the name of the material
  42324. * @param scene defines the hosting scene
  42325. */
  42326. constructor(name: string, scene: BABYLON.Scene);
  42327. needAlphaBlending(): boolean;
  42328. needAlphaTesting(): boolean;
  42329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  42330. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  42331. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  42332. getActiveTextures(): BABYLON.BaseTexture[];
  42333. hasTexture(texture: BABYLON.BaseTexture): boolean;
  42334. dispose(forceDisposeEffect?: boolean): void;
  42335. clone(name: string): FluentMaterial;
  42336. serialize(): any;
  42337. getClassName(): string;
  42338. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  42339. }
  42340. }
  42341. declare module BABYLON {
  42342. /**
  42343. * Mode that determines the coordinate system to use.
  42344. */
  42345. enum GLTFLoaderCoordinateSystemMode {
  42346. /**
  42347. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  42348. */
  42349. AUTO = 0,
  42350. /**
  42351. * Sets the useRightHandedSystem flag on the scene.
  42352. */
  42353. FORCE_RIGHT_HANDED = 1
  42354. }
  42355. /**
  42356. * Mode that determines what animations will start.
  42357. */
  42358. enum GLTFLoaderAnimationStartMode {
  42359. /**
  42360. * No animation will start.
  42361. */
  42362. NONE = 0,
  42363. /**
  42364. * The first animation will start.
  42365. */
  42366. FIRST = 1,
  42367. /**
  42368. * All animations will start.
  42369. */
  42370. ALL = 2
  42371. }
  42372. /**
  42373. * Interface that contains the data for the glTF asset.
  42374. */
  42375. interface IGLTFLoaderData {
  42376. /**
  42377. * JSON that represents the glTF.
  42378. */
  42379. json: Object;
  42380. /**
  42381. * The BIN chunk of a binary glTF
  42382. */
  42383. bin: Nullable<ArrayBufferView>;
  42384. }
  42385. /**
  42386. * Interface for extending the loader.
  42387. */
  42388. interface IGLTFLoaderExtension {
  42389. /**
  42390. * The name of this extension.
  42391. */
  42392. readonly name: string;
  42393. /**
  42394. * Defines whether this extension is enabled.
  42395. */
  42396. enabled: boolean;
  42397. }
  42398. /**
  42399. * Loader state.
  42400. */
  42401. enum GLTFLoaderState {
  42402. /**
  42403. * The asset is loading.
  42404. */
  42405. LOADING = 0,
  42406. /**
  42407. * The asset is ready for rendering.
  42408. */
  42409. READY = 1,
  42410. /**
  42411. * The asset is completely loaded.
  42412. */
  42413. COMPLETE = 2
  42414. }
  42415. /** @hidden */
  42416. interface IGLTFLoader extends IDisposable {
  42417. readonly state: Nullable<GLTFLoaderState>;
  42418. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string) => Promise<{
  42419. meshes: AbstractMesh[];
  42420. particleSystems: IParticleSystem[];
  42421. skeletons: Skeleton[];
  42422. animationGroups: AnimationGroup[];
  42423. }>;
  42424. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string) => Promise<void>;
  42425. }
  42426. /**
  42427. * File loader for loading glTF files into a scene.
  42428. */
  42429. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  42430. /** @hidden */
  42431. private static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  42432. /** @hidden */
  42433. private static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  42434. /**
  42435. * Raised when the asset has been parsed
  42436. */
  42437. onParsedObservable: Observable<IGLTFLoaderData>;
  42438. private _onParsedObserver;
  42439. /**
  42440. * Raised when the asset has been parsed
  42441. */
  42442. onParsed: (loaderData: IGLTFLoaderData) => void;
  42443. /**
  42444. * 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.
  42445. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  42446. * Defaults to true.
  42447. * @hidden
  42448. */
  42449. static IncrementalLoading: boolean;
  42450. /**
  42451. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  42452. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  42453. * @hidden
  42454. */
  42455. static HomogeneousCoordinates: boolean;
  42456. /**
  42457. * The coordinate system mode. Defaults to AUTO.
  42458. */
  42459. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  42460. /**
  42461. * The animation start mode. Defaults to FIRST.
  42462. */
  42463. animationStartMode: GLTFLoaderAnimationStartMode;
  42464. /**
  42465. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  42466. */
  42467. compileMaterials: boolean;
  42468. /**
  42469. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  42470. */
  42471. useClipPlane: boolean;
  42472. /**
  42473. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  42474. */
  42475. compileShadowGenerators: boolean;
  42476. /**
  42477. * Defines if the Alpha blended materials are only applied as coverage.
  42478. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  42479. * If true, no extra effects are applied to transparent pixels.
  42480. */
  42481. transparencyAsCoverage: boolean;
  42482. /** @hidden */
  42483. /**
  42484. * Function called before loading a url referenced by the asset.
  42485. */
  42486. preprocessUrlAsync: (url: string) => Promise<string>;
  42487. /**
  42488. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  42489. */
  42490. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  42491. private _onMeshLoadedObserver;
  42492. /**
  42493. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  42494. */
  42495. onMeshLoaded: (mesh: AbstractMesh) => void;
  42496. /**
  42497. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  42498. */
  42499. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  42500. private _onTextureLoadedObserver;
  42501. /**
  42502. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  42503. */
  42504. onTextureLoaded: (texture: BaseTexture) => void;
  42505. /**
  42506. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  42507. */
  42508. readonly onMaterialLoadedObservable: Observable<Material>;
  42509. private _onMaterialLoadedObserver;
  42510. /**
  42511. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  42512. */
  42513. onMaterialLoaded: (material: Material) => void;
  42514. /**
  42515. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  42516. */
  42517. readonly onCameraLoadedObservable: Observable<Camera>;
  42518. private _onCameraLoadedObserver;
  42519. /**
  42520. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  42521. */
  42522. onCameraLoaded: (camera: Camera) => void;
  42523. /**
  42524. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  42525. * For assets with LODs, raised when all of the LODs are complete.
  42526. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  42527. */
  42528. readonly onCompleteObservable: Observable<void>;
  42529. private _onCompleteObserver;
  42530. /**
  42531. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  42532. * For assets with LODs, raised when all of the LODs are complete.
  42533. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  42534. */
  42535. onComplete: () => void;
  42536. /**
  42537. * Observable raised when an error occurs.
  42538. */
  42539. readonly onErrorObservable: Observable<any>;
  42540. private _onErrorObserver;
  42541. /**
  42542. * Callback raised when an error occurs.
  42543. */
  42544. onError: (reason: any) => void;
  42545. /**
  42546. * Observable raised after the loader is disposed.
  42547. */
  42548. readonly onDisposeObservable: Observable<void>;
  42549. private _onDisposeObserver;
  42550. /**
  42551. * Callback raised after the loader is disposed.
  42552. */
  42553. onDispose: () => void;
  42554. /**
  42555. * Observable raised after a loader extension is created.
  42556. * Set additional options for a loader extension in this event.
  42557. */
  42558. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  42559. private _onExtensionLoadedObserver;
  42560. /**
  42561. * Callback raised after a loader extension is created.
  42562. */
  42563. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  42564. /**
  42565. * Returns a promise that resolves when the asset is completely loaded.
  42566. * @returns a promise that resolves when the asset is completely loaded.
  42567. */
  42568. whenCompleteAsync(): Promise<void>;
  42569. /**
  42570. * The loader state or null if the loader is not active.
  42571. */
  42572. readonly loaderState: Nullable<GLTFLoaderState>;
  42573. /**
  42574. * Defines if the loader logging is enabled.
  42575. */
  42576. loggingEnabled: boolean;
  42577. /**
  42578. * Defines if the loader should capture performance counters.
  42579. */
  42580. capturePerformanceCounters: boolean;
  42581. private _loader;
  42582. /**
  42583. * Name of the loader ("gltf")
  42584. */
  42585. name: string;
  42586. /**
  42587. * Supported file extensions of the loader (.gltf, .glb)
  42588. */
  42589. extensions: ISceneLoaderPluginExtensions;
  42590. /**
  42591. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  42592. */
  42593. dispose(): void;
  42594. /** @hidden */
  42595. /**
  42596. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  42597. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  42598. * @param scene the scene the meshes should be added to
  42599. * @param data the glTF data to load
  42600. * @param rootUrl root url to load from
  42601. * @param onProgress event that fires when loading progress has occured
  42602. * @param fullName Defines the FQDN of the file to load
  42603. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  42604. */
  42605. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  42606. meshes: AbstractMesh[];
  42607. particleSystems: IParticleSystem[];
  42608. skeletons: Skeleton[];
  42609. animationGroups: AnimationGroup[];
  42610. }>;
  42611. /**
  42612. * Imports all objects from the loaded glTF data and adds them to the scene
  42613. * @param scene the scene the objects should be added to
  42614. * @param data the glTF data to load
  42615. * @param rootUrl root url to load from
  42616. * @param onProgress event that fires when loading progress has occured
  42617. * @param fullName Defines the FQDN of the file to load
  42618. * @returns a promise which completes when objects have been loaded to the scene
  42619. */
  42620. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  42621. /**
  42622. * Load into an asset container.
  42623. * @param scene The scene to load into
  42624. * @param data The data to import
  42625. * @param rootUrl The root url for scene and resources
  42626. * @param onProgress The callback when the load progresses
  42627. * @param fullName Defines the FQDN of the file to load
  42628. * @returns The loaded asset container
  42629. */
  42630. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  42631. /**
  42632. * If the data string can be loaded directly.
  42633. * @param data string contianing the file data
  42634. * @returns if the data can be loaded directly
  42635. */
  42636. canDirectLoad(data: string): boolean;
  42637. /**
  42638. * Rewrites a url by combining a root url and response url.
  42639. */
  42640. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  42641. /**
  42642. * Instantiates a glTF file loader plugin.
  42643. * @returns the created plugin
  42644. */
  42645. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42646. private _parse;
  42647. private _getLoader;
  42648. private _parseBinary;
  42649. private _parseV1;
  42650. private _parseV2;
  42651. private static _parseVersion;
  42652. private static _compareVersion;
  42653. private static _decodeBufferToText;
  42654. private static readonly _logSpaces;
  42655. private _logIndentLevel;
  42656. private _loggingEnabled;
  42657. /** @hidden */
  42658. /** @hidden */
  42659. /** @hidden */
  42660. private _logEnabled;
  42661. private _logDisabled;
  42662. private _capturePerformanceCounters;
  42663. /** @hidden */
  42664. /** @hidden */
  42665. private _startPerformanceCounterEnabled;
  42666. private _startPerformanceCounterDisabled;
  42667. private _endPerformanceCounterEnabled;
  42668. private _endPerformanceCounterDisabled;
  42669. }
  42670. }
  42671. declare module BABYLON.GLTF2 {
  42672. /**
  42673. * Loader interface with an index field.
  42674. */
  42675. interface IArrayItem {
  42676. /**
  42677. * The index of this item in the array.
  42678. */
  42679. index: number;
  42680. }
  42681. /**
  42682. * Loader interface with additional members.
  42683. */
  42684. interface ILoaderAccessor extends IAccessor, IArrayItem {
  42685. /** @hidden */
  42686. /** @hidden */
  42687. }
  42688. /**
  42689. * Loader interface with additional members.
  42690. */
  42691. interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem {
  42692. }
  42693. /** @hidden */
  42694. interface _ILoaderAnimationSamplerData {
  42695. input: Float32Array;
  42696. interpolation: AnimationSamplerInterpolation;
  42697. output: Float32Array;
  42698. }
  42699. /**
  42700. * Loader interface with additional members.
  42701. */
  42702. interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem {
  42703. /** @hidden */
  42704. }
  42705. /**
  42706. * Loader interface with additional members.
  42707. */
  42708. interface ILoaderAnimation extends IAnimation, IArrayItem {
  42709. channels: ILoaderAnimationChannel[];
  42710. samplers: ILoaderAnimationSampler[];
  42711. /** @hidden */
  42712. }
  42713. /**
  42714. * Loader interface with additional members.
  42715. */
  42716. interface ILoaderBuffer extends IBuffer, IArrayItem {
  42717. /** @hidden */
  42718. }
  42719. /**
  42720. * Loader interface with additional members.
  42721. */
  42722. interface ILoaderBufferView extends IBufferView, IArrayItem {
  42723. /** @hidden */
  42724. /** @hidden */
  42725. }
  42726. /**
  42727. * Loader interface with additional members.
  42728. */
  42729. interface ILoaderCamera extends ICamera, IArrayItem {
  42730. }
  42731. /**
  42732. * Loader interface with additional members.
  42733. */
  42734. interface ILoaderImage extends IImage, IArrayItem {
  42735. /** @hidden */
  42736. }
  42737. /**
  42738. * Loader interface with additional members.
  42739. */
  42740. interface ILoaderMaterialNormalTextureInfo extends IMaterialNormalTextureInfo, ILoaderTextureInfo {
  42741. }
  42742. /**
  42743. * Loader interface with additional members.
  42744. */
  42745. interface ILoaderMaterialOcclusionTextureInfo extends IMaterialOcclusionTextureInfo, ILoaderTextureInfo {
  42746. }
  42747. /**
  42748. * Loader interface with additional members.
  42749. */
  42750. interface ILoaderMaterialPbrMetallicRoughness extends IMaterialPbrMetallicRoughness {
  42751. baseColorTexture?: ILoaderTextureInfo;
  42752. metallicRoughnessTexture?: ILoaderTextureInfo;
  42753. }
  42754. /**
  42755. * Loader interface with additional members.
  42756. */
  42757. interface ILoaderMaterial extends IMaterial, IArrayItem {
  42758. pbrMetallicRoughness?: ILoaderMaterialPbrMetallicRoughness;
  42759. normalTexture?: ILoaderMaterialNormalTextureInfo;
  42760. occlusionTexture?: ILoaderMaterialOcclusionTextureInfo;
  42761. emissiveTexture?: ILoaderTextureInfo;
  42762. /** @hidden */
  42763. ;
  42764. };
  42765. }
  42766. /**
  42767. * Loader interface with additional members.
  42768. */
  42769. interface ILoaderMesh extends IMesh, IArrayItem {
  42770. primitives: ILoaderMeshPrimitive[];
  42771. }
  42772. /**
  42773. * Loader interface with additional members.
  42774. */
  42775. interface ILoaderMeshPrimitive extends IMeshPrimitive, IArrayItem {
  42776. }
  42777. /**
  42778. * Loader interface with additional members.
  42779. */
  42780. interface ILoaderNode extends INode, IArrayItem {
  42781. /**
  42782. * The parent glTF node.
  42783. */
  42784. parent?: ILoaderNode;
  42785. /** @hidden */
  42786. /** @hidden */
  42787. /** @hidden */
  42788. /** @hidden */
  42789. }
  42790. /** @hidden */
  42791. interface _ILoaderSamplerData {
  42792. noMipMaps: boolean;
  42793. samplingMode: number;
  42794. wrapU: number;
  42795. wrapV: number;
  42796. }
  42797. /**
  42798. * Loader interface with additional members.
  42799. */
  42800. interface ILoaderSampler extends ISampler, IArrayItem {
  42801. /** @hidden */
  42802. }
  42803. /**
  42804. * Loader interface with additional members.
  42805. */
  42806. interface ILoaderScene extends IScene, IArrayItem {
  42807. }
  42808. /**
  42809. * Loader interface with additional members.
  42810. */
  42811. interface ILoaderSkin extends ISkin, IArrayItem {
  42812. /** @hidden */
  42813. /** @hidden */
  42814. }
  42815. /**
  42816. * Loader interface with additional members.
  42817. */
  42818. interface ILoaderTexture extends ITexture, IArrayItem {
  42819. }
  42820. /**
  42821. * Loader interface with additional members.
  42822. */
  42823. interface ILoaderTextureInfo extends ITextureInfo {
  42824. }
  42825. /**
  42826. * Loader interface with additional members.
  42827. */
  42828. interface ILoaderGLTF extends IGLTF {
  42829. accessors?: ILoaderAccessor[];
  42830. animations?: ILoaderAnimation[];
  42831. buffers?: ILoaderBuffer[];
  42832. bufferViews?: ILoaderBufferView[];
  42833. cameras?: ILoaderCamera[];
  42834. images?: ILoaderImage[];
  42835. materials?: ILoaderMaterial[];
  42836. meshes?: ILoaderMesh[];
  42837. nodes?: ILoaderNode[];
  42838. samplers?: ILoaderSampler[];
  42839. scenes?: ILoaderScene[];
  42840. skins?: ILoaderSkin[];
  42841. textures?: ILoaderTexture[];
  42842. }
  42843. }
  42844. /**
  42845. * Defines the module for importing and exporting glTF 2.0 assets
  42846. */
  42847. declare module BABYLON.GLTF2 {
  42848. /**
  42849. * Helper class for working with arrays when loading the glTF asset
  42850. */
  42851. class ArrayItem {
  42852. /**
  42853. * Gets an item from the given array.
  42854. * @param context The context when loading the asset
  42855. * @param array The array to get the item from
  42856. * @param index The index to the array
  42857. * @returns The array item
  42858. */
  42859. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  42860. /**
  42861. * Assign an `index` field to each item of the given array.
  42862. * @param array The array of items
  42863. */
  42864. static Assign(array?: IArrayItem[]): void;
  42865. }
  42866. /**
  42867. * The glTF 2.0 loader
  42868. */
  42869. class GLTFLoader implements IGLTFLoader {
  42870. /** The glTF object parsed from the JSON. */
  42871. gltf: ILoaderGLTF;
  42872. /** The Babylon scene when loading the asset. */
  42873. babylonScene: Scene;
  42874. /** @hidden */
  42875. private _disposed;
  42876. private _parent;
  42877. private _state;
  42878. private _extensions;
  42879. private _rootUrl;
  42880. private _fullName;
  42881. private _rootBabylonMesh;
  42882. private _defaultBabylonMaterialData;
  42883. private _progressCallback?;
  42884. private _requests;
  42885. private static readonly _DefaultSampler;
  42886. private static _ExtensionNames;
  42887. private static _ExtensionFactories;
  42888. /**
  42889. * Registers a loader extension.
  42890. * @param name The name of the loader extension.
  42891. * @param factory The factory function that creates the loader extension.
  42892. */
  42893. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  42894. /**
  42895. * Unregisters a loader extension.
  42896. * @param name The name of the loader extenion.
  42897. * @returns A boolean indicating whether the extension has been unregistered
  42898. */
  42899. static UnregisterExtension(name: string): boolean;
  42900. /**
  42901. * Gets the loader state.
  42902. */
  42903. readonly state: Nullable<GLTFLoaderState>;
  42904. /** @hidden */
  42905. constructor(parent: GLTFFileLoader);
  42906. /** @hidden */
  42907. dispose(): void;
  42908. /** @hidden */
  42909. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  42910. meshes: AbstractMesh[];
  42911. particleSystems: IParticleSystem[];
  42912. skeletons: Skeleton[];
  42913. animationGroups: AnimationGroup[];
  42914. }>;
  42915. /** @hidden */
  42916. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  42917. private _loadAsync;
  42918. private _loadData;
  42919. private _setupData;
  42920. private _loadExtensions;
  42921. private _checkExtensions;
  42922. private _setState;
  42923. private _createRootNode;
  42924. /**
  42925. * Loads a glTF scene.
  42926. * @param context The context when loading the asset
  42927. * @param scene The glTF scene property
  42928. * @returns A promise that resolves when the load is complete
  42929. */
  42930. loadSceneAsync(context: string, scene: ILoaderScene): Promise<void>;
  42931. private _forEachPrimitive;
  42932. private _getMeshes;
  42933. private _getSkeletons;
  42934. private _getAnimationGroups;
  42935. private _startAnimations;
  42936. /**
  42937. * Loads a glTF node.
  42938. * @param context The context when loading the asset
  42939. * @param node The glTF node property
  42940. * @param assign A function called synchronously after parsing the glTF properties
  42941. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  42942. */
  42943. loadNodeAsync(context: string, node: ILoaderNode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
  42944. private _loadMeshAsync;
  42945. private _loadMeshPrimitiveAsync;
  42946. private _loadVertexDataAsync;
  42947. private _createMorphTargets;
  42948. private _loadMorphTargetsAsync;
  42949. private _loadMorphTargetVertexDataAsync;
  42950. private static _LoadTransform;
  42951. private _loadSkinAsync;
  42952. private _loadBones;
  42953. private _loadBone;
  42954. private _loadSkinInverseBindMatricesDataAsync;
  42955. private _updateBoneMatrices;
  42956. private _getNodeMatrix;
  42957. /**
  42958. * Loads a glTF camera.
  42959. * @param context The context when loading the asset
  42960. * @param camera The glTF camera property
  42961. * @param assign A function called synchronously after parsing the glTF properties
  42962. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  42963. */
  42964. loadCameraAsync(context: string, camera: ILoaderCamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  42965. private _loadAnimationsAsync;
  42966. /**
  42967. * Loads a glTF animation.
  42968. * @param context The context when loading the asset
  42969. * @param animation The glTF animation property
  42970. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  42971. */
  42972. loadAnimationAsync(context: string, animation: ILoaderAnimation): Promise<AnimationGroup>;
  42973. private _loadAnimationChannelAsync;
  42974. private _loadAnimationSamplerAsync;
  42975. private _loadBufferAsync;
  42976. /**
  42977. * Loads a glTF buffer view.
  42978. * @param context The context when loading the asset
  42979. * @param bufferView The glTF buffer view property
  42980. * @returns A promise that resolves with the loaded data when the load is complete
  42981. */
  42982. loadBufferViewAsync(context: string, bufferView: ILoaderBufferView): Promise<ArrayBufferView>;
  42983. private _loadIndicesAccessorAsync;
  42984. private _loadFloatAccessorAsync;
  42985. private _loadVertexBufferViewAsync;
  42986. private _loadVertexAccessorAsync;
  42987. private _loadMaterialMetallicRoughnessPropertiesAsync;
  42988. /** @hidden */
  42989. private _createDefaultMaterial;
  42990. /**
  42991. * Creates a Babylon material from a glTF material.
  42992. * @param context The context when loading the asset
  42993. * @param material The glTF material property
  42994. * @param babylonDrawMode The draw mode for the Babylon material
  42995. * @returns The Babylon material
  42996. */
  42997. createMaterial(context: string, material: ILoaderMaterial, babylonDrawMode: number): Material;
  42998. /**
  42999. * Loads properties from a glTF material into a Babylon material.
  43000. * @param context The context when loading the asset
  43001. * @param material The glTF material property
  43002. * @param babylonMaterial The Babylon material
  43003. * @returns A promise that resolves when the load is complete
  43004. */
  43005. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Promise<void>;
  43006. /**
  43007. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  43008. * @param context The context when loading the asset
  43009. * @param material The glTF material property
  43010. * @param babylonMaterial The Babylon material
  43011. * @returns A promise that resolves when the load is complete
  43012. */
  43013. loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Promise<void>;
  43014. /**
  43015. * Loads the alpha properties from a glTF material into a Babylon material.
  43016. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  43017. * @param context The context when loading the asset
  43018. * @param material The glTF material property
  43019. * @param babylonMaterial The Babylon material
  43020. */
  43021. loadMaterialAlphaProperties(context: string, material: ILoaderMaterial, babylonMaterial: Material): void;
  43022. /**
  43023. * Loads a glTF texture info.
  43024. * @param context The context when loading the asset
  43025. * @param textureInfo The glTF texture info property
  43026. * @param assign A function called synchronously after parsing the glTF properties
  43027. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  43028. */
  43029. loadTextureInfoAsync(context: string, textureInfo: ILoaderTextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  43030. private _loadTextureAsync;
  43031. private _loadSampler;
  43032. /**
  43033. * Loads a glTF image.
  43034. * @param context The context when loading the asset
  43035. * @param image The glTF image property
  43036. * @returns A promise that resolves with the loaded data when the load is complete
  43037. */
  43038. loadImageAsync(context: string, image: ILoaderImage): Promise<ArrayBufferView>;
  43039. /**
  43040. * Loads a glTF uri.
  43041. * @param context The context when loading the asset
  43042. * @param uri The base64 or relative uri
  43043. * @returns A promise that resolves with the loaded data when the load is complete
  43044. */
  43045. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  43046. private _onProgress;
  43047. private static _GetTextureWrapMode;
  43048. private static _GetTextureSamplingMode;
  43049. private static _GetTypedArray;
  43050. private static _GetNumComponents;
  43051. private static _ValidateUri;
  43052. private static _GetDrawMode;
  43053. private _compileMaterialsAsync;
  43054. private _compileShadowGeneratorsAsync;
  43055. private _forEachExtensions;
  43056. private _applyExtensions;
  43057. private _extensionsOnLoading;
  43058. private _extensionsOnReady;
  43059. private _extensionsLoadSceneAsync;
  43060. private _extensionsLoadNodeAsync;
  43061. private _extensionsLoadCameraAsync;
  43062. private _extensionsLoadVertexDataAsync;
  43063. private _extensionsLoadMaterialAsync;
  43064. private _extensionsCreateMaterial;
  43065. private _extensionsLoadMaterialPropertiesAsync;
  43066. private _extensionsLoadTextureInfoAsync;
  43067. private _extensionsLoadAnimationAsync;
  43068. private _extensionsLoadUriAsync;
  43069. /**
  43070. * Helper method called by a loader extension to load an glTF extension.
  43071. * @param context The context when loading the asset
  43072. * @param property The glTF property to load the extension from
  43073. * @param extensionName The name of the extension to load
  43074. * @param actionAsync The action to run
  43075. * @returns The promise returned by actionAsync or null if the extension does not exist
  43076. */
  43077. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  43078. /**
  43079. * Helper method called by a loader extension to load a glTF extra.
  43080. * @param context The context when loading the asset
  43081. * @param property The glTF property to load the extra from
  43082. * @param extensionName The name of the extension to load
  43083. * @param actionAsync The action to run
  43084. * @returns The promise returned by actionAsync or null if the extra does not exist
  43085. */
  43086. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  43087. /**
  43088. * Increments the indentation level and logs a message.
  43089. * @param message The message to log
  43090. */
  43091. logOpen(message: string): void;
  43092. /**
  43093. * Decrements the indentation level.
  43094. */
  43095. logClose(): void;
  43096. /**
  43097. * Logs a message
  43098. * @param message The message to log
  43099. */
  43100. log(message: string): void;
  43101. /**
  43102. * Starts a performance counter.
  43103. * @param counterName The name of the performance counter
  43104. */
  43105. startPerformanceCounter(counterName: string): void;
  43106. /**
  43107. * Ends a performance counter.
  43108. * @param counterName The name of the performance counter
  43109. */
  43110. endPerformanceCounter(counterName: string): void;
  43111. }
  43112. }
  43113. declare module BABYLON.GLTF2 {
  43114. /**
  43115. * Interface for a glTF loader extension.
  43116. */
  43117. interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  43118. /**
  43119. * Called after the loader state changes to LOADING.
  43120. */
  43121. onLoading?(): void;
  43122. /**
  43123. * Called after the loader state changes to READY.
  43124. */
  43125. onReady?(): void;
  43126. /**
  43127. * Define this method to modify the default behavior when loading scenes.
  43128. * @param context The context when loading the asset
  43129. * @param scene The glTF scene property
  43130. * @returns A promise that resolves when the load is complete or null if not handled
  43131. */
  43132. loadSceneAsync?(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  43133. /**
  43134. * Define this method to modify the default behavior when loading nodes.
  43135. * @param context The context when loading the asset
  43136. * @param node The glTF node property
  43137. * @param assign A function called synchronously after parsing the glTF properties
  43138. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  43139. */
  43140. loadNodeAsync?(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  43141. /**
  43142. * Define this method to modify the default behavior when loading cameras.
  43143. * @param context The context when loading the asset
  43144. * @param camera The glTF camera property
  43145. * @param assign A function called synchronously after parsing the glTF properties
  43146. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  43147. */
  43148. loadCameraAsync?(context: string, camera: ILoaderCamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  43149. /**
  43150. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  43151. * @param context The context when loading the asset
  43152. * @param primitive The glTF mesh primitive property
  43153. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  43154. */
  43155. /**
  43156. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  43157. * @param context The context when loading the asset
  43158. * @param material The glTF material property
  43159. * @param assign A function called synchronously after parsing the glTF properties
  43160. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  43161. */
  43162. /**
  43163. * Define this method to modify the default behavior when creating materials.
  43164. * @param context The context when loading the asset
  43165. * @param material The glTF material property
  43166. * @param babylonDrawMode The draw mode for the Babylon material
  43167. * @returns The Babylon material or null if not handled
  43168. */
  43169. createMaterial?(context: string, material: ILoaderMaterial, babylonDrawMode: number): Nullable<Material>;
  43170. /**
  43171. * Define this method to modify the default behavior when loading material properties.
  43172. * @param context The context when loading the asset
  43173. * @param material The glTF material property
  43174. * @param babylonMaterial The Babylon material
  43175. * @returns A promise that resolves when the load is complete or null if not handled
  43176. */
  43177. loadMaterialPropertiesAsync?(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  43178. /**
  43179. * Define this method to modify the default behavior when loading texture infos.
  43180. * @param context The context when loading the asset
  43181. * @param textureInfo The glTF texture info property
  43182. * @param assign A function called synchronously after parsing the glTF properties
  43183. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  43184. */
  43185. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  43186. /**
  43187. * Define this method to modify the default behavior when loading animations.
  43188. * @param context The context when loading the asset
  43189. * @param animation The glTF animation property
  43190. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  43191. */
  43192. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  43193. /**
  43194. * Define this method to modify the default behavior when loading uris.
  43195. * @param context The context when loading the asset
  43196. * @param uri The uri to load
  43197. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  43198. */
  43199. }
  43200. }
  43201. /**
  43202. * Defines the module for the built-in glTF 2.0 loader extensions.
  43203. */
  43204. declare module BABYLON.GLTF2.Extensions {
  43205. }
  43206. declare module BABYLON.GLTF2.Extensions {
  43207. /**
  43208. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  43209. */
  43210. class MSFT_audio_emitter implements IGLTFLoaderExtension {
  43211. /** The name of this extension. */
  43212. readonly name: string;
  43213. /** Defines whether this extension is enabled. */
  43214. enabled: boolean;
  43215. private _loader;
  43216. private _clips;
  43217. private _emitters;
  43218. /** @hidden */
  43219. constructor(loader: GLTFLoader);
  43220. /** @hidden */
  43221. dispose(): void;
  43222. /** @hidden */
  43223. onLoading(): void;
  43224. /** @hidden */
  43225. loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  43226. /** @hidden */
  43227. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  43228. /** @hidden */
  43229. loadAnimationAsync(context: string, animation: ILoaderAnimation): Nullable<Promise<AnimationGroup>>;
  43230. private _loadClipAsync;
  43231. private _loadEmitterAsync;
  43232. private _getEventAction;
  43233. private _loadAnimationEventAsync;
  43234. }
  43235. }
  43236. declare module BABYLON.GLTF2.Extensions {
  43237. /**
  43238. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  43239. */
  43240. class MSFT_lod implements IGLTFLoaderExtension {
  43241. /** The name of this extension. */
  43242. readonly name: string;
  43243. /** Defines whether this extension is enabled. */
  43244. enabled: boolean;
  43245. /**
  43246. * Maximum number of LODs to load, starting from the lowest LOD.
  43247. */
  43248. maxLODsToLoad: number;
  43249. /**
  43250. * Observable raised when all node LODs of one level are loaded.
  43251. * The event data is the index of the loaded LOD starting from zero.
  43252. * Dispose the loader to cancel the loading of the next level of LODs.
  43253. */
  43254. onNodeLODsLoadedObservable: Observable<number>;
  43255. /**
  43256. * Observable raised when all material LODs of one level are loaded.
  43257. * The event data is the index of the loaded LOD starting from zero.
  43258. * Dispose the loader to cancel the loading of the next level of LODs.
  43259. */
  43260. onMaterialLODsLoadedObservable: Observable<number>;
  43261. private _loader;
  43262. private _nodeIndexLOD;
  43263. private _nodeSignalLODs;
  43264. private _nodePromiseLODs;
  43265. private _materialIndexLOD;
  43266. private _materialSignalLODs;
  43267. private _materialPromiseLODs;
  43268. /** @hidden */
  43269. constructor(loader: GLTFLoader);
  43270. /** @hidden */
  43271. dispose(): void;
  43272. /** @hidden */
  43273. onReady(): void;
  43274. /** @hidden */
  43275. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  43276. /** @hidden */
  43277. /** @hidden */
  43278. /**
  43279. * Gets an array of LOD properties from lowest to highest.
  43280. */
  43281. private _getLODs;
  43282. private _disposeUnusedMaterials;
  43283. }
  43284. }
  43285. declare module BABYLON.GLTF2.Extensions {
  43286. /** @hidden */
  43287. class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  43288. readonly name: string;
  43289. enabled: boolean;
  43290. private _loader;
  43291. constructor(loader: GLTFLoader);
  43292. dispose(): void;
  43293. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  43294. }
  43295. }
  43296. declare module BABYLON.GLTF2.Extensions {
  43297. /** @hidden */
  43298. class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  43299. readonly name: string;
  43300. enabled: boolean;
  43301. private _loader;
  43302. constructor(loader: GLTFLoader);
  43303. dispose(): void;
  43304. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  43305. }
  43306. }
  43307. declare module BABYLON.GLTF2.Extensions {
  43308. /**
  43309. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  43310. */
  43311. class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  43312. /** The name of this extension. */
  43313. readonly name: string;
  43314. /** Defines whether this extension is enabled. */
  43315. enabled: boolean;
  43316. private _loader;
  43317. private _dracoCompression?;
  43318. /** @hidden */
  43319. constructor(loader: GLTFLoader);
  43320. /** @hidden */
  43321. dispose(): void;
  43322. /** @hidden */
  43323. }
  43324. }
  43325. declare module BABYLON.GLTF2.Extensions {
  43326. /**
  43327. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  43328. */
  43329. class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  43330. /** The name of this extension. */
  43331. readonly name: string;
  43332. /** Defines whether this extension is enabled. */
  43333. enabled: boolean;
  43334. private _loader;
  43335. /** @hidden */
  43336. constructor(loader: GLTFLoader);
  43337. /** @hidden */
  43338. dispose(): void;
  43339. /** @hidden */
  43340. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  43341. private _loadSpecularGlossinessPropertiesAsync;
  43342. }
  43343. }
  43344. declare module BABYLON.GLTF2.Extensions {
  43345. /**
  43346. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  43347. */
  43348. class KHR_materials_unlit implements IGLTFLoaderExtension {
  43349. /** The name of this extension. */
  43350. readonly name: string;
  43351. /** Defines whether this extension is enabled. */
  43352. enabled: boolean;
  43353. private _loader;
  43354. /** @hidden */
  43355. constructor(loader: GLTFLoader);
  43356. /** @hidden */
  43357. dispose(): void;
  43358. /** @hidden */
  43359. loadMaterialPropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  43360. private _loadUnlitPropertiesAsync;
  43361. }
  43362. }
  43363. declare module BABYLON.GLTF2.Extensions {
  43364. /**
  43365. * [Specification](https://github.com/MiiBond/glTF/tree/khr_lights_v1/extensions/Khronos/KHR_lights) (Experimental)
  43366. */
  43367. class KHR_lights implements IGLTFLoaderExtension {
  43368. /** The name of this extension. */
  43369. readonly name: string;
  43370. /** Defines whether this extension is enabled. */
  43371. enabled: boolean;
  43372. private _loader;
  43373. private _lights?;
  43374. /** @hidden */
  43375. constructor(loader: GLTFLoader);
  43376. /** @hidden */
  43377. dispose(): void;
  43378. /** @hidden */
  43379. onLoading(): void;
  43380. /** @hidden */
  43381. loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  43382. /** @hidden */
  43383. loadNodeAsync(context: string, node: ILoaderNode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  43384. }
  43385. }
  43386. declare module BABYLON.GLTF2.Extensions {
  43387. /**
  43388. * [Specification](https://github.com/AltspaceVR/glTF/blob/avr-sampler-offset-tile/extensions/2.0/Khronos/KHR_texture_transform/README.md) (Experimental)
  43389. */
  43390. class KHR_texture_transform implements IGLTFLoaderExtension {
  43391. /** The name of this extension. */
  43392. readonly name: string;
  43393. /** Defines whether this extension is enabled. */
  43394. enabled: boolean;
  43395. private _loader;
  43396. /** @hidden */
  43397. constructor(loader: GLTFLoader);
  43398. /** @hidden */
  43399. dispose(): void;
  43400. /** @hidden */
  43401. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  43402. }
  43403. }
  43404. declare module BABYLON.GLTF2.Extensions {
  43405. /**
  43406. * [Specification](TODO) (Experimental)
  43407. */
  43408. class EXT_lights_imageBased implements IGLTFLoaderExtension {
  43409. /** The name of this extension. */
  43410. readonly name: string;
  43411. /** Defines whether this extension is enabled. */
  43412. enabled: boolean;
  43413. private _loader;
  43414. private _lights?;
  43415. /** @hidden */
  43416. constructor(loader: GLTFLoader);
  43417. /** @hidden */
  43418. dispose(): void;
  43419. /** @hidden */
  43420. onLoading(): void;
  43421. /** @hidden */
  43422. loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
  43423. private _loadLightAsync;
  43424. }
  43425. }
  43426. declare module BABYLON {
  43427. /**
  43428. * Holds a collection of exporter options and parameters
  43429. */
  43430. interface IExportOptions {
  43431. /**
  43432. * Function which indicates whether a babylon mesh should be exported or not
  43433. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  43434. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  43435. */
  43436. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  43437. /**
  43438. * The sample rate to bake animation curves
  43439. */
  43440. animationSampleRate?: number;
  43441. }
  43442. /**
  43443. * Class for generating glTF data from a Babylon scene.
  43444. */
  43445. class GLTF2Export {
  43446. /**
  43447. * Exports the geometry of the scene to .gltf file format asynchronously
  43448. * @param scene Babylon scene with scene hierarchy information
  43449. * @param filePrefix File prefix to use when generating the glTF file
  43450. * @param options Exporter options
  43451. * @returns Returns an object with a .gltf file and associates texture names
  43452. * as keys and their data and paths as values
  43453. */
  43454. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  43455. /**
  43456. * Exports the geometry of the scene to .glb file format asychronously
  43457. * @param scene Babylon scene with scene hierarchy information
  43458. * @param filePrefix File prefix to use when generating glb file
  43459. * @param options Exporter options
  43460. * @returns Returns an object with a .glb filename as key and data as value
  43461. */
  43462. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  43463. }
  43464. }
  43465. declare module BABYLON.GLTF2 {
  43466. /**
  43467. * Converts Babylon Scene into glTF 2.0.
  43468. * @hidden
  43469. */
  43470. class _Exporter {
  43471. /**
  43472. * Stores all generated buffer views, which represents views into the main glTF buffer data
  43473. */
  43474. private _bufferViews;
  43475. /**
  43476. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  43477. */
  43478. private _accessors;
  43479. /**
  43480. * Stores all the generated nodes, which contains transform and/or mesh information per node
  43481. */
  43482. private _nodes;
  43483. /**
  43484. * Stores the glTF asset information, which represents the glTF version and this file generator
  43485. */
  43486. private _asset;
  43487. /**
  43488. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  43489. */
  43490. private _scenes;
  43491. /**
  43492. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  43493. */
  43494. private _meshes;
  43495. /**
  43496. * Stores all the generated material information, which represents the appearance of each primitive
  43497. */
  43498. ;
  43499. /**
  43500. * Stores all the generated texture information, which is referenced by glTF materials
  43501. */
  43502. /**
  43503. * Stores all the generated image information, which is referenced by glTF textures
  43504. */
  43505. /**
  43506. * Stores all the texture samplers
  43507. */
  43508. /**
  43509. * Stores all the generated animation samplers, which is referenced by glTF animations
  43510. */
  43511. /**
  43512. * Stores the animations for glTF models
  43513. */
  43514. private _animations;
  43515. /**
  43516. * Stores the total amount of bytes stored in the glTF buffer
  43517. */
  43518. private _totalByteLength;
  43519. /**
  43520. * Stores a reference to the Babylon scene containing the source geometry and material information
  43521. */
  43522. private _babylonScene;
  43523. /**
  43524. * Stores a map of the image data, where the key is the file name and the value
  43525. * is the image data
  43526. */
  43527. ;
  43528. };
  43529. /**
  43530. * Stores a map of the unique id of a node to its index in the node array
  43531. */
  43532. private _nodeMap;
  43533. /**
  43534. * Specifies if the Babylon scene should be converted to right-handed on export
  43535. */
  43536. private _convertToRightHandedSystem;
  43537. /**
  43538. * Baked animation sample rate
  43539. */
  43540. private _animationSampleRate;
  43541. /**
  43542. * Callback which specifies if a transform node should be exported or not
  43543. */
  43544. private _shouldExportTransformNode;
  43545. private _localEngine;
  43546. private _glTFMaterialExporter;
  43547. /**
  43548. * Creates a glTF Exporter instance, which can accept optional exporter options
  43549. * @param babylonScene Babylon scene object
  43550. * @param options Options to modify the behavior of the exporter
  43551. */
  43552. constructor(babylonScene: Scene, options?: IExportOptions);
  43553. /**
  43554. * Lazy load a local engine with premultiplied alpha set to false
  43555. */
  43556. private reorderIndicesBasedOnPrimitiveMode;
  43557. /**
  43558. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  43559. * clock-wise during export to glTF
  43560. * @param submesh BabylonJS submesh
  43561. * @param primitiveMode Primitive mode of the mesh
  43562. * @param sideOrientation the winding order of the submesh
  43563. * @param vertexBufferKind The type of vertex attribute
  43564. * @param meshAttributeArray The vertex attribute data
  43565. * @param byteOffset The offset to the binary data
  43566. * @param binaryWriter The binary data for the glTF file
  43567. */
  43568. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  43569. /**
  43570. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  43571. * clock-wise during export to glTF
  43572. * @param submesh BabylonJS submesh
  43573. * @param primitiveMode Primitive mode of the mesh
  43574. * @param sideOrientation the winding order of the submesh
  43575. * @param vertexBufferKind The type of vertex attribute
  43576. * @param meshAttributeArray The vertex attribute data
  43577. * @param byteOffset The offset to the binary data
  43578. * @param binaryWriter The binary data for the glTF file
  43579. */
  43580. private reorderTriangleFillMode;
  43581. /**
  43582. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  43583. * clock-wise during export to glTF
  43584. * @param submesh BabylonJS submesh
  43585. * @param primitiveMode Primitive mode of the mesh
  43586. * @param sideOrientation the winding order of the submesh
  43587. * @param vertexBufferKind The type of vertex attribute
  43588. * @param meshAttributeArray The vertex attribute data
  43589. * @param byteOffset The offset to the binary data
  43590. * @param binaryWriter The binary data for the glTF file
  43591. */
  43592. private reorderTriangleStripDrawMode;
  43593. /**
  43594. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  43595. * clock-wise during export to glTF
  43596. * @param submesh BabylonJS submesh
  43597. * @param primitiveMode Primitive mode of the mesh
  43598. * @param sideOrientation the winding order of the submesh
  43599. * @param vertexBufferKind The type of vertex attribute
  43600. * @param meshAttributeArray The vertex attribute data
  43601. * @param byteOffset The offset to the binary data
  43602. * @param binaryWriter The binary data for the glTF file
  43603. */
  43604. private reorderTriangleFanMode;
  43605. /**
  43606. * Writes the vertex attribute data to binary
  43607. * @param vertices The vertices to write to the binary writer
  43608. * @param byteOffset The offset into the binary writer to overwrite binary data
  43609. * @param vertexAttributeKind The vertex attribute type
  43610. * @param meshAttributeArray The vertex attribute data
  43611. * @param binaryWriter The writer containing the binary data
  43612. */
  43613. private writeVertexAttributeData;
  43614. /**
  43615. * Writes mesh attribute data to a data buffer
  43616. * Returns the bytelength of the data
  43617. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  43618. * @param meshAttributeArray Array containing the attribute data
  43619. * @param binaryWriter The buffer to write the binary data to
  43620. * @param indices Used to specify the order of the vertex data
  43621. */
  43622. private writeAttributeData;
  43623. /**
  43624. * Generates glTF json data
  43625. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  43626. * @param glTFPrefix Text to use when prefixing a glTF file
  43627. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  43628. * @returns json data as string
  43629. */
  43630. private generateJSON;
  43631. /**
  43632. * Generates data for .gltf and .bin files based on the glTF prefix string
  43633. * @param glTFPrefix Text to use when prefixing a glTF file
  43634. * @returns GLTFData with glTF file data
  43635. */
  43636. /**
  43637. * Creates a binary buffer for glTF
  43638. * @returns array buffer for binary data
  43639. */
  43640. private _generateBinaryAsync;
  43641. /**
  43642. * Pads the number to a multiple of 4
  43643. * @param num number to pad
  43644. * @returns padded number
  43645. */
  43646. private _getPadding;
  43647. /**
  43648. * Generates a glb file from the json and binary data
  43649. * Returns an object with the glb file name as the key and data as the value
  43650. * @param glTFPrefix
  43651. * @returns object with glb filename as key and data as value
  43652. */
  43653. /**
  43654. * Sets the TRS for each node
  43655. * @param node glTF Node for storing the transformation data
  43656. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  43657. */
  43658. private setNodeTransformation;
  43659. private getVertexBufferFromMesh;
  43660. /**
  43661. * Creates a bufferview based on the vertices type for the Babylon mesh
  43662. * @param kind Indicates the type of vertices data
  43663. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  43664. * @param binaryWriter The buffer to write the bufferview data to
  43665. */
  43666. private createBufferViewKind;
  43667. /**
  43668. * The primitive mode of the Babylon mesh
  43669. * @param babylonMesh The BabylonJS mesh
  43670. */
  43671. private getMeshPrimitiveMode;
  43672. /**
  43673. * Sets the primitive mode of the glTF mesh primitive
  43674. * @param meshPrimitive glTF mesh primitive
  43675. * @param primitiveMode The primitive mode
  43676. */
  43677. private setPrimitiveMode;
  43678. /**
  43679. * Sets the vertex attribute accessor based of the glTF mesh primitive
  43680. * @param meshPrimitive glTF mesh primitive
  43681. * @param attributeKind vertex attribute
  43682. * @returns boolean specifying if uv coordinates are present
  43683. */
  43684. private setAttributeKind;
  43685. /**
  43686. * Sets data for the primitive attributes of each submesh
  43687. * @param mesh glTF Mesh object to store the primitive attribute information
  43688. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  43689. * @param binaryWriter Buffer to write the attribute data to
  43690. */
  43691. private setPrimitiveAttributes;
  43692. /**
  43693. * Creates a glTF scene based on the array of meshes
  43694. * Returns the the total byte offset
  43695. * @param babylonScene Babylon scene to get the mesh data from
  43696. * @param binaryWriter Buffer to write binary data to
  43697. */
  43698. private createSceneAsync;
  43699. /**
  43700. * Creates a mapping of Node unique id to node index and handles animations
  43701. * @param babylonScene Babylon Scene
  43702. * @param nodes Babylon transform nodes
  43703. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  43704. * @param binaryWriter Buffer to write binary data to
  43705. * @returns Node mapping of unique id to index
  43706. */
  43707. private createNodeMapAndAnimations;
  43708. /**
  43709. * Creates a glTF node from a Babylon mesh
  43710. * @param babylonMesh Source Babylon mesh
  43711. * @param binaryWriter Buffer for storing geometry data
  43712. * @returns glTF node
  43713. */
  43714. private createNode;
  43715. }
  43716. /**
  43717. * @hidden
  43718. *
  43719. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  43720. */
  43721. class _BinaryWriter {
  43722. /**
  43723. * Array buffer which stores all binary data
  43724. */
  43725. private _arrayBuffer;
  43726. /**
  43727. * View of the array buffer
  43728. */
  43729. private _dataView;
  43730. /**
  43731. * byte offset of data in array buffer
  43732. */
  43733. private _byteOffset;
  43734. /**
  43735. * Initialize binary writer with an initial byte length
  43736. * @param byteLength Initial byte length of the array buffer
  43737. */
  43738. constructor(byteLength: number);
  43739. /**
  43740. * Resize the array buffer to the specified byte length
  43741. * @param byteLength
  43742. */
  43743. private resizeBuffer;
  43744. /**
  43745. * Get an array buffer with the length of the byte offset
  43746. * @returns ArrayBuffer resized to the byte offset
  43747. */
  43748. getArrayBuffer(): ArrayBuffer;
  43749. /**
  43750. * Get the byte offset of the array buffer
  43751. * @returns byte offset
  43752. */
  43753. getByteOffset(): number;
  43754. /**
  43755. * Stores an UInt8 in the array buffer
  43756. * @param entry
  43757. * @param byteOffset If defined, specifies where to set the value as an offset.
  43758. */
  43759. setUInt8(entry: number, byteOffset?: number): void;
  43760. /**
  43761. * Gets an UInt32 in the array buffer
  43762. * @param entry
  43763. * @param byteOffset If defined, specifies where to set the value as an offset.
  43764. */
  43765. getUInt32(byteOffset: number): number;
  43766. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  43767. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  43768. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  43769. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  43770. /**
  43771. * Stores a Float32 in the array buffer
  43772. * @param entry
  43773. */
  43774. setFloat32(entry: number, byteOffset?: number): void;
  43775. /**
  43776. * Stores an UInt32 in the array buffer
  43777. * @param entry
  43778. * @param byteOffset If defined, specifies where to set the value as an offset.
  43779. */
  43780. setUInt32(entry: number, byteOffset?: number): void;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * Class for holding and downloading glTF file data
  43786. */
  43787. class GLTFData {
  43788. /**
  43789. * Object which contains the file name as the key and its data as the value
  43790. */
  43791. glTFFiles: {
  43792. [fileName: string]: string | Blob;
  43793. };
  43794. /**
  43795. * Initializes the glTF file object
  43796. */
  43797. constructor();
  43798. /**
  43799. * Downloads the glTF data as files based on their names and data
  43800. */
  43801. downloadFiles(): void;
  43802. }
  43803. }
  43804. declare module BABYLON.GLTF2 {
  43805. /**
  43806. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  43807. * @hidden
  43808. */
  43809. class _GLTFMaterialExporter {
  43810. /**
  43811. * Represents the dielectric specular values for R, G and B
  43812. */
  43813. private static readonly _DielectricSpecular;
  43814. /**
  43815. * Allows the maximum specular power to be defined for material calculations
  43816. */
  43817. private static readonly _MaxSpecularPower;
  43818. /**
  43819. * Mapping to store textures
  43820. */
  43821. private _textureMap;
  43822. /**
  43823. * Numeric tolerance value
  43824. */
  43825. private static readonly _Epsilon;
  43826. /**
  43827. * Reference to the glTF Exporter
  43828. */
  43829. private _exporter;
  43830. constructor(exporter: _Exporter);
  43831. /**
  43832. * Specifies if two colors are approximately equal in value
  43833. * @param color1 first color to compare to
  43834. * @param color2 second color to compare to
  43835. * @param epsilon threshold value
  43836. */
  43837. private static FuzzyEquals;
  43838. /**
  43839. * Gets the materials from a Babylon scene and converts them to glTF materials
  43840. * @param scene babylonjs scene
  43841. * @param mimeType texture mime type
  43842. * @param images array of images
  43843. * @param textures array of textures
  43844. * @param materials array of materials
  43845. * @param imageData mapping of texture names to base64 textures
  43846. * @param hasTextureCoords specifies if texture coordinates are present on the material
  43847. */
  43848. /**
  43849. * Makes a copy of the glTF material without the texture parameters
  43850. * @param originalMaterial original glTF material
  43851. * @returns glTF material without texture parameters
  43852. */
  43853. /**
  43854. * Specifies if the material has any texture parameters present
  43855. * @param material glTF Material
  43856. * @returns boolean specifying if texture parameters are present
  43857. */
  43858. /**
  43859. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  43860. * @param babylonStandardMaterial
  43861. * @returns glTF Metallic Roughness Material representation
  43862. */
  43863. /**
  43864. * Computes the metallic factor
  43865. * @param diffuse diffused value
  43866. * @param specular specular value
  43867. * @param oneMinusSpecularStrength one minus the specular strength
  43868. * @returns metallic value
  43869. */
  43870. private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  43871. /**
  43872. * Gets the glTF alpha mode from the Babylon Material
  43873. * @param babylonMaterial Babylon Material
  43874. * @returns The Babylon alpha mode value
  43875. */
  43876. /**
  43877. * Converts a Babylon Standard Material to a glTF Material
  43878. * @param babylonStandardMaterial BJS Standard Material
  43879. * @param mimeType mime type to use for the textures
  43880. * @param images array of glTF image interfaces
  43881. * @param textures array of glTF texture interfaces
  43882. * @param materials array of glTF material interfaces
  43883. * @param imageData map of image file name to data
  43884. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  43885. */
  43886. /**
  43887. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  43888. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  43889. * @param mimeType mime type to use for the textures
  43890. * @param images array of glTF image interfaces
  43891. * @param textures array of glTF texture interfaces
  43892. * @param materials array of glTF material interfaces
  43893. * @param imageData map of image file name to data
  43894. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  43895. */
  43896. /**
  43897. * Converts an image typed array buffer to a base64 image
  43898. * @param buffer typed array buffer
  43899. * @param width width of the image
  43900. * @param height height of the image
  43901. * @param mimeType mimetype of the image
  43902. * @returns base64 image string
  43903. */
  43904. private _createBase64FromCanvasAsync;
  43905. /**
  43906. * Generates a white texture based on the specified width and height
  43907. * @param width width of the texture in pixels
  43908. * @param height height of the texture in pixels
  43909. * @param scene babylonjs scene
  43910. * @returns white texture
  43911. */
  43912. private _createWhiteTexture;
  43913. /**
  43914. * 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
  43915. * @param texture1 first texture to resize
  43916. * @param texture2 second texture to resize
  43917. * @param scene babylonjs scene
  43918. * @returns resized textures or null
  43919. */
  43920. private _resizeTexturesToSameDimensions;
  43921. /**
  43922. * Converts an array of pixels to a Float32Array
  43923. * Throws an error if the pixel format is not supported
  43924. * @param pixels - array buffer containing pixel values
  43925. * @returns Float32 of pixels
  43926. */
  43927. private _convertPixelArrayToFloat32;
  43928. /**
  43929. * Convert Specular Glossiness Textures to Metallic Roughness
  43930. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  43931. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  43932. * @param diffuseTexture texture used to store diffuse information
  43933. * @param specularGlossinessTexture texture used to store specular and glossiness information
  43934. * @param factors specular glossiness material factors
  43935. * @param mimeType the mime type to use for the texture
  43936. * @returns pbr metallic roughness interface or null
  43937. */
  43938. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  43939. /**
  43940. * Converts specular glossiness material properties to metallic roughness
  43941. * @param specularGlossiness interface with specular glossiness material properties
  43942. * @returns interface with metallic roughness material properties
  43943. */
  43944. private _convertSpecularGlossinessToMetallicRoughness;
  43945. /**
  43946. * Calculates the surface reflectance, independent of lighting conditions
  43947. * @param color Color source to calculate brightness from
  43948. * @returns number representing the perceived brightness, or zero if color is undefined
  43949. */
  43950. private _getPerceivedBrightness;
  43951. /**
  43952. * Returns the maximum color component value
  43953. * @param color
  43954. * @returns maximum color component value, or zero if color is null or undefined
  43955. */
  43956. private _getMaxComponent;
  43957. /**
  43958. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  43959. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  43960. * @param mimeType mime type to use for the textures
  43961. * @param images array of glTF image interfaces
  43962. * @param textures array of glTF texture interfaces
  43963. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  43964. * @param imageData map of image file name to data
  43965. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  43966. * @returns glTF PBR Metallic Roughness factors
  43967. */
  43968. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  43969. private _getGLTFTextureSampler;
  43970. private _getGLTFTextureWrapMode;
  43971. private _getGLTFTextureWrapModesSampler;
  43972. /**
  43973. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  43974. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  43975. * @param mimeType mime type to use for the textures
  43976. * @param images array of glTF image interfaces
  43977. * @param textures array of glTF texture interfaces
  43978. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  43979. * @param imageData map of image file name to data
  43980. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  43981. * @returns glTF PBR Metallic Roughness factors
  43982. */
  43983. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  43984. /**
  43985. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  43986. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  43987. * @param mimeType mime type to use for the textures
  43988. * @param images array of glTF image interfaces
  43989. * @param textures array of glTF texture interfaces
  43990. * @param materials array of glTF material interfaces
  43991. * @param imageData map of image file name to data
  43992. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  43993. */
  43994. private setMetallicRoughnessPbrMaterial;
  43995. private getPixelsFromTexture;
  43996. /**
  43997. * Extracts a texture from a Babylon texture into file data and glTF data
  43998. * @param babylonTexture Babylon texture to extract
  43999. * @param mimeType Mime Type of the babylonTexture
  44000. * @param images Array of glTF images
  44001. * @param textures Array of glTF textures
  44002. * @param imageData map of image file name and data
  44003. * @return glTF texture info, or null if the texture format is not supported
  44004. */
  44005. private _exportTextureAsync;
  44006. /**
  44007. * Builds a texture from base64 string
  44008. * @param base64Texture base64 texture string
  44009. * @param baseTextureName Name to use for the texture
  44010. * @param mimeType image mime type for the texture
  44011. * @param images array of images
  44012. * @param textures array of textures
  44013. * @param imageData map of image data
  44014. * @returns glTF texture info, or null if the texture format is not supported
  44015. */
  44016. private _getTextureInfoFromBase64;
  44017. }
  44018. }
  44019. declare module BABYLON.GLTF2 {
  44020. /**
  44021. * @hidden
  44022. * Interface to store animation data.
  44023. */
  44024. interface _IAnimationData {
  44025. /**
  44026. * Keyframe data.
  44027. */
  44028. inputs: number[];
  44029. /**
  44030. * Value data.
  44031. */
  44032. outputs: number[][];
  44033. /**
  44034. * Animation interpolation data.
  44035. */
  44036. samplerInterpolation: AnimationSamplerInterpolation;
  44037. /**
  44038. * Minimum keyframe value.
  44039. */
  44040. inputsMin: number;
  44041. /**
  44042. * Maximum keyframe value.
  44043. */
  44044. inputsMax: number;
  44045. }
  44046. /**
  44047. * @hidden
  44048. */
  44049. interface _IAnimationInfo {
  44050. /**
  44051. * The target channel for the animation
  44052. */
  44053. animationChannelTargetPath: AnimationChannelTargetPath;
  44054. /**
  44055. * The glTF accessor type for the data.
  44056. */
  44057. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  44058. /**
  44059. * Specifies if quaternions should be used.
  44060. */
  44061. useQuaternion: boolean;
  44062. }
  44063. /**
  44064. * @hidden
  44065. * Utility class for generating glTF animation data from BabylonJS.
  44066. */
  44067. class _GLTFAnimation {
  44068. /**
  44069. * @ignore
  44070. *
  44071. * Creates glTF channel animation from BabylonJS animation.
  44072. * @param babylonTransformNode - BabylonJS mesh.
  44073. * @param animation - animation.
  44074. * @param animationChannelTargetPath - The target animation channel.
  44075. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  44076. * @param useQuaternion - Specifies if quaternions are used.
  44077. * @returns nullable IAnimationData
  44078. */
  44079. private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  44080. private static _DeduceAnimationInfo;
  44081. /**
  44082. * @ignore
  44083. * Create node animations from the transform node animations
  44084. * @param babylonTransformNode
  44085. * @param runtimeGLTFAnimation
  44086. * @param idleGLTFAnimations
  44087. * @param nodeMap
  44088. * @param nodes
  44089. * @param binaryWriter
  44090. * @param bufferViews
  44091. * @param accessors
  44092. * @param convertToRightHandedSystem
  44093. */
  44094. private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  44095. [key: number]: number;
  44096. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  44097. /**
  44098. * @ignore
  44099. * Create node animations from the animation groups
  44100. * @param babylonScene
  44101. * @param glTFAnimations
  44102. * @param nodeMap
  44103. * @param nodes
  44104. * @param binaryWriter
  44105. * @param bufferViews
  44106. * @param accessors
  44107. * @param convertToRightHandedSystem
  44108. */
  44109. private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  44110. [key: number]: number;
  44111. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  44112. private static AddAnimation;
  44113. /**
  44114. * Create a baked animation
  44115. * @param babylonTransformNode BabylonJS mesh
  44116. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  44117. * @param animationChannelTargetPath animation target channel
  44118. * @param minFrame minimum animation frame
  44119. * @param maxFrame maximum animation frame
  44120. * @param fps frames per second of the animation
  44121. * @param inputs input key frames of the animation
  44122. * @param outputs output key frame data of the animation
  44123. * @param convertToRightHandedSystem converts the values to right-handed
  44124. * @param useQuaternion specifies if quaternions should be used
  44125. */
  44126. private static _CreateBakedAnimation;
  44127. private static _ConvertFactorToVector3OrQuaternion;
  44128. private static _SetInterpolatedValue;
  44129. /**
  44130. * Creates linear animation from the animation key frames
  44131. * @param babylonTransformNode BabylonJS mesh
  44132. * @param animation BabylonJS animation
  44133. * @param animationChannelTargetPath The target animation channel
  44134. * @param frameDelta The difference between the last and first frame of the animation
  44135. * @param inputs Array to store the key frame times
  44136. * @param outputs Array to store the key frame data
  44137. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  44138. * @param useQuaternion Specifies if quaternions are used in the animation
  44139. */
  44140. private static _CreateLinearOrStepAnimation;
  44141. /**
  44142. * Creates cubic spline animation from the animation key frames
  44143. * @param babylonTransformNode BabylonJS mesh
  44144. * @param animation BabylonJS animation
  44145. * @param animationChannelTargetPath The target animation channel
  44146. * @param frameDelta The difference between the last and first frame of the animation
  44147. * @param inputs Array to store the key frame times
  44148. * @param outputs Array to store the key frame data
  44149. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  44150. * @param useQuaternion Specifies if quaternions are used in the animation
  44151. */
  44152. private static _CreateCubicSplineAnimation;
  44153. private static _GetBasePositionRotationOrScale;
  44154. /**
  44155. * Adds a key frame value
  44156. * @param keyFrame
  44157. * @param animation
  44158. * @param outputs
  44159. * @param animationChannelTargetPath
  44160. * @param basePositionRotationOrScale
  44161. * @param convertToRightHandedSystem
  44162. * @param useQuaternion
  44163. */
  44164. private static _AddKeyframeValue;
  44165. /**
  44166. * Determine the interpolation based on the key frames
  44167. * @param keyFrames
  44168. * @param animationChannelTargetPath
  44169. * @param useQuaternion
  44170. */
  44171. private static _DeduceInterpolation;
  44172. /**
  44173. * Adds an input tangent or output tangent to the output data
  44174. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  44175. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  44176. * @param outputs The animation data by keyframe
  44177. * @param animationChannelTargetPath The target animation channel
  44178. * @param interpolation The interpolation type
  44179. * @param keyFrame The key frame with the animation data
  44180. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  44181. * @param useQuaternion Specifies if quaternions are used
  44182. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  44183. */
  44184. private static AddSplineTangent;
  44185. /**
  44186. * Get the minimum and maximum key frames' frame values
  44187. * @param keyFrames animation key frames
  44188. * @returns the minimum and maximum key frame value
  44189. */
  44190. private static calculateMinMaxKeyFrames;
  44191. }
  44192. }
  44193. declare module BABYLON.GLTF2 {
  44194. /**
  44195. * @hidden
  44196. */
  44197. class _GLTFUtilities {
  44198. /**
  44199. * Creates a buffer view based on the supplied arguments
  44200. * @param bufferIndex index value of the specified buffer
  44201. * @param byteOffset byte offset value
  44202. * @param byteLength byte length of the bufferView
  44203. * @param byteStride byte distance between conequential elements
  44204. * @param name name of the buffer view
  44205. * @returns bufferView for glTF
  44206. */
  44207. private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  44208. /**
  44209. * Creates an accessor based on the supplied arguments
  44210. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  44211. * @param name The name of the accessor
  44212. * @param type The type of the accessor
  44213. * @param componentType The datatype of components in the attribute
  44214. * @param count The number of attributes referenced by this accessor
  44215. * @param byteOffset The offset relative to the start of the bufferView in bytes
  44216. * @param min Minimum value of each component in this attribute
  44217. * @param max Maximum value of each component in this attribute
  44218. * @returns accessor for glTF
  44219. */
  44220. private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  44221. /**
  44222. * Calculates the minimum and maximum values of an array of position floats
  44223. * @param positions Positions array of a mesh
  44224. * @param vertexStart Starting vertex offset to calculate min and max values
  44225. * @param vertexCount Number of vertices to check for min and max values
  44226. * @returns min number array and max number array
  44227. */
  44228. private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  44229. min: number[];
  44230. max: number[];
  44231. };
  44232. /**
  44233. * Converts a new right-handed Vector3
  44234. * @param vector vector3 array
  44235. * @returns right-handed Vector3
  44236. */
  44237. private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  44238. /**
  44239. * Converts a Vector3 to right-handed
  44240. * @param vector Vector3 to convert to right-handed
  44241. */
  44242. private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  44243. /**
  44244. * Converts a three element number array to right-handed
  44245. * @param vector number array to convert to right-handed
  44246. */
  44247. private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  44248. /**
  44249. * Converts a new right-handed Vector3
  44250. * @param vector vector3 array
  44251. * @returns right-handed Vector3
  44252. */
  44253. private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  44254. /**
  44255. * Converts a Vector3 to right-handed
  44256. * @param vector Vector3 to convert to right-handed
  44257. */
  44258. private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  44259. /**
  44260. * Converts a three element number array to right-handed
  44261. * @param vector number array to convert to right-handed
  44262. */
  44263. private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  44264. /**
  44265. * Converts a Vector4 to right-handed
  44266. * @param vector Vector4 to convert to right-handed
  44267. */
  44268. private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  44269. /**
  44270. * Converts a Vector4 to right-handed
  44271. * @param vector Vector4 to convert to right-handed
  44272. */
  44273. private static _GetRightHandedArray4FromRef(vector: number[]): void;
  44274. /**
  44275. * Converts a Quaternion to right-handed
  44276. * @param quaternion Source quaternion to convert to right-handed
  44277. */
  44278. private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  44279. /**
  44280. * Converts a Quaternion to right-handed
  44281. * @param quaternion Source quaternion to convert to right-handed
  44282. */
  44283. private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  44284. private static _NormalizeTangentFromRef(tangent: Vector4): void;
  44285. }
  44286. }
  44287. /**
  44288. * @ignoreChildren
  44289. * @ignore
  44290. */
  44291. declare module "babylonjs-gltf2interface" {
  44292. export = BABYLON.GLTF2;
  44293. }
  44294. /**
  44295. * Moduel for glTF 2.0 Interface
  44296. */
  44297. declare module BABYLON.GLTF2 {
  44298. /**
  44299. * The datatype of the components in the attribute
  44300. */
  44301. const enum AccessorComponentType {
  44302. /**
  44303. * Byte
  44304. */
  44305. BYTE = 5120,
  44306. /**
  44307. * Unsigned Byte
  44308. */
  44309. UNSIGNED_BYTE = 5121,
  44310. /**
  44311. * Short
  44312. */
  44313. SHORT = 5122,
  44314. /**
  44315. * Unsigned Short
  44316. */
  44317. UNSIGNED_SHORT = 5123,
  44318. /**
  44319. * Unsigned Int
  44320. */
  44321. UNSIGNED_INT = 5125,
  44322. /**
  44323. * Float
  44324. */
  44325. FLOAT = 5126,
  44326. }
  44327. /**
  44328. * Specifies if the attirbute is a scalar, vector, or matrix
  44329. */
  44330. const enum AccessorType {
  44331. /**
  44332. * Scalar
  44333. */
  44334. SCALAR = "SCALAR",
  44335. /**
  44336. * Vector2
  44337. */
  44338. VEC2 = "VEC2",
  44339. /**
  44340. * Vector3
  44341. */
  44342. VEC3 = "VEC3",
  44343. /**
  44344. * Vector4
  44345. */
  44346. VEC4 = "VEC4",
  44347. /**
  44348. * Matrix2x2
  44349. */
  44350. MAT2 = "MAT2",
  44351. /**
  44352. * Matrix3x3
  44353. */
  44354. MAT3 = "MAT3",
  44355. /**
  44356. * Matrix4x4
  44357. */
  44358. MAT4 = "MAT4",
  44359. }
  44360. /**
  44361. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  44362. */
  44363. const enum AnimationChannelTargetPath {
  44364. /**
  44365. * Translation
  44366. */
  44367. TRANSLATION = "translation",
  44368. /**
  44369. * Rotation
  44370. */
  44371. ROTATION = "rotation",
  44372. /**
  44373. * Scale
  44374. */
  44375. SCALE = "scale",
  44376. /**
  44377. * Weights
  44378. */
  44379. WEIGHTS = "weights",
  44380. }
  44381. /**
  44382. * Interpolation algorithm
  44383. */
  44384. const enum AnimationSamplerInterpolation {
  44385. /**
  44386. * The animated values are linearly interpolated between keyframes
  44387. */
  44388. LINEAR = "LINEAR",
  44389. /**
  44390. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  44391. */
  44392. STEP = "STEP",
  44393. /**
  44394. * The animation's interpolation is computed using a cubic spline with specified tangents
  44395. */
  44396. CUBICSPLINE = "CUBICSPLINE",
  44397. }
  44398. /**
  44399. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  44400. */
  44401. const enum CameraType {
  44402. /**
  44403. * A perspective camera containing properties to create a perspective projection matrix
  44404. */
  44405. PERSPECTIVE = "perspective",
  44406. /**
  44407. * An orthographic camera containing properties to create an orthographic projection matrix
  44408. */
  44409. ORTHOGRAPHIC = "orthographic",
  44410. }
  44411. /**
  44412. * The mime-type of the image
  44413. */
  44414. const enum ImageMimeType {
  44415. /**
  44416. * JPEG Mime-type
  44417. */
  44418. JPEG = "image/jpeg",
  44419. /**
  44420. * PNG Mime-type
  44421. */
  44422. PNG = "image/png",
  44423. }
  44424. /**
  44425. * The alpha rendering mode of the material
  44426. */
  44427. const enum MaterialAlphaMode {
  44428. /**
  44429. * The alpha value is ignored and the rendered output is fully opaque
  44430. */
  44431. OPAQUE = "OPAQUE",
  44432. /**
  44433. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  44434. */
  44435. MASK = "MASK",
  44436. /**
  44437. * 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)
  44438. */
  44439. BLEND = "BLEND",
  44440. }
  44441. /**
  44442. * The type of the primitives to render
  44443. */
  44444. const enum MeshPrimitiveMode {
  44445. /**
  44446. * Points
  44447. */
  44448. POINTS = 0,
  44449. /**
  44450. * Lines
  44451. */
  44452. LINES = 1,
  44453. /**
  44454. * Line Loop
  44455. */
  44456. LINE_LOOP = 2,
  44457. /**
  44458. * Line Strip
  44459. */
  44460. LINE_STRIP = 3,
  44461. /**
  44462. * Triangles
  44463. */
  44464. TRIANGLES = 4,
  44465. /**
  44466. * Triangle Strip
  44467. */
  44468. TRIANGLE_STRIP = 5,
  44469. /**
  44470. * Triangle Fan
  44471. */
  44472. TRIANGLE_FAN = 6,
  44473. }
  44474. /**
  44475. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  44476. */
  44477. const enum TextureMagFilter {
  44478. /**
  44479. * Nearest
  44480. */
  44481. NEAREST = 9728,
  44482. /**
  44483. * Linear
  44484. */
  44485. LINEAR = 9729,
  44486. }
  44487. /**
  44488. * Minification filter. All valid values correspond to WebGL enums
  44489. */
  44490. const enum TextureMinFilter {
  44491. /**
  44492. * Nearest
  44493. */
  44494. NEAREST = 9728,
  44495. /**
  44496. * Linear
  44497. */
  44498. LINEAR = 9729,
  44499. /**
  44500. * Nearest Mip-Map Nearest
  44501. */
  44502. NEAREST_MIPMAP_NEAREST = 9984,
  44503. /**
  44504. * Linear Mipmap Nearest
  44505. */
  44506. LINEAR_MIPMAP_NEAREST = 9985,
  44507. /**
  44508. * Nearest Mipmap Linear
  44509. */
  44510. NEAREST_MIPMAP_LINEAR = 9986,
  44511. /**
  44512. * Linear Mipmap Linear
  44513. */
  44514. LINEAR_MIPMAP_LINEAR = 9987,
  44515. }
  44516. /**
  44517. * S (U) wrapping mode. All valid values correspond to WebGL enums
  44518. */
  44519. const enum TextureWrapMode {
  44520. /**
  44521. * Clamp to Edge
  44522. */
  44523. CLAMP_TO_EDGE = 33071,
  44524. /**
  44525. * Mirrored Repeat
  44526. */
  44527. MIRRORED_REPEAT = 33648,
  44528. /**
  44529. * Repeat
  44530. */
  44531. REPEAT = 10497,
  44532. }
  44533. /**
  44534. * glTF Property
  44535. */
  44536. interface IProperty {
  44537. /**
  44538. * Dictionary object with extension-specific objects
  44539. */
  44540. extensions?: {
  44541. [key: string]: any;
  44542. };
  44543. /**
  44544. * Application-Specific data
  44545. */
  44546. extras?: any;
  44547. }
  44548. /**
  44549. * glTF Child of Root Property
  44550. */
  44551. interface IChildRootProperty extends IProperty {
  44552. /**
  44553. * The user-defined name of this object
  44554. */
  44555. name?: string;
  44556. }
  44557. /**
  44558. * Indices of those attributes that deviate from their initialization value
  44559. */
  44560. interface IAccessorSparseIndices extends IProperty {
  44561. /**
  44562. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  44563. */
  44564. bufferView: number;
  44565. /**
  44566. * The offset relative to the start of the bufferView in bytes. Must be aligned
  44567. */
  44568. byteOffset?: number;
  44569. /**
  44570. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  44571. */
  44572. componentType: AccessorComponentType;
  44573. }
  44574. /**
  44575. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  44576. */
  44577. interface IAccessorSparseValues extends IProperty {
  44578. /**
  44579. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  44580. */
  44581. bufferView: number;
  44582. /**
  44583. * The offset relative to the start of the bufferView in bytes. Must be aligned
  44584. */
  44585. byteOffset?: number;
  44586. }
  44587. /**
  44588. * Sparse storage of attributes that deviate from their initialization value
  44589. */
  44590. interface IAccessorSparse extends IProperty {
  44591. /**
  44592. * The number of attributes encoded in this sparse accessor
  44593. */
  44594. count: number;
  44595. /**
  44596. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  44597. */
  44598. indices: IAccessorSparseIndices;
  44599. /**
  44600. * 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
  44601. */
  44602. values: IAccessorSparseValues;
  44603. }
  44604. /**
  44605. * 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
  44606. */
  44607. interface IAccessor extends IChildRootProperty {
  44608. /**
  44609. * The index of the bufferview
  44610. */
  44611. bufferView?: number;
  44612. /**
  44613. * The offset relative to the start of the bufferView in bytes
  44614. */
  44615. byteOffset?: number;
  44616. /**
  44617. * The datatype of components in the attribute
  44618. */
  44619. componentType: AccessorComponentType;
  44620. /**
  44621. * Specifies whether integer data values should be normalized
  44622. */
  44623. normalized?: boolean;
  44624. /**
  44625. * The number of attributes referenced by this accessor
  44626. */
  44627. count: number;
  44628. /**
  44629. * Specifies if the attribute is a scalar, vector, or matrix
  44630. */
  44631. type: AccessorType;
  44632. /**
  44633. * Maximum value of each component in this attribute
  44634. */
  44635. max?: number[];
  44636. /**
  44637. * Minimum value of each component in this attribute
  44638. */
  44639. min?: number[];
  44640. /**
  44641. * Sparse storage of attributes that deviate from their initialization value
  44642. */
  44643. sparse?: IAccessorSparse;
  44644. }
  44645. /**
  44646. * Targets an animation's sampler at a node's property
  44647. */
  44648. interface IAnimationChannel extends IProperty {
  44649. /**
  44650. * The index of a sampler in this animation used to compute the value for the target
  44651. */
  44652. sampler: number;
  44653. /**
  44654. * The index of the node and TRS property to target
  44655. */
  44656. target: IAnimationChannelTarget;
  44657. }
  44658. /**
  44659. * The index of the node and TRS property that an animation channel targets
  44660. */
  44661. interface IAnimationChannelTarget extends IProperty {
  44662. /**
  44663. * The index of the node to target
  44664. */
  44665. node: number;
  44666. /**
  44667. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  44668. */
  44669. path: AnimationChannelTargetPath;
  44670. }
  44671. /**
  44672. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  44673. */
  44674. interface IAnimationSampler extends IProperty {
  44675. /**
  44676. * The index of an accessor containing keyframe input values, e.g., time
  44677. */
  44678. input: number;
  44679. /**
  44680. * Interpolation algorithm
  44681. */
  44682. interpolation?: AnimationSamplerInterpolation;
  44683. /**
  44684. * The index of an accessor, containing keyframe output values
  44685. */
  44686. output: number;
  44687. }
  44688. /**
  44689. * A keyframe animation
  44690. */
  44691. interface IAnimation extends IChildRootProperty {
  44692. /**
  44693. * An array of channels, each of which targets an animation's sampler at a node's property
  44694. */
  44695. channels: IAnimationChannel[];
  44696. /**
  44697. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  44698. */
  44699. samplers: IAnimationSampler[];
  44700. }
  44701. /**
  44702. * Metadata about the glTF asset
  44703. */
  44704. interface IAsset extends IChildRootProperty {
  44705. /**
  44706. * A copyright message suitable for display to credit the content creator
  44707. */
  44708. copyright?: string;
  44709. /**
  44710. * Tool that generated this glTF model. Useful for debugging
  44711. */
  44712. generator?: string;
  44713. /**
  44714. * The glTF version that this asset targets
  44715. */
  44716. version: string;
  44717. /**
  44718. * The minimum glTF version that this asset targets
  44719. */
  44720. minVersion?: string;
  44721. }
  44722. /**
  44723. * A buffer points to binary geometry, animation, or skins
  44724. */
  44725. interface IBuffer extends IChildRootProperty {
  44726. /**
  44727. * 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
  44728. */
  44729. uri?: string;
  44730. /**
  44731. * The length of the buffer in bytes
  44732. */
  44733. byteLength: number;
  44734. }
  44735. /**
  44736. * A view into a buffer generally representing a subset of the buffer
  44737. */
  44738. interface IBufferView extends IChildRootProperty {
  44739. /**
  44740. * The index of the buffer
  44741. */
  44742. buffer: number;
  44743. /**
  44744. * The offset into the buffer in bytes
  44745. */
  44746. byteOffset?: number;
  44747. /**
  44748. * The lenth of the bufferView in bytes
  44749. */
  44750. byteLength: number;
  44751. /**
  44752. * The stride, in bytes
  44753. */
  44754. byteStride?: number;
  44755. }
  44756. /**
  44757. * An orthographic camera containing properties to create an orthographic projection matrix
  44758. */
  44759. interface ICameraOrthographic extends IProperty {
  44760. /**
  44761. * The floating-point horizontal magnification of the view. Must not be zero
  44762. */
  44763. xmag: number;
  44764. /**
  44765. * The floating-point vertical magnification of the view. Must not be zero
  44766. */
  44767. ymag: number;
  44768. /**
  44769. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  44770. */
  44771. zfar: number;
  44772. /**
  44773. * The floating-point distance to the near clipping plane
  44774. */
  44775. znear: number;
  44776. }
  44777. /**
  44778. * A perspective camera containing properties to create a perspective projection matrix
  44779. */
  44780. interface ICameraPerspective extends IProperty {
  44781. /**
  44782. * The floating-point aspect ratio of the field of view
  44783. */
  44784. aspectRatio?: number;
  44785. /**
  44786. * The floating-point vertical field of view in radians
  44787. */
  44788. yfov: number;
  44789. /**
  44790. * The floating-point distance to the far clipping plane
  44791. */
  44792. zfar?: number;
  44793. /**
  44794. * The floating-point distance to the near clipping plane
  44795. */
  44796. znear: number;
  44797. }
  44798. /**
  44799. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  44800. */
  44801. interface ICamera extends IChildRootProperty {
  44802. /**
  44803. * An orthographic camera containing properties to create an orthographic projection matrix
  44804. */
  44805. orthographic?: ICameraOrthographic;
  44806. /**
  44807. * A perspective camera containing properties to create a perspective projection matrix
  44808. */
  44809. perspective?: ICameraPerspective;
  44810. /**
  44811. * Specifies if the camera uses a perspective or orthographic projection
  44812. */
  44813. type: CameraType;
  44814. }
  44815. /**
  44816. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  44817. */
  44818. interface IImage extends IChildRootProperty {
  44819. /**
  44820. * 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
  44821. */
  44822. uri?: string;
  44823. /**
  44824. * The image's MIME type
  44825. */
  44826. mimeType?: ImageMimeType;
  44827. /**
  44828. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  44829. */
  44830. bufferView?: number;
  44831. }
  44832. /**
  44833. * Material Normal Texture Info
  44834. */
  44835. interface IMaterialNormalTextureInfo extends ITextureInfo {
  44836. /**
  44837. * The scalar multiplier applied to each normal vector of the normal texture
  44838. */
  44839. scale?: number;
  44840. }
  44841. /**
  44842. * Material Occlusion Texture Info
  44843. */
  44844. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  44845. /**
  44846. * A scalar multiplier controlling the amount of occlusion applied
  44847. */
  44848. strength?: number;
  44849. }
  44850. /**
  44851. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  44852. */
  44853. interface IMaterialPbrMetallicRoughness {
  44854. /**
  44855. * The material's base color factor
  44856. */
  44857. baseColorFactor?: number[];
  44858. /**
  44859. * The base color texture
  44860. */
  44861. baseColorTexture?: ITextureInfo;
  44862. /**
  44863. * The metalness of the material
  44864. */
  44865. metallicFactor?: number;
  44866. /**
  44867. * The roughness of the material
  44868. */
  44869. roughnessFactor?: number;
  44870. /**
  44871. * The metallic-roughness texture
  44872. */
  44873. metallicRoughnessTexture?: ITextureInfo;
  44874. }
  44875. /**
  44876. * The material appearance of a primitive
  44877. */
  44878. interface IMaterial extends IChildRootProperty {
  44879. /**
  44880. * 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
  44881. */
  44882. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  44883. /**
  44884. * The normal map texture
  44885. */
  44886. normalTexture?: IMaterialNormalTextureInfo;
  44887. /**
  44888. * The occlusion map texture
  44889. */
  44890. occlusionTexture?: IMaterialOcclusionTextureInfo;
  44891. /**
  44892. * The emissive map texture
  44893. */
  44894. emissiveTexture?: ITextureInfo;
  44895. /**
  44896. * 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
  44897. */
  44898. emissiveFactor?: number[];
  44899. /**
  44900. * The alpha rendering mode of the material
  44901. */
  44902. alphaMode?: MaterialAlphaMode;
  44903. /**
  44904. * The alpha cutoff value of the material
  44905. */
  44906. alphaCutoff?: number;
  44907. /**
  44908. * Specifies whether the material is double sided
  44909. */
  44910. doubleSided?: boolean;
  44911. }
  44912. /**
  44913. * Geometry to be rendered with the given material
  44914. */
  44915. interface IMeshPrimitive extends IProperty {
  44916. /**
  44917. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  44918. */
  44919. attributes: {
  44920. [name: string]: number;
  44921. };
  44922. /**
  44923. * The index of the accessor that contains the indices
  44924. */
  44925. indices?: number;
  44926. /**
  44927. * The index of the material to apply to this primitive when rendering
  44928. */
  44929. material?: number;
  44930. /**
  44931. * The type of primitives to render. All valid values correspond to WebGL enums
  44932. */
  44933. mode?: MeshPrimitiveMode;
  44934. /**
  44935. * 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
  44936. */
  44937. targets?: {
  44938. [name: string]: number;
  44939. }[];
  44940. }
  44941. /**
  44942. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  44943. */
  44944. interface IMesh extends IChildRootProperty {
  44945. /**
  44946. * An array of primitives, each defining geometry to be rendered with a material
  44947. */
  44948. primitives: IMeshPrimitive[];
  44949. /**
  44950. * Array of weights to be applied to the Morph Targets
  44951. */
  44952. weights?: number[];
  44953. }
  44954. /**
  44955. * A node in the node hierarchy
  44956. */
  44957. interface INode extends IChildRootProperty {
  44958. /**
  44959. * The index of the camera referenced by this node
  44960. */
  44961. camera?: number;
  44962. /**
  44963. * The indices of this node's children
  44964. */
  44965. children?: number[];
  44966. /**
  44967. * The index of the skin referenced by this node
  44968. */
  44969. skin?: number;
  44970. /**
  44971. * A floating-point 4x4 transformation matrix stored in column-major order
  44972. */
  44973. matrix?: number[];
  44974. /**
  44975. * The index of the mesh in this node
  44976. */
  44977. mesh?: number;
  44978. /**
  44979. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  44980. */
  44981. rotation?: number[];
  44982. /**
  44983. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  44984. */
  44985. scale?: number[];
  44986. /**
  44987. * The node's translation along the x, y, and z axes
  44988. */
  44989. translation?: number[];
  44990. /**
  44991. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  44992. */
  44993. weights?: number[];
  44994. }
  44995. /**
  44996. * Texture sampler properties for filtering and wrapping modes
  44997. */
  44998. interface ISampler extends IChildRootProperty {
  44999. /**
  45000. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  45001. */
  45002. magFilter?: TextureMagFilter;
  45003. /**
  45004. * Minification filter. All valid values correspond to WebGL enums
  45005. */
  45006. minFilter?: TextureMinFilter;
  45007. /**
  45008. * S (U) wrapping mode. All valid values correspond to WebGL enums
  45009. */
  45010. wrapS?: TextureWrapMode;
  45011. /**
  45012. * T (V) wrapping mode. All valid values correspond to WebGL enums
  45013. */
  45014. wrapT?: TextureWrapMode;
  45015. }
  45016. /**
  45017. * The root nodes of a scene
  45018. */
  45019. interface IScene extends IChildRootProperty {
  45020. /**
  45021. * The indices of each root node
  45022. */
  45023. nodes: number[];
  45024. }
  45025. /**
  45026. * Joints and matrices defining a skin
  45027. */
  45028. interface ISkin extends IChildRootProperty {
  45029. /**
  45030. * 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
  45031. */
  45032. inverseBindMatrices?: number;
  45033. /**
  45034. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  45035. */
  45036. skeleton?: number;
  45037. /**
  45038. * 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)
  45039. */
  45040. joints: number[];
  45041. }
  45042. /**
  45043. * A texture and its sampler
  45044. */
  45045. interface ITexture extends IChildRootProperty {
  45046. /**
  45047. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  45048. */
  45049. sampler?: number;
  45050. /**
  45051. * The index of the image used by this texture
  45052. */
  45053. source: number;
  45054. }
  45055. /**
  45056. * Reference to a texture
  45057. */
  45058. interface ITextureInfo extends IProperty {
  45059. /**
  45060. * The index of the texture
  45061. */
  45062. index: number;
  45063. /**
  45064. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  45065. */
  45066. texCoord?: number;
  45067. }
  45068. /**
  45069. * The root object for a glTF asset
  45070. */
  45071. interface IGLTF extends IProperty {
  45072. /**
  45073. * An array of accessors. An accessor is a typed view into a bufferView
  45074. */
  45075. accessors?: IAccessor[];
  45076. /**
  45077. * An array of keyframe animations
  45078. */
  45079. animations?: IAnimation[];
  45080. /**
  45081. * Metadata about the glTF asset
  45082. */
  45083. asset: IAsset;
  45084. /**
  45085. * An array of buffers. A buffer points to binary geometry, animation, or skins
  45086. */
  45087. buffers?: IBuffer[];
  45088. /**
  45089. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  45090. */
  45091. bufferViews?: IBufferView[];
  45092. /**
  45093. * An array of cameras
  45094. */
  45095. cameras?: ICamera[];
  45096. /**
  45097. * Names of glTF extensions used somewhere in this asset
  45098. */
  45099. extensionsUsed?: string[];
  45100. /**
  45101. * Names of glTF extensions required to properly load this asset
  45102. */
  45103. extensionsRequired?: string[];
  45104. /**
  45105. * An array of images. An image defines data used to create a texture
  45106. */
  45107. images?: IImage[];
  45108. /**
  45109. * An array of materials. A material defines the appearance of a primitive
  45110. */
  45111. materials?: IMaterial[];
  45112. /**
  45113. * An array of meshes. A mesh is a set of primitives to be rendered
  45114. */
  45115. meshes?: IMesh[];
  45116. /**
  45117. * An array of nodes
  45118. */
  45119. nodes?: INode[];
  45120. /**
  45121. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  45122. */
  45123. samplers?: ISampler[];
  45124. /**
  45125. * The index of the default scene
  45126. */
  45127. scene?: number;
  45128. /**
  45129. * An array of scenes
  45130. */
  45131. scenes?: IScene[];
  45132. /**
  45133. * An array of skins. A skin is defined by joints and matrices
  45134. */
  45135. skins?: ISkin[];
  45136. /**
  45137. * An array of textures
  45138. */
  45139. textures?: ITexture[];
  45140. }
  45141. }